I have to make my ubuntu PC as router, because I am not allowed to connect any router to University network.
I have a PC (ubuntu 16.04) with two NIC cards. eth0 is connected to university network (public) and eth1 is connected to WLAN router.
eth0 : 131.173.115.18
eth1 : 192.168.1.62
Router WAN: 192.168.1.65
I want all traffic to via eth0 to internet. I have enabled IP forwarding
net.ipv4.ip_forward=1
and also NAT service on eth0
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
I don't know why I am having so many routes. And cannot ping eth1 from eth0 or in reverse. What am I missing?
epc@nano:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 131.173.119.254 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 131.173.119.254 0.0.0.0 UG 100 0 0 eth0
0.0.0.0 131.173.115.18 0.0.0.0 UG 101 0 0 eth1
131.173.112.0 0.0.0.0 255.255.248.0 U 100 0 0 eth0
131.173.115.18 0.0.0.0 255.255.255.255 UH 100 0 0 eth1
131.173.245.1 131.173.119.254 255.255.255.255 UGH 100 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 eth1