Linux routing lab

From k-space wiki
Jump to: navigation, search


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 as the IP address, netmask, as the gateway. Verify that you can ping and Configure bridge over remaining network interfaces as LAN interface, use 10.107-126.0.1 as the IP address, netmask

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

auto br-lan
iface br-lan inet static
	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

Configure /etc/dnsmasq.conf:

  • 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.