You are not logged in.

#1 2014-07-29 20:37:48

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,697
Website

Using netctl and bonding still use two different IP addresses

Goal: have wired internet take precedent over wireless using netctl.  If I plug in a wire, I want it to up come.  If I do not, I want wireless to connect.

Action: bind together my wireless and wired interfaces.

How: I followed this wiki article.  After completing the steps, it seems to be working but:

1) The wired interface operates on a different IP address from the wireless interface.
2) Both interfaces are up at the same time (i.e. I can ssh into either one or both at the same time).

What am I missing here?

The following are running:
dhcpcd.service
netctl@failover.service
wpa_supplicant@wlp4s0.service

/etc/modprobe.d/bonding.conf

options bonding mode=active-backup
options bonding miimon=100
options bonding primary=enp0s10
options bonding max_bonds=0

/etc/netctl/failover

Description='A wired connection with failover to wireless'
Interface='bond0'
Connection=bond
BindsToInterfaces=('enp0s10' 'wlp4s0')
IP='dhcp'
SkipNoCarrier='no'
ExecUpPost='/usr/bin/ethtool -s enp0s10 wol g'
ExecDownPre='/usr/bin/pkill sshd'

/etc/wpa_supplicant/wpa_supplicant-wlp4s0.conf

ctrl_interface=/var/run/wpa_supplicant
update_config=1
eapol_version=1
fast_reauth=1
ap_scan=1

network={
 ssid="myssid"
 psk="mysecretpasswd"
 priority=2
}

Last edited by graysky (2014-07-29 21:09:01)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2014-07-29 21:04:24

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: Using netctl and bonding still use two different IP addresses

graysky wrote:

How: I followed this wiki article.  After completing the steps, it seems to be working but the wired interface operates on a different IP address from the wireless interface.  Why?

None of these interfaces should have an IP, just the bonding one. As said in the other thread, the wiki is confusing on this. Please try a fixed IP. If this works for you, we can figure out how to use it with dhcp (dhcp fails because of no carrier - there should be some workaround, I think).

Edit: I see, you have edited your config. IP=no is wrong, this is meant for the wired/wireless interfaces, if you bring them up with netctl.

Last edited by Tarqi (2014-07-29 21:16:12)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#3 2014-07-29 21:13:55

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,697
Website

Re: Using netctl and bonding still use two different IP addresses

@Tarqi - Sorry about that... it was a typo.  I edited my first post changing it to dhcp which reflects reality.

I tried using a fixed IP in /etc/netctl/failover but when I do that, things get even more crazy: I have 3 IP addresses and can connect to any of them.

Last edited by graysky (2014-07-29 21:15:38)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#4 2014-07-29 21:26:32

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: Using netctl and bonding still use two different IP addresses

Below is what I use. The only thing I need to do is netctl start failover (or enable the systemd service), wpa_supplicant will be fired up from there. This is a client profile, maybe that is important (what I don't think). It works when booted without a cable plugged, so wireless will kick in (I will try to boot with a cable plugged right now and report here in a few mins). The only thing i needed to do is to set the option fail_over_mac, because of my dumb gateway, but that should not touch the setup itself.

/etc/modprobe.d/bonding.conf

options bonding mode=active-backup
options bonding miimon=100
options bonding primary=eth0
options bonding max_bonds=0
options bonding fail_over_mac=active

/etc/netctl/failover

Description='Bond Network (eth0, wlan0, static)'
Interface=bond0
Connection=bond
BindsToInterfaces=('eth0' 'wlan0')
IP=static
Address=('192.168.20.2/24')
Gateway='192.168.20.1'
DNS=('192.168.10.1' 'x,x,x,x' 'y.y.y.y')
DNSDomain='domain.tld'
DNSSearch='domain.tld'
ExecUpPost='wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant-wlan0.conf||true'
ExecDownPre='wpa_cli -i wlan0 terminate||true'

/etc/wpa_supplicant/wpa_supplicant-wlan0.conf

ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=wheel
network={
proto=RSN WPA
psk=thepsk
ssid="thessid"
scan_ssid=1
}

Last edited by Tarqi (2014-07-31 17:47:13)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#5 2014-07-29 21:29:28

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,697
Website

Re: Using netctl and bonding still use two different IP addresses

So you did not enable dhcpcd nor wpa_supplicant@foo?  I see you have ExecUpPost to start the wpa thing...

Can you post the output of:  `find /etc/systemd/system -mindepth 1 -type d | xargs ls -l --color`

For me:

% find /etc/systemd/system -mindepth 1 -type d | xargs ls -l --color
/etc/systemd/system/getty.target.wants:
total 0
lrwxrwxrwx 1 root root 38 Dec 31  2013 getty@tty1.service -> /usr/lib/systemd/system/getty@.service

/etc/systemd/system/local-fs.target.wants:
total 0

/etc/systemd/system/multi-user.target.wants:
total 0
lrwxrwxrwx 1 root root 38 Dec 31  2013 cronie.service -> /usr/lib/systemd/system/cronie.service
lrwxrwxrwx 1 root root 38 Jul 29 16:19 dhcpcd.service -> /usr/lib/systemd/system/dhcpcd.service
lrwxrwxrwx 1 root root 43 Jul 29 15:21 netctl@failover.service -> /etc/systemd/system/netctl@failover.service
lrwxrwxrwx 1 root root 36 Dec 31  2013 ntpd.service -> /usr/lib/systemd/system/ntpd.service
lrwxrwxrwx 1 root root 51 Jul  8 09:12 remote-fs.target -> ../../../../usr/lib/systemd/system/remote-fs.target
lrwxrwxrwx 1 root root 36 Jul 24 20:25 sshd.service -> /usr/lib/systemd/system/sshd.service
lrwxrwxrwx 1 root root 47 Jul 29 15:33 wpa_supplicant@wlp4s0.service -> /usr/lib/systemd/system/wpa_supplicant@.service

/etc/systemd/system/sockets.target.wants:
total 0

Last edited by graysky (2014-07-29 21:30:12)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#6 2014-07-29 21:46:29

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: Using netctl and bonding still use two different IP addresses

First: It works perfectly on boot, regardless if the cable is plugged or not.

graysky wrote:

So you did not enable dhcpcd nor wpa_supplicant@foo?  I see you have ExecUpPost to start the wpa thing...

That's correct.

graysky wrote:

Can you post the output of:  `find /etc/systemd/system -mindepth 1 -type d | xargs ls -l --color`

This would lead to confusion I think, because I have a quite special setup with several targets. However, here you go:

/etc/systemd/system/boot-hdd.target.wants:
total 0
lrwxrwxrwx 1 root root 32  7. May 06:00 arch.service -> /etc/systemd/system/arch.service
lrwxrwxrwx 1 root root 42 16. Apr 00:11 boot-hdd-mount.service -> /etc/systemd/system/boot-hdd-mount.service
lrwxrwxrwx 1 root root 44 28. Jul 23:34 netctl@failover.service -> /etc/systemd/system/netctl@failover.service

/etc/systemd/system/boot-usb.target.wants:
total 0
lrwxrwxrwx 1 root root 42 16. Apr 00:13 boot-usb-mount.service -> /etc/systemd/system/boot-usb-mount.service
lrwxrwxrwx 1 root root 35 16. Apr 00:13 hdparm@sda.service -> /etc/systemd/system/hdparm@.service

/etc/systemd/system/boot-vm.target.wants:
total 0
lrwxrwxrwx 1 root root 32  7. May 11:22 arch.service -> /etc/systemd/system/arch.service
lrwxrwxrwx 1 root root 41 16. Apr 00:13 boot-vm-mount.service -> /etc/systemd/system/boot-vm-mount.service
lrwxrwxrwx 1 root root 43 20. Jun 01:53 netctl@eth1.service -> /etc/systemd/system/netctl@eth1.service

/etc/systemd/system/getty.target.wants:
total 0
lrwxrwxrwx 1 root root 38 28. Jul 2013  getty@tty1.service -> /usr/lib/systemd/system/getty@.service

/etc/systemd/system/multi-user.target.wants:
total 0
lrwxrwxrwx 1 root root 36 24. Apr 00:21 boot-hdd.service -> /etc/systemd/system/boot-hdd.service
lrwxrwxrwx 1 root root 36 24. Apr 00:21 boot-usb.service -> /etc/systemd/system/boot-usb.service
lrwxrwxrwx 1 root root 35 24. Apr 00:21 boot-vm.service -> /etc/systemd/system/boot-vm.service
lrwxrwxrwx 1 root root 35 14. Sep 2013  gpm.service -> /usr/lib/systemd/system/gpm.service
lrwxrwxrwx 1 root root 51  8. Jul 15:16 remote-fs.target -> ../../../../usr/lib/systemd/system/remote-fs.target
lrwxrwxrwx 1 root root 20 13. Jun 23:13 static-boot.mount -> ../static-boot.mount
lrwxrwxrwx 1 root root 15 13. Jun 23:13 static.mount -> ../static.mount

You are interested in the first one (boot-hdd.target.wants), where arch.service is a systemd-nspawn with my old server (lacking hardware currently), boot-hdd-mount.service takes care to mount the boot partition if the system is booted from the internal hdd (and not  from {vm,usb,ram}), and finally netctl@failover.service is the only service which kicks in my network in this target.

The boot-{vm,usb,hdd}.service files in multi-user.target.wants conditionally start the needed target.

Last edited by Tarqi (2014-07-31 17:49:26)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#7 2014-07-29 21:48:34

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,697
Website

Re: Using netctl and bonding still use two different IP addresses

Ha, that is confusing smile  Are you able to get your setup to work with DHCP?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#8 2014-07-29 21:53:51

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: Using netctl and bonding still use two different IP addresses

graysky wrote:

Are you able to get your setup to work with DHCP?

Tarqi wrote:

If this works for you, we can figure out how to use it with dhcp (dhcp fails because of no carrier - there should be some workaround, I think).

So: No. I just tested it while we are writing here for the last hour and did not find a quick solution. However, I am sure there is one smile

Last edited by Tarqi (2014-07-29 22:16:40)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#9 2014-07-29 23:24:56

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: Using netctl and bonding still use two different IP addresses

Ok, I poked around a bit and it turned out that using DHCP manually is indeed possible. So it might be a problem caused by the way netctl works. I did not test it with systemd-networkd, this may be an example for the reader, as for putting the functionality into a systemd service, if wanted.

The following, simple script illustrates the workflow (and it certainly works):

#!/bin/sh

WIRED=eth0
WIFI=wlan0

case "$1" in
  up)
     modprobe bonding
     ip link add bond0 type bond
     ip link set bond0 up
     ifenslave bond0 $WIRED $WIFI
     wpa_supplicant -B -i $WIFI -c /etc/wpa_supplicant/wpa_supplicant-$WIFI.conf
     dhcpcd bond0
     ;;
  down)
     dhcpcd -k bond0
     wpa_cli -i $WIFI terminate
     ip link del dev bond0
     ;;
  *)
     echo "Usage: $(basename $0) <up|down>"
     ;;
esac

Note: At least one interface must have a carrier, otherwise it will fail (obviously), and the interface may not be up when adding it to the bonding device.

Edit: Changed pkill to wpa_cli
Edit2: Typos

Last edited by Tarqi (2014-07-31 17:39:36)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#10 2014-07-31 03:52:23

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: Using netctl and bonding still use two different IP addresses

There is nothing special about bonding and DHCP. The only thing you should pay attention to, is that all real interfaces that  are to be enslaved, are down before enslaving. This means that wpa_supplicant must start after the wlan interface is added to the bond.

FWIW, here is my systemd-networkd config which I just created on my laptop with 2 real interfaces: wired 'eno1' and wireless 'wlp3s0'.
(1) Create a bond -- 'bond0' interface -- that is appropriately configured

$ cat /etc/systemd/network/bond0.netdev 
[NetDev]
Name=bond0
Kind=bond
$ cat /etc/modprobe.d/bonding.conf 
options bonding mode=active-backup
options bonding primary=wlp3s0
options bonding miimon=1000

The last option is the most important one. By default it is 0, which I guess disables link status updates and effectively blocks all traffic through 'bond0'.

(2) Enslave the physical interfaces

$ cat /etc/systemd/network/eth.network 
[Match]
Name=eno1

[Network]
Description=Wired interface
Bond=bond0
$ cat /etc/systemd/network/wlan.network 
[Match]
Name=wlp3s0

[Network]
Description=Wireless interface
Bond=bond0

(3) Finally, wake up the DHCP client on 'bond0'

$ cat /etc/systemd/network/bond0.network 
[Match]
Name=bond0

[Network]
Description=Bond interface
DHCP=v4

[DHCPv4]
UseDNS=false

(4) Now starts wpa_supplicant on the wlan interface. To order if after systemd-networkd, append  the latter service with the drop-in config

$ cat /etc/systemd/system/systemd-networkd.service.d/before-wpa_supplicant.conf 
[Unit]
Before=wpa_supplicant-nl80211@wlp3s0.service

The wpa_supplicant service is the stock file shipped with the package.

(5) Modify your userspace to use 'bond0' as a real interface. In my case, this amounted to changing iptables ruleset.

Here is the picture after boot:

$ ip a
2: wlp3s0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
    link/ether f0:1f:af:4d:36:99 brd ff:ff:ff:ff:ff:ff
3: eno1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 1500 qdisc pfifo_fast master bond0 state DOWN group default qlen 1000
    link/ether f0:1f:af:4d:36:99 brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether f0:1f:af:4d:36:99 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.20/24 brd 10.0.0.255 scope global dynamic bond0
       valid_lft 83684sec preferred_lft 83684sec
$ journalctl -u systemd-networkd.service 
Jul 30 23:03:04 borei systemd[1]: Starting Network Service...
Jul 30 23:03:05 borei systemd-networkd[455]: bond0           : netdev ready
Jul 30 23:03:05 borei systemd-networkd[455]: lo              : gained carrier
Jul 30 23:03:05 borei systemd-networkd[455]: bond0           : link configured
Jul 30 23:03:05 borei systemd[1]: Started Network Service.
Jul 30 23:03:05 borei systemd-networkd[455]: eno1            : link configured
Jul 30 23:03:05 borei systemd-networkd[455]: wlp3s0          : link configured
Jul 30 23:03:09 borei systemd-networkd[455]: wlp3s0          : gained carrier
Jul 30 23:03:10 borei systemd-networkd[455]: bond0           : gained carrier
Jul 30 23:03:13 borei systemd-networkd[455]: bond0           : DHCPv4 address 10.0.0.20/24 via 10.0.0.1
Jul 30 23:03:13 borei systemd-networkd[455]: bond0           : link configured
$ journalctl | gr bonding
Jul 30 23:03:05 borei kernel: bonding: Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Jul 30 23:03:05 borei kernel: bonding: MII link monitoring set to 1000 ms
Jul 30 23:03:05 borei kernel: bonding: bond0: Enslaving eno1 as a backup interface with a down link
Jul 30 23:03:05 borei kernel: bonding: bond0: Enslaving wlp3s0 as a backup interface with a down link
Jul 30 23:03:10 borei kernel: bonding: bond0: link status definitely up for interface wlp3s0, 0 Mbps full duplex
Jul 30 23:03:10 borei kernel: bonding: bond0: making interface wlp3s0 the new active one
Jul 30 23:03:10 borei kernel: bonding: bond0: first active interface up!

HTH.

EDIT: @Graysky, by looking at your profiles in the other thread, I don't think that you need netctl. This is because those profiles are basically the same. i.e. they both start DHCP client on an interface, without any special and _different_ (interface-specific) configuration. So, the above config can be a fit for you...

Last edited by Leonid.I (2014-07-31 03:56:22)


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

#11 2014-08-09 19:20:11

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: Using netctl and bonding still use two different IP addresses

graysky wrote:

Ha, that is confusing smile  Are you able to get your setup to work with DHCP?

So in case you haven't got it to work yet, here is an example of how to use netctl, wpa_supplicant and dhcpcd with bonding interfaces.

$ cat /etc/netctl/bonding0 
Description="Bond interface for external NICs"

Interface=bond0
Connection=bond
BindsToInterfaces=(eno1 wlp3s0)

IP=no
$ cat /etc/netctl/wlan 
Description='Secure wireless uplink'

Interface=wlp3s0
Connection=wireless
ForceConnect=yes
After=(bonding0)

Security=wpa-config
WPAConfigFile='/etc/wpa_supplicant/wpa_supplicant-nl80211-wlp3s0.conf'
IP=no
$ cat /etc/netctl/wan
Description='DHCP connection on bond0'

Interface=bond0
Connection=ethernet
ForceConnect=yes
SkipNoCarrier=yes
After=(wlan)
	
IP=dhcp
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 1500 qdisc pfifo_fast master bond0 state DOWN group default qlen 1000
    link/ether f0:1f:af:4d:36:99 brd ff:ff:ff:ff:ff:ff
3: wlp3s0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
    link/ether f0:1f:af:4d:36:99 brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether f0:1f:af:4d:36:99 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.20/24 brd 10.0.0.255 scope global bond0
       valid_lft forever preferred_lft forever

Notice the "ForceConnect" flags which are required because interfaces will be up after bonding.

HTH...

Last edited by Leonid.I (2014-08-09 19:23:04)


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

Board footer

Powered by FluxBB