2014-02-08 19:35:02 +00:00
|
|
|
---
|
|
|
|
layout: post
|
|
|
|
title: "Internet sharing (ipv4 and ipv6) on archlinux using dnsmasq"
|
|
|
|
date: 2014-02-08 20:02:22 +0100
|
|
|
|
comments: true
|
|
|
|
categories:
|
|
|
|
- arch
|
|
|
|
- dhcp
|
|
|
|
- ipv6 router advertisement
|
2015-01-19 23:43:59 +00:00
|
|
|
- network
|
2014-02-08 19:35:02 +00:00
|
|
|
---
|
|
|
|
|
2014-02-09 08:59:11 +00:00
|
|
|
**Update:** Added adhoc wlan network
|
|
|
|
|
2014-02-08 19:35:02 +00:00
|
|
|
A guide to connect with a different machine using a ethernet cable for
|
|
|
|
internet sharing or just transferring files:
|
|
|
|
|
|
|
|
1. Install dnsmasq and iproute2
|
|
|
|
|
|
|
|
$ pacman -S dnsmasq iproute2
|
|
|
|
|
|
|
|
2. Copy over the configuration files at the end of the article and edit the
|
2014-02-09 08:59:11 +00:00
|
|
|
*/etc/conf.d/share-internet@\<device\>* to match your network setup. (where
|
|
|
|
\<device\> is your network device)
|
2014-02-08 19:35:02 +00:00
|
|
|
|
|
|
|
3. Start the sharing service with systemd
|
|
|
|
|
2014-02-09 08:59:11 +00:00
|
|
|
$ sudo systemctl start internet-sharing@<device>.service
|
2014-02-08 19:35:02 +00:00
|
|
|
|
|
|
|
After that the other machine can connect via dhcp. It will get an ipv4
|
|
|
|
address from the **10.20.0.0/24** subnet and a ipv6 address from the **fd21:30c2:dd2f::**
|
|
|
|
subnet. Your host will be reachable via **10.20.0.1** or **fd21:30c2:dd2f::1**.
|
|
|
|
Thanks to ipv6 router advertising, an AAAA record for each host is automatically set based on the hostname.
|
|
|
|
This means if your hostname is *foo*, all members of the network can just connect
|
|
|
|
to it using the address *foo*. You should disable the share-internet.service, if
|
|
|
|
you don't need it. Otherwise you might mess up network setups, if you connect to a
|
|
|
|
network with the device on which the dhcp service is running.
|
|
|
|
|
|
|
|
Happy networking!
|
|
|
|
|
|
|
|
{% include_code /etc/systemd/system/share-internet.service lang:ini share-internet/share-internet.service %}
|
|
|
|
|
|
|
|
{% include_code /etc/dnsmasq.conf lang:ini share-internet/dnsmasq.conf %}
|
|
|
|
|
2014-02-09 08:59:11 +00:00
|
|
|
Ethernet to Wlan:
|
|
|
|
|
|
|
|
{% include_code /etc/conf.d/share-internet@enp0s25 lang:bash share-internet/share-internet@enp0s25 %}
|
|
|
|
|
|
|
|
Wlan to Ethernet:
|
|
|
|
|
|
|
|
If you have luck and your wifi driver is capable of the infrastructure mode,
|
|
|
|
you should take a look at hostadp, in my case I have to create an adhoc network.
|
|
|
|
To enable the adhoc network:
|
|
|
|
|
|
|
|
$ sudo systemctl enable wireless-adhoc@\<device\>.service
|
|
|
|
|
|
|
|
{% include_code /etc/conf.d/share-internet@wlp3s0 lang:bash share-internet/share-internet@wlp3s0 %}
|
|
|
|
|
|
|
|
{% include_code /etc/systemd/system/wireless-adhoc@.service lang:ini share-internet/wireless-adhoc@.service %}
|
|
|
|
|
|
|
|
{% include_code /etc/wpa_supplicant/wpa_supplicant-adhoc-wlp3s0.conf lang:bash share-internet/wpa_supplicant-adhoc-wlp3s0.conf %}
|