# ifconfig_bridge with tap not working in rc.conf



## joggx (Sep 3, 2020)

Hi All,

I have the following setup in rc.conf to bring up the bridge and taps so that bhyve VMs have Internet access. I am using FreeBSD 12.1-RELEASE.


```
cloned_interfaces="bridge1"
cloned_interfaces="bridge1 tap2"
cloned_interfaces="bridge1 tap3"
ifconfig_bridge1="addm bce0 addm tap2 addm tap3 up"
```

I have the following in /etc/boot/loader.conf too:

```
if_bridge_load="YES"
if_tap_load="YES"
```

But it is not working and each time it boots I have to manually run the following to make it work:

`ifconfig bridge create;ifconfig bridge1 addm tap3;ifconfig tap2 create;ifconfig bridge1 addm tap2;`

Also it seems that if I use bridge0 it is ignored and system only recognizes bridge1 and up.

Any help is appreciated.


----------



## Emrion (Sep 3, 2020)

In rc.conf, what you set are just variables. If you set several times `cloned_interfaces`, it can't work. Try:
`cloned_interfaces="bridge1 tap2 tap3"`


----------



## driesm (Sep 3, 2020)

What Emrion said will be the root cause, as an optimization/config file clean-up you don't need to specify the drivers below.
They will be auto loaded by ifconfig when the interfaces are created.



joggx said:


> ```
> if_bridge_load="YES"
> if_tap_load="YES"
> ```


----------



## joggx (Sep 3, 2020)

Emrion said:


> In rc.conf, what you set are just variables. If you set several times `cloned_interfaces`, it can't work. Try:
> `cloned_interfaces="bridge1 tap2 tap3"`



Tried but doesn't work. I found the following in dmesg:


```
# dmesg | grep tap
tap3: Ethernet address: 58:9c:fc:10:a4:33
tap3: link state changed to UP
tap3: promiscuous mode enabled
tap2: Ethernet address: 58:9c:fc:10:d5:01
tap2: promiscuous mode enabled
# dmesg | grep bridge1
bridge1: Ethernet address: 58:9c:fc:10:ff:9a
bridge1: link state changed to UP
```

tap3 is up but tap2 is not.  It also shows bridge1 is up but `ifconfig` doesn't show bridge1 info.


----------



## joggx (Sep 3, 2020)

Duffyx said:


> What Emrion said will be the root cause, as an optimization/config file clean-up you don't need to specify the drivers below.
> They will be auto loaded by ifconfig when the interfaces are created.



OK


----------



## Emrion (Sep 3, 2020)

First, leave `cloned_interfaces` as I show you.

It isn't clear why you use bridge1 and not bridge0; tap2 & 3 instead of tap0 & 1.
I think you should explain what you want to achieve.

For the tap interfaces you can try to add in rc.conf:
`ifconfig_tap2="up"                                                               
ifconfig_tap3="up"`


----------



## joggx (Sep 4, 2020)

The reason of not using bridge0 is it doesn't work. If I change all `bridge1` in `/etc/rc.conf` to `bridge0` nothing happens either. Until I run `ifconfig bridge create` which gives output `bridge1`.

I tried adding after 


```
ifconfig_tap2="up"
ifconfig_tap3="up"
```

It doesn't work either.


----------



## Lamia (Sep 5, 2020)

What are you doing? You can't get (cloned) interfaces for tapX unless there is a genuine service requing them - vm, openvpn,etc.
And for the bridges, what are the member interfaces - em0, ix1,etc? Do they exist? Bce0! What is it? You would see them with the ifconfig command if we'll defined.


----------



## joggx (Sep 5, 2020)

Lamia said:


> What are you doing? You can't get (cloned) interfaces for tapX unless there is a genuine service requing them - vm, openvpn,etc.
> And for the bridges, what are the member interfaces - em0, ix1,etc? Do they exist? Bce0! What is it? You would see them with the ifconfig command if we'll defined.



bce0 and bce1 are the NICs comes with the physical machine.

bridge is the root of the problem. It is not created at boot.


----------



## Lamia (Sep 5, 2020)

This should work:

```
cloned_interfaces="bridge1 tap2 tap3"
ifconfig_bridge1="addm bce0 addm tap2 addm tap3 up"
ifconfig_bridge1="inet 192.168.0.1/24 ether 00:00:00:0c:00:0f"
```
Adding an arbitrary ether address could make a difference and so is an IP address.
You can alternatively drop the lines in a shell script and run after boot up - rc.local may work too. So you can try three options - additional changes to rc.conf, new shell script or rc.local

Do read about bridging to:

```
31.5.4. Enabling the Bridge
Add the line:

net.link.ether.bridge.enable=1
to /etc/sysctl.conf to enable the bridge at runtime, and the line:

net.link.ether.bridge.config=if1,if2
to enable bridging on the specified interfaces (replace if1 and if2 with the names of your two network interfaces).
```


----------

