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 via src
RTNETLINK answers: No such process


# ip route add dev eth0
# ip route change via src

My interfaces file is:

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

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 to be marked as coming from my 178.xxx.xxx.xxx address, I added a routing rule. Maybe having eth0 with the 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
    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

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, 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 dev eth0:0 via src –  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 via src

I get

RTNETLINK answers: No such process


$ sudo ip route add via src

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

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

As others have stated your IP on eth0:1 of 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

share|improve this answer

Your Answer


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.