Subject: How to ensure that host gets the primary ip address?
From: Thomas Gebhardt <gebhardt@hrz.uni-marburg.de>
Date: Wed, 30 Jun 2010 09:35:39 +0200

Hello,

somehow I got into the situation that the ip address of the Host is
secondary and a VServer gets the primary address:

# ip addr ls
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
->  inet <vserver1-ip>/24 brd <brdcast-ip> scope global eth0
    inet <vserver2-ip>24  brd <brdcast-ip> scope global secondary eth0
->  inet <host-ip>/24     brd <brdcast-ip> scope global secondary eth0
    inet <vserver3-ip>/24 brd <brdcast-ip> scope global secondary eth0
    ...
...
4: vlan71@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue
state UP
    link/ether 00:04:23:d6:b4:a8 brd ff:ff:ff:ff:ff:ff
    inet <vserver6-ip>/25 brd <brdcast2-ip> scope global vlan71
...

* I have the sysctl setting "net.ipv4.conf.all.promote_secondaries=1",
so the host will not get offline when I shutdown vserver1.
* The hostname of the host resolves to host-ip.

Nethertheless, ssh connections from the host get vserver1-ip as its src
address, obviously because vserver1-ip is the primary ip address of the
eth0 interface. I can fix this by the BindAddress directive in
ssh_config, but this is just a workaroud for ssh and I don't know
whether other services will be affected, too. A much cleaner solution
would be to "pin" the primary role to the host ip.

Any idea how to achieve that and/or how to swap the primary and
secondary role of the ip adresses in my current situation?

Thanks, Thomas