Debian router config

From The World according to Vissie
Jump to navigation Jump to search

Edit your /etc/network/interfaces:

 auto lo
 iface lo inet loopback

 # The primary network interface
 allow-hotplug eth0
 iface eth0 inet static
    address 192.168.0.10
    netmask 255.255.255.0
    gateway 192.168.0.1

 # The secondary network interface
 allow-hotplug eth1
    iface eth1 inet static
    address 10.10.0.10
    netmask 255.255.255.0
https://www.systutorials.com/setting-up-gateway-using-iptables-and-route-on-linux/
ip route add 10.10.0.0/16 dev eth1
sysctl -w net.ipv4.ip_forward=1

You can also make the setting permanent in `/etc/sysctl.conf by adding a line below to /etc/sysctl.conf:

net.ipv4.ip_forward = 1
sudo iptables -t nat -A POSTROUTING ! -d 10.10.0.0/16 -o eth0 -j SNAT --to-source 192.168.0.10

We ended up using these rules:

/home/user/my_script.sh

sudo echo 1 > /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o ppp0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i ppp0 -o eth0 -j ACCEPT