We are going to turn the Raspberry Pi into a Router for our devices, pick your need:
Instead of reinventing the wheel, we follow the guide Sixfab tutorial
If you are using Raspberry Pi 2 or earlier, you will need a USB WiFi adaptor.
Not a must but you may want to do this, in case later you changed your mind.
$ sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.backup.conf
Clear the configuration file
$ sudo cp /dev/null /etc/wpa_supplicant/wpa_supplicant.conf
Add configurations into
Use a quick installer of RaspAP and follow the questions to setup the wireless network
$ wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap -y
We are going to use network address translation (NAT) to bridge
This tutorial was adopting sharing wifi through the ethernet and change it to share PPP connection to ethernet
dnsmasq for DHCP + DNS.
$ sudo apt-get install dnsmasq
eth0 section in file
/etc/sysctl.conf to enable packet forwarding.
$ sudo nano /etc/sysctl.conf
Find the line
#net.ipv4.ip_forwarding=1 and remove the
# at the beginning to make it
net.ipv4.ip_forwarding=1. This will enable packet forwarding once the system reboot.
Backup dnsmasq configuration
$ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
interface=eth0 # Use interface eth0
bind-interfacescause me unable to share the internet. You may need to test it.
$ sudo iptables -t nat -A POSTROUTING -o wwan0 -j MASQUERADE
Make the rules persistent.
$ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
# Add this line above exit 0
Connect my laptop to Raspberry Pi
$ ping 18.104.22.168