Linux routing lab
In this lab we see how any Linux distribution can be used as a router.
For this lab you need:
- PC with 4 or more network interfaces and 64GB+ SSD
- Memory stick to install Debian
Set up Debian as router
Start off by configuring eth0 as WAN interface, use available IP address from range 220.127.116.11-126 as the IP address, netmask 255.255.255.192, 18.104.22.168 as the gateway. Verify that you can ping 22.214.171.124 and google.com. Configure bridge over remaining network interfaces as LAN interface, use 10.107-126.0.1 as the IP address, netmask 255.255.0.0.
You need to install couple essential packages for networking basics:
apt install vlan bridge-utils
Your /etc/network/interfaces should eventually look something like this:
source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 126.96.36.199 netmask 255.255.255.192 gateway 188.8.131.52 dns-nameservers 184.108.40.206 auto br-lan iface br-lan inet static address 10.107.0.1 netmask 255.255.0.0 bridge_ports eth1 eth2 eth3 eth4 eth5 eth6 eth7
Configure static IP address on your laptop from the same subnet and verify that you can access the machine via LAN network interface.
Enable packet forwarding and add iptables rules for masquerading traffic on the outgoing interface:
# This will permanently enable packet forwarding echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf sysctl -p
Configure DHCP and DNS
Easy way to get started is to use dnsmasq which by default serves as DHCP server and DNS cache.
apt install dnsmasq
- Install dnsmasq to serve DHCP and DNS caching on the LAN segment. Revert your laptop back to DHCP and verify it works.
Add wireless network interface
Install hostapd to configure wireless network interface as an access point.