Configure your WiFi
sudo raspi-config
select "2 Network Options Configure network settings"
then select "N2 Wi-fi Enter SSID and passphrase"
enter your access point and password
you are done
Install a lightweight network (DHCP, DNS) infrastructure
sudo apt-get install dnsmasq
Stop the service until we configure if fully
Configure Static WiFi for dhcp client
Type the following statements
interface eth0
static ip_address=192.168.10.1/24
static domain_name_servers=192.168.0.1 8.8.8.8
Restart the dhcp client daemon
sudo service dhcpcd restart
Let us configure the dhcp server
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo vi /etc/dnsmasq.conf
type the following
interface=eth0
dhcp-range=192.168.10.2,192.168.10.20,255.255.255.0,24h
Add a Routing and Masqueraed
- Edit /etc/sysctl.conf and uncomment this line:
- Add a masquerade for outbound traffic on wlan0:
-
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
- Save the iptables rule.
-
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
- Edit /etc/rc.local and add this just above "exit 0" to install these rules on boot.
-
iptables-restore < /etc/iptables.ipv4.nat
Reboot
Your raspberrypi is now ready as a WiFi ==> Ethernet router