# How to make bridge br0 start at boot? (SOLVED)

## Akaihiryuu

I have a bridge set up between ethernet (eth0) and wireless (ath0).  Everything works, however I have not been able to find a way to make br0 start at boot.  I added bridge to /etc/modules.autoload.d/kernel-2.6 so that the options I set in sysctl.conf will work.  However, br0 does not show up in "device initiated services" and thus does not start automatically.  The problem is, my LAN IP address is on br0, so if br0 isn't started most of my services (DHCP, named, etc) will not start properly.  Adding br0 to the default runlevel also does not help...it doesn't try to start this way until after most of the other services have attempted to start.  Is there any way to get it to start with the rest of the network interfaces?Last edited by Akaihiryuu on Tue Jul 17, 2007 7:39 pm; edited 1 time in total

----------

## alex.blackbit

i'm not sure, but since it's a network device, you could try to symlink "/etc/init.d/net.lo" to "/etc/init.d/net.br0" and add that to your runlevel.

----------

## Akaihiryuu

I did that, it doesn't work.  It doesn't try to start br0 until long after all of the necessary services (DHCP, etc) try to start and fail due to the interface not being up.

----------

## Akaihiryuu

I found an extremely inelegant workaround...adding net.br0 to the boot runlevel.  This really messes up the way things start, but it does get br0 up before the other services.  This is definitely a huge problem though, because as of right now, the startup scripts don't support bridging...and a server should be able to start up on its own without any intervention.  The whole using hotplug events to start network interfaces is very dumb IMO, things worked much better when you could just stick the interfaces you wanted to start in the default runlevel.

----------

## Cyker

Compile it into the kernel?

----------

## Monkeh

 *Akaihiryuu wrote:*   

> The whole using hotplug events to start network interfaces is very dumb IMO

 

So turn it off.

----------

## Akaihiryuu

How do you disable that?  I'd much rather start my interfaces myself by putting them in default.

----------

## Akaihiryuu

Still no go...I managed to keep Hotplug from bringing interfaces up, but they're still being brought up in the wrong order.  The scripts don't seem to be able to handle a bridge interface...however the bridge *must* be up before any other services like named or dhcp or the server will not be able to start on its own.  I plan on this thing being completely headless, and I want the startup to be fully automatic...even though I very rarely reboot (except to change kernels), sometimes things like power outages cause it.  The problem is, br0 needs to be up for net to be considered up, but eth1 doesn't necessarily.  What would really be great is a modification to the scripts so that instead of strict net checking yes or no, you could put a list of interfaces that are required to be up for net to be considered up.  Dependencies would take care of the rest.

----------

## Monkeh

Look up RC_NEED and RC_USE.

----------

## Akaihiryuu

Ok, those sound like environment variables.  I can't find them in any man pages that I know of though (rc doesn't seem to have a man page, since it's just a script).  Is there anywhere I can find documentation on those?

----------

## Monkeh

 *Akaihiryuu wrote:*   

> Ok, those sound like environment variables.  I can't find them in any man pages that I know of though (rc doesn't seem to have a man page, since it's just a script).  Is there anywhere I can find documentation on those?

 

I.. really can't remember where I read about them. Anyway, iirc, RC_NEED adds a hard dependency for a service, and RC_USE will depend on a service if it's in the current runlevel. I think.

----------

## Cyker

Aha! My search-fu is strong today!  :Very Happy: 

https://forums.gentoo.org/viewtopic-t-540093-highlight-.html

----------

## Akaihiryuu

Damn, no matter what I do nothing works.  I tried making eth1, named, and dhcpd depend on net.br0, all I get is a message saying eth1 starting has been delayed until br0 is up, then it proceeds to not give me any output until a bunch of stuff tries to start and fails because eth1 isn't up.  There has to be a better way to do this...I'm thinking of dropping the entire script system and moving over to initng, it might be the only way to be able to have my server start up on its own without me having to type in several console commands.

Update:  RC_USE, RC_NEED, RC_BEFORE, and RC_AFTER are all completely useless for this situation.  I've found no combination of these that will result in the services starting properly.  All I want it to do is start, ath0, eth0, THEN start br0 before doing anything else.  Instead, no matter what I do (even putting RC_BEFORE_eth1="net.br0"), it starts eth1, then proceeds to start everything else and try to do br0 last.  If I try to make everything depend on br0 being up, it simply gives no output after starting eth1 until everything has tried to start and failed, then proceeds to bring up br0 last (again).  It's apparently that baselayout (at least 1.12.9) has NO support whatsoever for bridges.  I'm probably going to have to do some serious hacking to make this work properly...as of right now, if there's a power outage or something like that that reboots the server, it will not come back up on its own...it is nonfunctional until I type in several commands at the console.

----------

## Cyker

Have you tried building the bridge code into the kernel instead of as a module?

Is your NIC stuff built as modules too or are they part of the kernel?

----------

## Akaihiryuu

This doesn't have anything to do with loading the modules...the modules are being loaded properly.  The problem is starting the actual interface, this won't matter if it's built into the kernel or not.  I do have all my interfaces built as modules.  The problem is not that they aren't being started, it's the order.  I'm thinking about trying to go to one of the unstable versions of baselayout, either 1.13 or 2.0...has anyone used those and do they handle this situation better?  The problem is, Hotplug normally brings the interfaces up, and for some reason it's not seeing br0 as a network interface and thus not seeing it as important to start.

----------

## Monkeh

I use 1.12.9-r2 on my firewall without any problems (involving a bridge, a wired interface, wireless, ppp to the outside world, and a VPN..). I'll paste up some details later.

----------

## Akaihiryuu

Ok...my only real goal here is to get net.br0 t start before the message INIT: entering runlevel 3...without putting net.br0 in /etc/runlevels/boot if possible.

----------

## Monkeh

 *Akaihiryuu wrote:*   

> Ok...my only real goal here is to get net.br0 t start before the message INIT: entering runlevel 3...without putting net.br0 in /etc/runlevels/boot if possible.

 

um.. The only runlevel before that message is boot. When it enters runlevel 3, it starts on default (or whatever other runlevel you've specified).

What, exactly, do you need networking up before that for anyway?

----------

## Akaihiryuu

I want to make sure that my br0 interface is up before *any* services in default start.  They need it up to bind to the correct interface, and "device initiated services" doesn't seem to see net.br0.  If there was a way to make hotplug see it so it would just include the bridge in that list, that would solve my problem.  I tried adding it in RC_PLUG_SERVICES in /etc/conf.d/rc but it just won't work.  I just noticed that I have hotplug in boot...should I have it in default instead?  I also thought about setting STRICT_NET_CHECKING to yes...however, if I did none of my local services (samba, etc) that depend on net would start unless eth1/internet is up, which may not always be the case.  I'm open to suggestions as to how to accomplish this.

EDIT:  I just tried putting RC_USE_eth0="net.br0" in conf.d/net...I don't know if that will work or not, I can't reboot the server right now to test it.  Though instead of rebooting it, could I just do /etc/init.d/hotplug restart to try it?

----------

## Monkeh

Something like this should help..

```
depend_br0() {

   before dhcpd sshd

}
```

I think that works anyway..

----------

## Monkeh

 *Akaihiryuu wrote:*   

> EDIT:  I just tried putting RC_USE_eth0="net.br0" in conf.d/net...I don't know if that will work or not, I can't reboot the server right now to test it.  Though instead of rebooting it, could I just do /etc/init.d/hotplug restart to try it?

 

Assuming eth0 is included in br0.. that's completely, totally, and utterly broken. A bridge requires the included interfaces, not the other way around.

Here..

```
config_ppp0=( "ppp" )

link_ppp0="eth1"

plugins_ppp0=( "pppoe" )

pppd_ppp0=(

   "defaultroute"

)

username_ppp0=""

password_ppp0=""

essid_ath0="foobarwpa"

mode_ath0="master"

channel_ath0="6"

config_ath0=( "172.16.2.1/24" )

bridge_br0="tap0 eth0"

config_eth0=( "null" )

config_br0=( "172.16.0.1/24" )

RC_NEED_br0="net.eth0 openvpn"

depend_br0() {

   before dhcpd

}
```

----------

## Akaihiryuu

Will that setup require me to put net.br0 in boot or default?  Or will the depend cause it to start automatically?

----------

## Monkeh

 *Akaihiryuu wrote:*   

> Will that setup require me to put net.br0 in boot or default?  Or will the depend cause it to start automatically?

 

Place it in default. 99.9% of the time, you do not touch the boot runlevel.

----------

## Akaihiryuu

Should Hotplug be in boot or default?

----------

## Loki:.

Have you tried adding net.br0 to the default run level and putting *Quote:*   

> RC_NET_STRICT_CHECKING="yes"

  in /etc/conf.d/rc ?

----------

## Akaihiryuu

Yes I've thought of that.  The reason I didn't is because a lot of services run on that machine that don't depend on the internet (eth1) being up.  I'd rather eth1 not *have* to be up, only eth0, ath0, and br0.

----------

## Akaihiryuu

Well, I solved it in a very odd way.  I added net.br0 to the boot runlevel, then I *removed* the depend statement in conf.d/net that makes br0 depend on ath0/eth0.  This allows the bridge to start without the two interfaces starting.  At first I was concerned that it might not work if the bridge was brought up first, but it doesn't seem to make any difference, it works fine like that.

----------

