2

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 ?

2 Answers 2

4

The only way you can do that is from ifconfig (or maybe ip addr add, but i haven't checked it against bridges). if-up.d is okay, but i recommend you use post-up in interfaces, like:

auto br0:0  
  iface br0:0 inet static  
  address 192.168.10.1  
  netmask 255.255.255.0  
  post-up /sbin/ifconfig br0:0 192.168.10.2 netmask 255.255.255.0

You can repeat post-up as much times as you want.

1
  • Thanks - didn't realise I could do that in a post-up command Oct 24, 2013 at 15:39
2

Here is something I'm using, works in Debian 8 and Ubuntu 16.03:

auto lo
iface lo inet loopback

auto br1 
iface br1 inet static
    bridge_ports eth1 
    address  172.17.17.1
    netmask  255.255.255.0
    network  172.17.17.0
    broadcast 172.17.17.255
    post-up /usr/sbin/dhcpd 

auto br1:1 
iface br1:1 inet static
    address 172.17.17.2
    netmask  255.255.255.0
    network  172.17.17.0
    broadcast 172.17.17.255

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.