Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created virtual ip on interface with the following command in centos.

ifconfig eth0:0 broadcast

real ip of the interface is When I ping another host my source ip is which is not something I want. I want virtual IP to appear as source.

I tried to add default gateway interface eth0:0 but in route -n still shows me eth0 as default gateway interface.

Any help is appreciated.

share|improve this question
up vote 2 down vote accepted

I was able to fix this using the 'ip' tool from the iproute-package.

Using ip route I can see which address is used as the source:

root@testbox:~# ip route dev eth0  proto kernel  scope link  src  metric 1 
default via dev eth0  proto static 

And by copying and editing the line from above, I can change it:

ip route change dev eth0 proto kernel scope link src metric 1

route -n will still show eth0 as it doesn't see virtual interfaces.

share|improve this answer
mark as correct answer! – 3molo May 13 '11 at 13:13
Thanks, i adapted your command to mine, it worked. – ubuntus May 16 '11 at 2:35

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.