Setup
For this, I am using a Ubuntu computer with two ethernet cards.
- eth0 connects to the internet on a DHCP connection
- eth1 connects to a switch which all the other computers on the local network are connected to.
- eth0 has ip 192.168.1.x where x can change
- eth1 set to static ip 192.168.2.1 as it will be the gateway.
- All other computers on the network have ips set manually to 192.168.2.x with gateway set to 192.168.2.1
- In network manager, eth1 connection set to 192.168.1.2 with gateway 192.168.1.x which matches the ip of eth0
Steps
Enter the following commands each time computer starts:
sudo iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE sudo iptables --append FORWARD --in-interface eth1 -j ACCEPT
You will need to allow packet forwarding.
To do this in ubuntu, edit the /etc/sysctl.conf file and uncomment the line shown here (remove the # at the front)
To do this in ubuntu, edit the /etc/sysctl.conf file and uncomment the line shown here (remove the # at the front)
#net.ipv4.ip_forward=1
Run the following command:
echo 1 > /proc/sys/net/ipv4/ip_forward
No comments:
Post a Comment