[CentOS] advanced routing, 2isp

David Hláčik david at hlacik.eu
Wed Dec 23 08:10:54 UTC 2009


Guys,

please I have no luck with this. I have 2 ISPS. I have working
configuration with ip route a 2 routing tables in a way, that matching
local subnet uses second provider while all the others are using the
first one - main.

The main problem I am having is, that I am unable to reach my router
via public ip address of that second ISP.

This is my default routing table

[root at sx1 cron.hourly]# ip route show table main
194.228.196.39 dev ppp0  proto kernel  scope link  src 90.178.76.117
10.123.50.101 dev ppp2  proto kernel  scope link  src 10.123.50.1
10.123.50.100 dev ppp1  proto kernel  scope link  src 10.123.50.1
213.194.242.0/24 dev eth1  proto kernel  scope link  src 213.194.242.198
10.123.20.0/24 dev eth0  proto kernel  scope link  src 10.123.20.1
10.123.10.0/24 dev eth0  proto kernel  scope link  src 10.123.10.11
10.123.11.0/24 dev eth0.8  proto kernel  scope link  src 10.123.11.1
10.123.42.0/24 dev eth0.5  proto kernel  scope link  src 10.123.42.1
10.123.123.0/24 dev eth0.7  proto kernel  scope link  src 10.123.123.1
10.123.40.0/24 dev eth0.4  proto kernel  scope link  src 10.123.40.1
10.123.30.0/24 dev eth0  proto kernel  scope link  src 10.123.30.1
10.123.44.0/24 dev eth0.6  proto kernel  scope link  src 10.123.44.1
169.254.0.0/16 dev eth0.8  scope link
default via 213.194.242.1 dev eth1

As you can see , my default provider has gateway 213.192.252.1 ,
connected via eth1 . This works fine for me.

Second configuration is ip rule based, when subnet 10.123.123.0/24
goes to routing table adsl

[root at sx1 cron.hourly]# ip rule show
0: from all lookup 255
32764: from all fwmark 0x1 lookup adsl-vpn
32765: from 10.123.123.0/24 lookup adsl
32766: from all lookup main
32767: from all lookup default

[root at sx1 cron.hourly]# ip route show table adsl
194.228.196.39 dev ppp0  scope link  src 90.178.76.117
10.123.123.0/24 dev eth0.7  scope link  src 10.123.123.1
default via 194.228.196.39 dev ppp0

As you can see in this case, all trafic goes via ppp0 (my second
internet provider connected via ppp0 - adsl ppoe).

This works fine.

What I want to achieve is, now being able to ping /access/whatever to
my server via second public IP address of my adsl provider
(90.178.76.117).
To achieve this i have added iptables rule, which marks all packets
comming via ppp0 (iptables -t mangle -A PREROUTING -i ppp0 -j MARK
--set-mark 0x1).

And created another routing table named adsl-vpn

[root at sx1 cron.hourly]# ip route show table adsl-vpn
194.228.196.39 dev ppp0  scope link  src 90.178.76.117
10.123.10.0/24 dev eth0  scope link  src 10.123.10.11
default via 194.228.196.39 dev ppp0

Now i have added ip rule, which for all packets marked as 1 , which
are the ones which came trough ppp0 = my second ISP, uses table
adsl-vpn

[root at sx1 cron.hourly]# ip rule show
0: from all lookup 255
32764: from all fwmark 0x1 lookup adsl-vpn  <--- this one
32765: from 10.123.123.0/24 lookup adsl
32766: from all lookup main
32767: from all lookup default

Well, now I should be able definitely to ping my server from outside,
but it does not works

Pinging from windows machine in outside world :

C:\Users\boss>ping 90.178.76.117
Pinging 90.178.76.117 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 90.178.76.117:
Packets: Sent = 3, Received = 0, Lost = 3 (100% loss),

If i will tcpdump my ppp0 interface on my router I see the ICMP echo
requests are comming

[root at sx1 cron.hourly]# tcpdump -i ppp0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ppp0, link-type LINUX_SLL (Linux cooked), capture size 96 bytes
09:08:27.743789 IP adsl-dyn118.78-98-105.t-com.sk >
gw2.cz.polarion.com: ICMP echo request, id 1, seq 72, length 40

But, echo responses  from my server NOT, instead of that, responses
are comming out of eth1 interface , which is my first ISP!

[root at sx1 cron.hourly]# tcpdump -i eth1 |grep ICMP
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
09:09:30.451706 IP gw2.cz.polarion.com >
adsl-dyn118.78-98-105.t-com.sk: ICMP echo reply, id 1, seq 73, length
40
09:09:35.409704 IP gw2.cz.polarion.com >
adsl-dyn118.78-98-105.t-com.sk: ICMP echo reply, id 1, seq 74, length
40

This means that either mange is not working or ip rule is not working .

Please help,
David


More information about the CentOS mailing list