Wlan0: sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE We also need to share RPi’s internet connection with the devicesĬonnected over Wi-Fi. sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward' But if you want to try it right now without reboot then do _forward=1 This will enable packet forwarding on next Remove the # from the beginning of the line containing # Assign IP addresses between 192.168.2.2 and 192.168.2.100 with aĮdit the /etc/nf file to enable packet forwarding sudo nano /etc/nf # Never forward addresses in the non-routed address spaces. Server=8.8.8.8 # Forward DNS requests to Google DNSĭomain-needed # Don't forward short names # Bind to the interface to make sure we aren't sending things Paste the following into the new file interface=eth0 # Use interface eth0 The shipped dnsmasq config fileĬontains a lot of information on how to use it. Open the interfaces file sudo nano /etc/network/interfacesĮdit the eth0 section like this: allow-hotplug eth0 We will assign a static IP address toĮth0 which will be used as gateway. Isc-dhcp-server and bind9 packages for DHCP and DNS respectively,īut for our purposes, dnsmasq works just fine. If you want something a little more 'heavyweight', you can use the We will use dnsmasq package for this purpose because it is combinedĭHCP and DNS server and also easy to configure.