You are not logged in.

#1 2014-01-11 14:23:01

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 678

Auto switching between network profiles - including auto up and down

I want my laptop to automatically connect to a given network profile based on the following rules:

1) if the ethernet cable is connected connect the ethernet-static profile
2) Otherwise, attempt to connect to any available wifi network using dhcp

I assumed that https://wiki.archlinux.org/index.php/Ne … f_profiles explained exactly this, but upon enabling both my wired and wireless interface:

#systemctl enable netctl-auto@wlp2s0.service
#systemctl enable netctl-ifplugd@enp0s25.service

It seems to simply bring up both interfaces regardless - which is not what I want and not what I expected from the wiki docs. I have given the wired profile a higher priority.

Am I simply misunderstanding how it works and expecting something unreasonable, or am I simply misunderstanding how it works!?

Last edited by phunni (2014-01-11 14:24:03)

Offline

#2 2014-01-11 14:27:05

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

Re: Auto switching between network profiles - including auto up and down

These standard service files don't try to be too smart...

For a wired to wireless failover with netctl see again the wiki: https://wiki.archlinux.org/index.php/Ne … s_failover

Last edited by ball (2014-01-11 14:28:51)

Offline

#3 2014-01-11 20:10:58

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 678

Re: Auto switching between network profiles - including auto up and down

Thanks for pointing that out - exactly what I want, but, somehow, I missed it.

Having now followed the process exactly I get a bonded interface with both my interfaces (wired and wireless) as slaves.  This is confirmed by both "ip link" and "cat /proc/net/bonding/bond0", however none of those interfaces is listed as having an ip under "ifconfig".  I also, not surprisingly, have no network connection.

I wondered if this was complicated by my having set up my own dhcp server on my router.  IP addresses are assigned based on HW address in /etc/ethers. However, all interfaces (bond0, enp0s25 and wlp2s0) appear to now have the same HW address - that of the wireless interface.  This should be able to get an ip since it is listed in /etc/ethers on the router.

I had planned on pasting all the details of my commands listed above, but I had to revert to a simple wired connection to get back online and forgot to save the file where I pasted all the output!

I can, however, give you my relevant configs:

/etc/modprobe.d/bonding.conf:

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

/etc/netctl/bonded:

Description='A wired connection with failover to wireless'
Interface='bond0'
Connection=bond
BindsToInterfaces=('enp0s25' 'wlp2s0')
IP='dhcp'
SkipNoCarrier='no'

/etc/netctl/home_wired:

Description='A basic bonded ethernet connection'
Interface=enp0s25
Connection=ethernet
IP='no'
## for DHCPv6
#IP6=dhcp
## for IPv6 autoconfiguration
#IP6=stateless

/etc/netctl/redfruit (with key obfuscated):

Description='Automatically generated profile by wifi-menu'
Interface=wlp2s0
Connection=wireless
Security=wpa
ESSID=redfruit
IP='no'
Key="*****"

my wpa supplicant conf (wpa_supplicant-wlp2s0.conf) looks like this(with key obfuscated):

network={
        ssid="redfruit"
        #psk="****"
        psk=*****
}

I enabled the netctl profile "bonded" and started wpa_supplicant with:

#systemctl enable wpa_supplicant@wlp2s0

What did I do wrong?

Last edited by phunni (2014-01-11 20:23:01)

Offline

#4 2014-01-12 01:30:52

cris9288
Member
Registered: 2013-01-07
Posts: 347

Re: Auto switching between network profiles - including auto up and down

I'm looking through this myself right now. The wiki mentions needing to have the dhcpcd service running on both interfaces. Does this mean you have to do a systemctl enable dhcpcd@<interface>.service for each interface? I'm trying it now.

EDIT: No I was definitely wrong about that since the wiki also says that you need to make sure an ip address is assigned to bond0 only. My issue now is that bond0 cannot get an IP address on boot, but once I get to my desktop running 'dhcpcd bon0' gets me one without any problems. I've found this thread http://ubuntuforums.org/showthread.php?t=864657 and am trying to figure out how to apply it to netctl.

EDIT2: I was able to get this working using dhclient. Add DHCPClient=dhclient to the bonding netctl profile. Still not sure why dhcpcd wouldn't work.

Last edited by cris9288 (2014-01-12 02:24:47)

Offline

#5 2014-01-12 18:15:10

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 678

Re: Auto switching between network profiles - including auto up and down

OK, adding DHCPClient=dhclient to the bonding netctl profile worked well.  My problem now is that, when it switches to wifi, it seems to keep bringing the interface down until I make a network request and then it brings it back up again - for a little while.  This has the effect of making my network seem painfully slow.

Does anyone have any ideas why this might be happening?

Offline

#6 2014-01-12 21:42:39

cris9288
Member
Registered: 2013-01-07
Posts: 347

Re: Auto switching between network profiles - including auto up and down

Sounds like a powe rmanagement thing. What wireless card/driver is present in your system? Do you have power management enabled for the interface? what does dmesg -w say when you disconnect and reconnect your ethernet cable?

Offline

#7 2014-01-13 19:06:42

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 678

Re: Auto switching between network profiles - including auto up and down

Annoyingly, my experiments this evening didn't produce the same results - wifi stayed on all the time, but dmesg -w produced the following:

[ 7837.109132] e1000e: enp0s25 NIC Link is Down
[ 7837.201967] bonding: bond0: link status definitely down for interface enp0s25, disabling it
[ 7837.202015] bonding: bond0: now running without any active interface !
[ 7935.237452] wlp2s0: authenticate with 00:18:e7:da:9e:24
[ 7935.245232] wlp2s0: send auth to 00:18:e7:da:9e:24 (try 1/3)
[ 7935.248486] wlp2s0: authenticated
[ 7935.251818] wlp2s0: associate with 00:18:e7:da:9e:24 (try 1/3)
[ 7935.256920] wlp2s0: RX AssocResp from 00:18:e7:da:9e:24 (capab=0x431 status=0 aid=3)
[ 7935.263061] wlp2s0: associated
[ 7935.268428] bonding: bond0: link status definitely up for interface wlp2s0, 0 Mbps full duplex.
[ 7935.268438] bonding: bond0: making interface wlp2s0 the new active one.
[ 7935.268607] bonding: bond0: first active interface up!
[ 7935.298563] wlp2s0: Limiting TX power to 20 (20 - 0) dBm as advertised by 00:18:e7:da:9e:24

The line about limiting power is interesting.

As for which driver I'm using, thinkwiki (I have a thinkpad x201) suggests that it should be  iwlwifi - which is what is loaded.

Last edited by phunni (2014-01-13 19:14:33)

Offline

#8 2014-01-13 21:01:06

cris9288
Member
Registered: 2013-01-07
Posts: 347

Re: Auto switching between network profiles - including auto up and down

Yeah I have iwlwifi too. I'm guessing you have some sort of Intel Centrino Card? Anyways, I've always seen that TX line in my dmesg output even before using the bonded interface. It means pretty what it says - transmitting power is limited to a certain value reported by the card in order to stop it from consuming too much power or overheating ( my best guess ). I hadn't thought about this before, but it may also suggest power management is on? You say you aren't having seeing the same results anymore, so that might not be it. It may be worth looking at though if you still have iwconfig present on your system (that's currently the only way I know to enable/disable power manangement, though it can probably be accomplished with iw).

I wanted to point out another thing: comparing our dmesg output when the ethernet link is removed, it looks like you have wpa_supplicant associate to known networks on-demand. The way I set it up, I'm always associated to my home wireless so there's no waiting period after I unplug the ethernet cable where wlan0 tries to authenticate. I'm not saying one method is better than the other; in fact, I would prefer if it worked more like yours does. How do you have wpa_supplicant set up? I just enabled the service, wpa_supplicant@wlan0.service.

EDIT: Nevermind, I see you also just enable the wpa_supplicant service.

Last edited by cris9288 (2014-01-13 21:05:02)

Offline

Board footer

Powered by FluxBB