# Why is eth0 in my routing table as well as bridge br0?

## Fog_Watch

I would like to bridge eth0 and wlan0.  /etc/conf.d/net is as follows:

```
modules_wlan0="!wpa_supplicant" 

config_wlan0="null"

config_eth0="null"

bridge_br0="eth0"

config_br0="dhcp"

brctl_br0="setfd 0

   sethello 10

   stp off"
```

This is works OK, however I can't ping out of my machine.

The routing table is as follows:

```
Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

default         192.168.1.1     0.0.0.0         UG    204    0        0 br0

loopback        localhost       255.0.0.0       UG    0      0        0 lo

192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

192.168.1.0     *               255.255.255.0   U     204    0        0 br0

```

That is, destination "192.168.1.0" is listed twice, once under eth0 and

once under br0.  I don't know why eth0 should be there, and when

removed routing works fine, both into and from the box.  When the

machine is booting and net.br0 starts under runlevel default, how do I prevent

the eth0 route from being created?

Regards

Fog_Watch.

(Don't worry about the absence of wlan0, I know how to fix that)

----------

## Logicien

Do you have net.eth0 in /etc/init.d? What is the output of

```
brctl show
```

after boot is finish?

----------

## Fog_Watch

 *Logicien wrote:*   

> Do you have net.eth0 in /etc/init.d? What is the output of
> 
> ```
> brctl show
> ```
> ...

 

```
# ls -la /etc/init.d/net*      

lrwxrwxrwx 1 root root     6 Feb 11 19:08 /etc/init.d/net.br0 -> net.lo

lrwxrwxrwx 1 root root     6 Feb 11 19:08 /etc/init.d/net.eth0 -> net.lo

-rwxr-xr-x 1 root root 16919 Feb  1 23:06 /etc/init.d/net.lo

lrwxrwxrwx 1 root root     6 Feb 11 19:08 /etc/init.d/net.wlan0 -> net.lo

-rwxr-xr-x 1 root root  1578 Feb  1 23:06 /etc/init.d/netmount

```

With or without net.eth0 in /etc/init.d the confounding eth0 route still appears.  However, hostapd needs both net.eth0 and net.br0 in /etc/init.d.

```

# brctl show

bridge name   bridge id      STP enabled   interfaces

br0      8000.001676d0bfe6   no      eth0
```

----------

## cwr

Have you set up hostapd.conf to tell hostapd that it's using a bridge?

Will

----------

## Logicien

If you want wlan0 to be in the same bridge than eth0, you have to add it in the bridge br0. Both are dependancies of br0 and have to be started by net.br0. They should not be started independently.

----------

## Fog_Watch

I don't believe that wlan0 or hostapd to be the problem:

I can plop wlan0 into my bridge easy peasy:

```
# brctl show

bridge name   bridge id      STP enabled   interfaces

br0      8000.001676d0bfe6   no      eth0

                     wlan0
```

Having started hostapd I can then use the wifi access point.

My problem is the routing table that is established by booting.  The following is what is currently booted:

```
# rc-update show | grep net

              net.br0 |      default                 

               net.lo | boot                         

             netmount |      default
```

```
# ls -la /etc/init.d/net*

lrwxrwxrwx 1 root root     6 Feb 13 19:19 /etc/init.d/net.br0 -> net.lo

-rwxr-xr-x 1 root root 16919 Feb  1 23:06 /etc/init.d/net.lo

-rwxr-xr-x 1 root root  1578 Feb  1 23:06 /etc/init.d/netmount

```

```
# egrep -v '^#|^$' /etc/conf.d/net

modules_wlan0="!wpa_supplicant" 

config_wlan0="null"

brctl_br0="setfd 0

   sethello 10

   stp off"

config_eth0="null"

bridge_br0="eth0"

config_br0="dhcp"

```

And the following is the infernal routing table that boot comes up with, unless I route del eth0.  

```
route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

default         192.168.1.1     0.0.0.0         UG    4      0        0 br0

loopback        localhost       255.0.0.0       UG    0      0        0 lo

192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

192.168.1.0     *               255.255.255.0   U     4      0        0 br0

```

Ah.

Why is eth0 in my routing table as well as bridge br0?

Moreover, thank you Paul and Will.

----------

## Aiken

I am using a bridge consisting of eth0 + eth1 +  wlan0 with hostapd and not seeing either of the eth devices in the routing table.

```

config_eth0="null"

config_eth1="null"

bridge_br0="eth0 eth1"

config_br0="172.16.31.1/24"

routes_br0="default via 172.16.31.254"

depend_br0() {

   need net.eth0 net.eth1

}

```

```

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         172.16.31.254   0.0.0.0         UG    6      0        0 br0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

172.16.31.0     0.0.0.0         255.255.255.0   U     0      0        0 br0

```

```

              net.br0 |      default                 

             net.eth0 |      default                 

             net.eth1 |      default                 

               net.lo | boot

```

One difference I am seeing is I have net.eth0 and net.eth1 in default where you do not have your net.eth0 in default. Don't see what that should make a difference as the eth device(s) should be started anyway as dependencies of br0. The other difference is I am using static and you are using dhcp. At the moment I am wondering if you have something else adding a route via eth0. Could that something else be the dhcp client?

 *Logicien wrote:*   

> If you want wlan0 to be in the same bridge than eth0, you have to add it in the bridge br0. Both are dependancies of 
> 
> br0 and have to be started by net.br0. They should not be started independently.

 

Hostapd adds wlan0 to the bridge as needed. Wlan0 does not need to be part of the original bridge definition. The bridge can be started independently of wlan0. In this situation hostapd needs the bridge started 1st.

----------

## Fog_Watch

 *Aiken wrote:*   

> The other difference is I am using static and you are using dhcp.

 

dhcp or not,  my routing table ends up the same: borked.

----------

