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 have a VPS that has 2 IP addresses on virtual interfaces. Here is the config:

root@vps [~]# ifconfig -a
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:571976 errors:0 dropped:0 overruns:0 frame:0
          TX packets:571976 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:172900062 (164.8 MiB)  TX bytes:172900062 (164.8 MiB)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:407339 errors:0 dropped:0 overruns:0 frame:0
          TX packets:404999 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:170561404 (162.6 MiB)  TX bytes:96416084 (91.9 MiB)

venet0:0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:1.2.3.1  P-t-P:1.2.3.1  Bcast:1.2.3.1       Mask:255.255.255.255
      UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1

venet0:1  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
      inet addr:1.2.3.2  P-t-P:1.2.3.2  Bcast:1.2.3.2  Mask:255.255.255.255
      UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1

Right now I have a website setup using (WHM/Cpanel) on the 1.2.3.2 address. The problem is whenever I initiate a connection from the web server (PHP curl script for example) it is always sourced from the 1.2.3.1 address. I have called and talked to the support for my VPS and they say this is impossible and I need to move the site to the other address. For reasons that are not important here I would like to avoid doing that. Is there any way to get the venet0:1 interface to be the default interface for outgoing connections?

EDIT:

Here is the routing table:

root@vps [~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
191.255.255.0   0.0.0.0         255.255.255.0   U     0      0        0 venet0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 venet0
0.0.0.0         191.255.255.1   0.0.0.0         UG    0      0        0 venet0
share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You may want to check out This question from last week. I think it's exactly what you're looking for.

Long story short, Linux doesn't handle multiple IPs on the same subnet well. But the tools in ipconfig2 help out a bunch. So using them instead of the more commonly known ifconfig/route commands is what you need.


--Christopher Karel

share|improve this answer
    
Thank you, I tried searching here before posting but didn't find that one. It worked perfectly. Thanks! –  Ezra Sep 20 '10 at 23:50
add comment

try:

route del -net 0.0.0.0
route add default gw xxx.xxx.xxx.xxx dev vmnet0:1

...where xxx.xxx.xxx.xxx is your normal default gateway from route -n. Do this at a console as you'll lose network routing, and be prepared to put it back if it doesn't work to whatever route -n normally says.

share|improve this answer
    
What is odd though is that if you look at the routing table (just added it to my post) it is referring to an IP subnet that is not on either of the other two interfaces. The 2 interfaces have public IP addresses and this is clearly an internal one. –  Ezra Sep 20 '10 at 23:07
    
that's a zeroconf network, just disable it - add NOZEROCONF=yes to /etc/sysconfig/network and delete that 169.254 route by hand (or restart networking) –  troyengel Sep 21 '10 at 11:46
add comment

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.