LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-28-2013, 10:13 AM   #1
Piziwate
LQ Newbie
 
Registered: Mar 2013
Posts: 1

Rep: Reputation: Disabled
Thumbs up Policy routing question and problem !?


Dear Linux users,

I've some problem with basic policy routing.
I'm using Ubuntu with kernel 3.2.0.39, but I've the same problem on kernel 2.6.

This is a simplifed example of my problem :

My comupter as an Internet access from eth0. At the boot, there is a default route on my computer to allow routing to WAN.

My computer IP : 10.110.0.104, my router is 10.110.0.1, netmask is 255.255.255.0

First, I ping 8.8.8.8 to test my connection. Everything works :
Code:
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=47 time=17.5 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=47 time=17.4 ms
Now for my test, I remove the default route on my main routing table
Code:
ip route del default
Now I'm unable to ping 8.8.8.8. This is normal... no default route.
For a complicated reason (too long to explain here), I need to use the eth0 by binding it (without default route on this interface)
So I configure policy routing to allow packets going out eth0 to come back :

Code:
ip route add 10.110.0.0/24 dev eth0 src 10.110.0.104 table 1
ip route add default via 10.110.0.1 table 1
ip rule add from 10.110.0.104 table 1
Now I'm trying to ping my 8.8.8.8 by using ping -I eth0 8.8.8.8 but it doesn't work !

How can I reach an IP through eth0 if this interface is not defined as default router in the main routing table ?

You should ask why I'm doing that ? I'm working on a linux box who as two WAN interfaces (eth0 and ppp0). This interfaces are both up and active. My software is sending UDP packets through eth0 (primary way, we bind the interface on the connection) and through ppp0 (bounded to ppp0). This is working well. If we send a packet without specifing the interface, everything goes through the default route (currently eth0). But it eth0 comes down (WAN failure), we continue to send packets through ppp0. That is good, but if we want to, for an example, update date and time with an ntp request, the ntpdate script will use the default interface. To be sure that ntpdate can use ppp0 (because eth0 is down) we update the default route to ppp0. But after that, packets sent through eth0 (bound) doesn't are lost, even if the eth0 works again.

Thank you for your help ! Best regards

Piziwate

Last edited by Piziwate; 03-28-2013 at 10:22 AM.
 
Old 03-30-2013, 08:54 AM   #2
hamlindsza
Member
 
Registered: Aug 2012
Distribution: Debian, CentOS
Posts: 74

Rep: Reputation: Disabled
I'm not an expert in linux routing, but i guess wat ure going here is your removing the default route from the default routing table, so when the packet comes to 10.110.0.1 it doesn't know where to get routed since there is no default route.

I think wat your really looking for is link failover, you can write a simple script which would just change the default route from eth0 to ppp0 & switch it back to eth0 when eth0 comes back.
 
Old 03-30-2013, 10:57 AM   #3
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
To: Piziwate

I think this article will help you: http://lartc.org/howto/lartc.rpdb.html

And, actually, http://lartc.org/howto/ - is very useful sometimes.

Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mutiple IPs and network cards routing (source policy routing?) shogun1234 Linux - Networking 1 01-17-2013 12:09 AM
policy routing mail2mphani Linux - Newbie 1 04-16-2009 12:48 AM
policy rule routing problem - help me pandanvn Linux - Networking 3 04-02-2007 06:24 PM
policy rule routing problem - help me pandanvn Linux - Networking 0 03-16-2007 12:03 AM
help with policy based routing GaijinPunch Linux - Networking 4 06-19-2005 06:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration