How to setup IP alias on bridged interface in Ubuntu

Posted by Anonymouslemming on Server Fault See other posts from Server Fault or by Anonymouslemming
Published on 2013-10-24T11:38:33Z Indexed on 2013/10/24 15:57 UTC
Read the original article Hit count: 188

Filed under:
|
|
|

How do I setup an IP alias on a bridge (br0) device on Ubuntu ?

If I wait for br0 to come up and then do

/sbin/ifconfig br0:0 192.168.10.1 netmask 255.255.255.0 

then it works fine.

If however I add the following to my /etc/network/interfaces file, it does not work and the network fails to start:

auto br0:0
iface br0:0 inet static
   address 192.168.10.1
   netmask 255.255.255.0 

At the moment, I have a script in /etc/network/if-up.d/bridge_alias that does this as follows:

#!/bin/bash

if [ "${LOGICAL}" == "br0" ] && [ "${PHASE}" = "post-up" ]; then
        echo -n "Starting br0:0 ... "
        /sbin/ifconfig br0:0 192.168.10.2 netmask 255.255.255.0
        echo "Done!"
fi

What is the right way of doing this though, just using the OS network config files ?

© Server Fault or respective owner

Related posts about linux

Related posts about ubuntu