LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   IPTables/Route and multiple interfaces configuration (https://www.linuxquestions.org/questions/linux-networking-3/iptables-route-and-multiple-interfaces-configuration-4175418982/)

TCB13 07-27-2012 01:53 PM

IPTables/Route and multiple interfaces configuration
 
Hello!
I'm not a linux expert but I've this scenario, a Debian box running with multiple network cards:

1. eth0 - Internet Connection via local Router (172.20.1.x , 255.255.255.0)
2. ppp0 - Dial-up to a network without internet (10.x.x.x , 255.255.255.255)

My goal is to be able to surf the web on this machine and allow SSH and other services to be accessible from the two networks.
Right now, I'm able to reach the router on eth0 (172.20.1.1), but I can't get to google or anywhere else on the internet as you can see bellow... (And no, it's not a DNS issue. I tried the IP)

Quote:

root@iklive-shv1:~# ping 172.20.1.1
PING 172.20.1.1 (172.20.1.1) 56(84) bytes of data.
64 bytes from 172.20.1.1: icmp_req=1 ttl=64 time=0.416 ms
64 bytes from 172.20.1.1: icmp_req=2 ttl=64 time=0.428 ms
^C
--- 172.20.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.416/0.422/0.428/0.006 ms
root@iklive-shv1:~# ping google.com
PING google.com (173.194.34.197) 56(84) bytes of data.
^C
--- google.com ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3003ms

root@iklive-shv1:~# ping 173.194.34.197
PING 173.194.34.197 (173.194.34.197) 56(84) bytes of data.
^C
--- 173.194.34.197 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2004ms
My current routing table is:

Quote:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.64.64.64 0.0.0.0 UG 0 0 0 ppp0
10.64.64.64 * 255.255.255.255 UH 0 0 0 ppp0
172.20.1.0 * 255.255.255.0 U 0 0 0 eth0
172.50.1.0 172.50.1.2 255.255.255.0 UG 0 0 0 tun0
172.50.1.2 * 255.255.255.255 UH 0 0 0 tun0
I also tried to change the default gateway to the router IP (172.20.1.1) using:

Quote:

route add default gw 172.20.1.1 eth0
I can access the internet but then clients can't connect or ping my machine over the dial-up connection (ppp0).
How can I do it? I tried some custom ip route routes but I wasn't able to get it work. :(

Thank you!

TCB13 07-27-2012 09:03 PM

After a long search e come across a solution but I'm not sure about some parameters...

Supposing that eth0 has the IP 172.20.1.7 and ppp0 has 10.184.225.42.

Quote:

echo 200 localnet >> /etc/iproute2/rt_tables
echo 201 dialup >> /etc/iproute2/rt_tables

ip route add <NET1> dev eth0 src <SRC1> table localnet
ip route add <NET2> dev ppp0 src <SRC2> table dialup

ip route add default via 172.20.1.7 table localnet
ip route add default via 10.184.225.42 table dialup

ip rule add from 172.20.1.7 table localnet
ip rule add from 10.184.225.42 table dialup
What shout be <NET*> and <SRC*> are the other parameters configured the right way?
I took that from http://unix.stackexchange.com/questi...s-two-gateways.

Thanks.

TCB13 07-28-2012 10:27 AM

So... I managed to solve this issue by:

Quote:

route add default gw 172.20.1.1 eth0
route add -net 10.0.0.0 netmask 255.0.0.0 ppp0
This sets my default gateway on eth0 and it's router and adds a new route for the 10.x.x.x network.

This way I'm able to reach the internet and still be accessible over the ppp0 dial-up.


All times are GMT -5. The time now is 08:45 PM.