# Question about network bridging in LXC

## sam_i_am

Hi,

I'm trying to set up a network bridge for a guest in LXC and was following the Gentoo wiki for LXC. At one point it says:

 *Quote:*   

> 6. brctl addif br0 eth0 # <-- this line seems to destroy networking if eth0 is a preconfigured primary outbound interface ... bad!

 

I don't really understand what "a preconfigured primary outbound interface" means and don't want to risk losing the ethernet connection to my machine as it is a headless machine that I access remotely. Can anyone shed a bit of light on this? 

Thanks for any explanations

----------

## Bones McCracker

I have this in /etc/conf.d/network (which is where the network setup stuff should actually go when using openrc; the /etc/conf.d/net stuff and associated scripts are just there for backward compatibility.  Apparently the lxc wiki only shows the /etc/conf.d/net way.  But if you're using that, you can probably examine what I've done below and adapt it).

```
## create a bridge pseudo-interface to which LXCs may connect veth pseudo interfaces.

## (IP is configured on the br0 pseudo-interface itself later by dhcp client.

interfaces="br0"

ifup_br0="brctl addbr \$int; brctl setfd \$int 0; brctl addif \$int eth0; ifconfig eth0 0.0.0.0 up"

ifdown_br0="ifconfig \$int down; brctl delbr \$int"
```

Then, for the network portion of my lxc config file (this is a per-container config file), I have:

```
# network configuration

lxc.network.type = veth

lxc.network.flags = up

lxc.network.link = br0

lxc.network.hwaddr = b6:67:82:92:ca:a0

lxc.network.ipv4 = 0.0.0.0
```

I think you want to comment out lxc.network.hwaddr at first.  LXC will generate a random MAC address for the virtual interface, which you can find out once it's running.  If you are using DHCP to assign an IP address to the container, as I am, then you probably want to hard-code that MAC address into your config file as I have above.  If you're not, then you can probably just delete that line and manually assign the address on lxc.network.ipv instead of using "0.0.0.0".

----------

