1

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
Sarmad
  • 11
  • 2
  • This [question](https://unix.stackexchange.com/questions/386490/how-do-i-forward-multicast-traffic-between-2-differant-lans-using-iptables) may help. – jc__ Jul 30 '18 at 14:07
  • Too much default gateway, too many subnets. – Ipor Sircer Jul 30 '18 at 14:08
  • @IporSircer yes this is what I am confused. Where am I getting this? I have only eth0 entry in /etc/network/interfaces file for dhcp, where eth1 is configured through GUI. – Sarmad Jul 30 '18 at 14:15

1 Answers1

0

By default Linux doesn't allow you to do this, you need to change rp filter echo 2 > /proc/sys/net/ipv4/conf/all/rp_filter

https://www.slashroot.in/linux-kernel-rpfilter-settings-reverse-path-filtering

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 18 '23 at 19:15
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/437345) – Peregrino69 Feb 19 '23 at 00:35