Port forwarding not working for certain LAN IP

I hope someone can shed some light on this. My knowledge of networking is basic at best.

I have a CentOS server on two networks:

  • NIC1 is on a public IP with gateway set sitting on Switch 1. (ADSL Internet)
  • NIC2 is set to 10.10.10.2 with no gateway set sitting on Switch 2. (Cable Internet)
  • Switch 2’s gateway/router is 10.10.10.1. (ASUS router)

Within the LAN, other LAN pc’s are able to access 10.10.10.2 on open ports. When a port forward rule is set from gateway/router 10.10.10.1 –> 10.10.10.2, this isn’t working. Port forwarding on gateway/router 10.10.10.1 –> to 10.10.10.3 works (Windows machine with gateway set to 10.10.10.1).

Is it possible to reach 10.10.10.2 from the public internet through the ASUS router 10.10.10.1?

Answer

IP policy routing.

I found two write-ups of the same that I used to update my CentOS server to enable the 2nd NIC to receive and send packets. Also was successful in updating another similar server with a dual NICs/gateways.

http://jensd.be/468/linux/two-network-cards-rp_filter <– I went with setting up IP policies under the ‘best solution’ section and did not change the rp_filter value. This write-up also has nice diagrams.

http://www.microhowto.info/howto/ensure_symmetric_routing_on_a_server_with_multiple_default_gateways.html <–additional example of the above which made it clearer for me.

If you want the changes permanent, then follow the instructions on the first link above.

My example:

  • ip route add 99.88.77.66/24 dev eth0 table 1 (example Public IP #1)
  • ip route add default via 99.88.77.1 table 1 (example Public IP #1’s gateway)
  • ip route add 10.10.10.0/24 dev eth1 table 2 (second NIC on different network)
  • ip route add default via 10.10.10.1 table 2 (ASUS router gateway)
  • ip rule add from 99.88.77.66/32 table 1 priority 100
  • ip rule add from 10.10.10.4/32 table 2 priority 110
  • ip route flush cache

The /24 for you may change depending on subnet mask of your IP’s.

Attribution
Source : Link , Question Author : stile , Answer Author : stile

Leave a Comment