Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a problem with ip route add. Surprisingly, I can add the route then change it, but I cannot directly add it:

# ip route add 192.168.0.0/16 via 192.168.255.254 src 192.168.1.101
RTNETLINK answers: No such process

but:

# ip route add 192.168.0.0/16 dev eth0
# ip route change 192.168.0.0/16 via 192.168.255.254 src 192.168.1.101

My interfaces file is:

iface lo inet loopback
auto eth0
iface eth0 inet static
    address 178.xxx.xxx.xxx
    netmask 255.255.255.192
    network 178.xxx.xxx.xxx
    broadcast 178.xxx.xxx.xxx
    gateway 178.xxx.xxx.xxx
auto eth0:1
iface eth0:1 inet static
    address 192.168.1.101
    netmask 255.255.0.0

I am a bit lost I must say. I am fine with adding then changing but it is not satisfying to not understand why it works in two steps and not directly. I have been reading man pages after man pages without understanding.

Updated with the help of the answers:

I have now a gateway on eth0 and eth0:0, but as I want all my traffic except the 192.168.0.0/16 to be marked as coming from my 178.xxx.xxx.xxx address, I added a routing rule. Maybe having eth0 with the 192.168.1.101 ip and then the 178.xxx.xxx.xxx ip on eth0:0 would work without routing rule, but here it goes:

auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
    address 178.xxx.xxx.131
    netmask 255.255.255.192
    network 178.xxx.xxx.128
    broadcast 178.xxx.xxx.191
    gateway 178.xxx.xxx.190
    up /sbin/ip route add default via 178.xxx.xxx.190 dev eth0 table 125
    up /sbin/ip rule add from 178.xxx.xxx.128/26 table 125
    post-down /sbin/ip route del default via 178.xxx.xxx.190 dev eth0 table 125
    post-down /sbin/ip rule del from 178.xxx.xxx.128/26 table 125

auto eth0:0
iface eth0:0 inet static
    address 192.168.1.101
    netmask 255.255.0.0
    gateway 192.168.255.254

I have also disabled rp_filter:

echo 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter

Thanks for your help!

share|improve this question

3 Answers 3

up vote 2 down vote accepted

According to your interfaces file you are already in the network 192.168.0.0/16, so you should not need a gateway to this network.

share|improve this answer
    
Yes, so, it looks like I had to put the gateway and add some routing stuff to get my source ip right. –  Loïc d'Anterroches Mar 28 '11 at 18:58
    
ip route add 192.168.0.0/16 dev eth0:0 via 192.168.1.254 src 192.168.1.101 –  rjt Jul 17 '12 at 17:02

If I adjust my results for your IP setup (I'm on a 192.168.x.0/24):

$ sudo ip route add 192.168.0.0/16 via 192.168.255.254 src 192.168.1.101

I get

RTNETLINK answers: No such process

But

$ sudo ip route add 192.168.0.0/16 via 192.168.1.254 src 192.168.1.101

works. I suspect it's because 192.168.255.254 is not on your local subnet or a known route, so you need a route to it first.

share|improve this answer
    
192.168.255.254 is on the 192.168.0.0/16 local subnet. –  Cheekaleak Mar 28 '11 at 12:32

As others have stated your IP on eth0:1 of 192.168.1.101/16 will mean that you already have a static route for that subnet. It looks like you need to add a gateway for that interface pointing to 192.168.255.254.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.