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

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

ifconfig eth0:0 10.100.0.5/24 broadcast 10.100.0.255

real ip of the interface is 10.100.0.3. When I ping another host my source ip is 10.100.0.3 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

1 Answer 1

up vote 1 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
10.100.0.0/24 dev eth0  proto kernel  scope link  src 10.100.0.3/24  metric 1 
default via 10.100.0.1 dev eth0  proto static 

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

ip route change 10.100.0.0/24 dev eth0 proto kernel scope link src 10.100.0.5/24 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

 
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.