Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved]how bridge with dhcpcd
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Rocky007
n00b
n00b


Joined: 22 Dec 2014
Posts: 66

PostPosted: Sun Feb 04, 2018 1:31 am    Post subject: [solved]how bridge with dhcpcd Reply with quote

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:
Code:

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
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 41719
Location: 56N 3W

PostPosted: Sun Feb 04, 2018 10:41 am    Post subject: Reply with quote

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.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Rocky007
n00b
n00b


Joined: 22 Dec 2014
Posts: 66

PostPosted: Sun Feb 04, 2018 11:24 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 41719
Location: 56N 3W

PostPosted: Sun Feb 04, 2018 11:40 am    Post subject: Reply with quote

Rocky007,

You will need brctl and kernel support for bridges.
Once your bridge exists, dhcpcd will do the rest.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Rocky007
n00b
n00b


Joined: 22 Dec 2014
Posts: 66

PostPosted: Sun Feb 04, 2018 3:01 pm    Post subject: Reply with quote

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

Code:
#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]
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 41719
Location: 56N 3W

PostPosted: Sun Feb 04, 2018 3:40 pm    Post subject: Reply with quote

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.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Rocky007
n00b
n00b


Joined: 22 Dec 2014
Posts: 66

PostPosted: Sun Feb 04, 2018 3:51 pm    Post subject: Reply with quote

i fixed it now using netifrc was a lot easyier an better to solve
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 41719
Location: 56N 3W

PostPosted: Sun Feb 04, 2018 4:02 pm    Post subject: Reply with quote

Rocky007,

That's what I do too :)
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Rocky007
n00b
n00b


Joined: 22 Dec 2014
Posts: 66

PostPosted: Mon Feb 05, 2018 7:38 am    Post subject: Reply with quote

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:
Code:

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
Code:

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:
Code:

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
}
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6721
Location: Blighty

PostPosted: Mon Feb 05, 2018 9:38 am    Post subject: Reply with quote

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?
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 41719
Location: 56N 3W

PostPosted: Mon Feb 05, 2018 10:17 am    Post subject: Reply with quote

Rocky007,

Your routing table isn't doing what you think it is.
Code:
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.
Code:
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.
Code:
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. :)
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6721
Location: Blighty

PostPosted: Mon Feb 05, 2018 10:20 am    Post subject: Reply with quote

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.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum