Sharing the wireless connection of a laptop with the ZedBoard through an Ethernet cable
The following assumes that the laptop runs Debian jessie but things should be very similar with most Debian-like GNU/Linux distributions. If you are using a completely different OS, please find out the equivalent steps for your OS. We also assume that:
- the laptop network interfaces are
wlan0
(wireless) andeth0
(wired), - the laptop's IP address in the wired network is
10.42.0.103
, - the ZedBoard runs a Linux kernel and has networking enabled,
- the ZedBoard's Ethernet and IP addresses are
00:0A:35:00:01:06
and10.42.0.6
, respectively, - and the ZedBoard's host name must be
secbus
.
Please adapt to your own setting.
First install the dnsmasq
and iptables-persistent
packages:
sudo apt-get install dnsmasq iptables-persistent
dnsmasq
provides a local DNS server for the laptop and its wired network, with forwarding of all query types to upstream recursive DNS servers. It also does DNS caching and has an integrated DHCP server. Edit the /etc/dnsmasq.conf
file (search for the indicated commented lines and add yours below):
-
Restrict the
dnsmasq
services to theeth0
interface of the laptop (for security reasons):#interface interface=eth0
-
Enable the DHCP server and define the IP address available for lease (with infinite lease time):
#dhcp-range=192.168.0.50,192.168.0.150,12h dhcp-range=eth0,10.42.0.6,10.42.0.6,infinite
-
Define the IP address and host name to give to your ZedBoard (by Ethernet address):
#dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m dhcp-host=00:0A:35:00:01:06,secbus,10.42.0.6,infinite
-
Restart the service:
/etc/init.d/dnsmasq restart
iptables-persistent
allows the iptables
rules to survive across reboot (iptables
is the command-line firewall).
Add the iptables
rules to forward and masquerade the traffic from eth0
to wlan0
:
sudo iptables --table nat --insert POSTROUTING --out-interface wlan0 -s 10.42.0.6 -j MASQUERADE
sudo iptables --table filter --insert FORWARD --in-interface eth0 -s 10.42.0.6 -j ACCEPT
Make this permanent (thanks to iptables-persistent
):
iptables-save | sudo tee /etc/iptables/rules.v4
Tell the kernel to enable the IP forwarding:
sudo sysctl -w net.ipv4.ip_forward=1
Make this permanent by editing /etc/sysctl.conf
and un-commenting the line:
#net.ipv4.ip_forward=1
Use the NetworkManager
to create your wireless network connection. Check the "Automatically connect to this network when it is available" box in the "General" tab. Check that the connection works.
Use the NetworkManager
to create your wired network connection. Un-check the "Automatically connect to this network when it is available" box in the "General" tab to avoid it to be started first and to take precedence over the wireless one. Open the "IPv4 Settings" tab, select the "Manual" method and add the 10.42.0.103
static IP address with 255.255.255.0
netmask. You can leave the "Gateway" field empty.
Connect the ZedBoard to the laptop with an Ethernet cable (crossover cables are not needed because the ZedBoard is gigabit Ethernet capable). The wired network connection should show up on the laptop. Verify that the wireless connection is active and enable the wired network connection. On the ZedBoard check your network interfaces:
ifconfig
If lo
(loopback) is the only listed interface, try to start eth0
manually:
ifup eth0
Then, test your Internet access and DNS service:
ping telecom-paristech.fr