# [solved]how bridge with dhcpcd

## Rocky007

Hello,

i'm trying to create a bridge with the following settings:

LAN enp7s0

WLAN (WiFi Hostapd) wlp10s0

Bridge br0

Currently i'm using dhcpcd with the following configuration:

```

interface enp7s0

static ip_address=192.168.178.29/24

static routers=192.168.178.1

static domain_name_servers=192.168.178.1

allow-hotplug wlp10s0

interface wlp10s0

static ip_address=192.168.178.30/24

static routers=192.168.178.1

static domain_name_servers=192.168.178.1

```

Can you help me how i can do this?

br0 will having a static ip -> 192.168.178.29 (currently used by enp7s0)Last edited by Rocky007 on Sun Feb 04, 2018 3:51 pm; edited 1 time in total

----------

## NeddySeagoon

Rocky007,

First you up the interfaces without than getting an IP address.

Then you donate the interfaces to the bridge.

Lastly, the bridge gets an IP.

Read  /usr/share/doc/netifrc-0.6.0/net.example.bz2, or whatever your netifrc version is.

----------

## Rocky007

Hi,

thanks for ghe info.

But i'm not using netifrc, just dhcpcd.

Isnt it possible without netifrc as the netifrc wiki site said it can be replaced by any other dhcp service?

----------

## NeddySeagoon

Rocky007,

You will need brctl and kernel support for bridges.

Once your bridge exists, dhcpcd will do the rest.

----------

## Rocky007

What i've done now:

brctl addbr br0

brctl addif br0 enp7s0

brctl addif br0 wlp10s0 -> "can't add wlp10s0 to bridge br0: Operation not supported"

/etc/dhcpcd.conf

```
#interface enp7s0

#static ip_address=192.168.178.29/24

#static routers=192.168.178.1

#static domain_name_servers=192.168.178.1

interface enp6s0

static ip_address=192.168.178.30/24

static routers=192.168.178.1

static domain_name_servers=192.168.178.1

#interface wlp10s0

#static ip_address=192.168.178.30/24

#static routers=192.168.178.1

#static domain_name_servers=192.168.178.1

interface br0

static ip_address=192.168.178.29/24

static routers=192.168.178.1

static domain_name_servers=192.168.178.1

```

But this is not persistent after a reboot....

What have i forgotten?

[Moderator edit: added [code] tags to preserve output layout. -Hu]

----------

## NeddySeagoon

Rocky007,

bridges are not persistent across reboots.

You need to create the bridge and assign interfaces to it before dhcpcd can assign it and IP and use it for routing.

Whatever will create your bridge needs to run before dhcpcd.

The error  "can't add wlp10s0 to bridge br0: Operation not supported" needs to be addressed too.

----------

## Rocky007

i fixed it now using netifrc was a lot easyier an better to solve

----------

## NeddySeagoon

Rocky007,

That's what I do too :)

----------

## Rocky007

Now i'm facing one problem:

Actual the server is behind a fritz box.

I've configured a NAT rule which says

Incoming port 5022 will go to my brigde interface 192.168.178.29 (br0, enp7s0 and wlp10s0) on port 22...

Also web port 80, mail etc is going to the br0 (enp7s0, wlp10s0), but i cannot get external access anymore.

Currently I've got another uplink enp6s0 192.168.178.30 forwarded in fritzbox 6022 to 22 on this ip

This is partitally working from time to time, but with another server internally i can connect to ssh...

What can cause the problem here?

ip addr:

```

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo

       valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host

       valid_lft forever preferred_lft forever

2: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000

    link/ether 1c:1b:0d:9e:18:27 brd ff:ff:ff:ff:ff:ff

    inet6 fe80::1e1b:dff:fe9e:1827/64 scope link

       valid_lft forever preferred_lft forever

3: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

    link/ether 1c:1b:0d:9e:18:25 brd ff:ff:ff:ff:ff:ff

    inet 192.168.178.30/24 brd 192.168.178.255 scope global enp6s0

       valid_lft forever preferred_lft forever

    inet6 fe80::1e1b:dff:fe9e:1825/64 scope link

       valid_lft forever preferred_lft forever

4: wlp10s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000

    link/ether 50:3e:aa:5f:30:56 brd ff:ff:ff:ff:ff:ff

5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1

    link/sit 0.0.0.0 brd 0.0.0.0

13: br0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000

    link/ether 1c:1b:0d:9e:18:27 brd ff:ff:ff:ff:ff:ff

    inet 192.168.178.29/24 brd 192.168.178.255 scope global br0

       valid_lft forever preferred_lft forever

    inet6 fe80::1e1b:dff:fe9e:1827/64 scope link

       valid_lft forever preferred_lft forever

15: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100

    link/none

    inet 10.100.0.1 peer 10.100.0.2/32 scope global tun0

       valid_lft forever preferred_lft forever

    inet6 fe80::a05d:917d:6fad:a0f1/64 scope link stable-privacy

       valid_lft forever preferred_lft forever

```

route -n

```

Kernel IP Routentabelle

Ziel            Router          Genmask         Flags Metric Ref    Use Iface

default via 192.168.178.1 dev enp6s0 metric 3

default via 192.168.178.1 dev br0 metric 6

10.100.0.0/24 via 10.100.0.2 dev tun0

10.100.0.2 dev tun0 proto kernel scope link src 10.100.0.1

192.168.178.0/24 dev br0 proto kernel scope link src 192.168.178.29

192.168.178.0/24 dev enp6s0 proto kernel scope link src 192.168.178.30

```

conf.d/net:

```

config_enp7s0="null"

config_enp6s0="192.168.178.30 netmask 255.255.255.0"

routes_enp6s0="default via 192.168.178.1"

dns_servers_enp6s0="192.168.178.1"

modules_wlp10s0="!iwconfig !wpa_supplicant"

config_wlp10s0="null"

bridge_br0="enp7s0"

rc_net_br0_need="net.enp7s0"

config_br0="192.168.178.29 netmask 255.255.255.0 brd 192.168.178.255"

routes_br0="default via 192.168.178.1"

bridge_forward_delay_br0=0

bridge_hello_time_br0=1000

preup() {

        rfkill unblock all

}

```

----------

## UberLord

So from reading this, the ability to run a script for non-existant interfaces at start would be desirable?

Or are people happy using netifrc?

----------

## NeddySeagoon

Rocky007,

Your routing table isn't doing what you think it is.

```
Kernel IP Routentabelle

Ziel            Router          Genmask         Flags Metric Ref    Use Iface

default via 192.168.178.1 dev enp6s0 metric 3

default via 192.168.178.1 dev br0 metric 6

10.100.0.0/24 via 10.100.0.2 dev tun0

10.100.0.2 dev tun0 proto kernel scope link src 10.100.0.1

192.168.178.0/24 dev br0 proto kernel scope link src 192.168.178.29

192.168.178.0/24 dev enp6s0 proto kernel scope link src 192.168.178.30 
```

Rules are applied from the bottom up until the first match is found.

```
192.168.178.0/24 dev br0 proto kernel scope link src 192.168.178.29

192.168.178.0/24 dev enp6s0 proto kernel scope link src 192.168.178.30
```

Packets going to  192.168.178.0/24 will always go to enp6s0 since the br0 rule cannot be reached.

Likewise with your two default routes, Only br0 will ever be used.

Your net file shows that you have two interfaces in the same subnet.

```
config_enp6s0="192.168.178.30 netmask 255.255.255.0"

config_br0="192.168.178.29 netmask 255.255.255.0
```

only one will be used.

This is where your two default routes come from too.

Draw out your network topology with the IP addresses and routes.

It will hep your thinking.  Maybe even post an image too.  

@UberLord,

I'm good with things the way they are.

If you go and change it, I'll need to learn it all over again. :)

----------

## UberLord

 *NeddySeagoon wrote:*   

> @UberLord,
> 
> I'm good with things the way they are.
> 
> If you go and change it, I'll need to learn it all over again. 

 

I don't touch netifrc.

And any change for this in dhcpcd would be user set via a new option, so if you don't want to change you don't have to.

----------

