You are not logged in.

#1 2017-10-07 17:00:50

Cbhihe
Member
Registered: 2017-04-09
Posts: 219

[SOLVED] How to stop wifi service when connected to wire-Ethernet.

Hi all, I come from Unix via Ubuntu and just installed `base` on a Dell XPs15 9560. For now I work only from console (no GUI installed) to set up networking as I need it. So this post is typed from a separate box. In /etc/udev/rules.d/ I renamed my internal WiFi (ath10k_pci controller for Qualcomm Atheros QCA6174 802.11ac) "wifi0" and my external wired NIC (a dongle) "net0".

When I am connected on the wired network I want the Wifi service on that system to aautomatically go down. With the following config, I expected that to happen. It does not.

Background info:
$ uname -r
4.13.4-1-ARCH
$ pacman -Q linux | grep -e Version -e Architecture
Version: 4.13.4-1
Architecture: x86_64

What I want to do is:
- set up wire connectivity - that, I did with
$ sudo systemctl enable netctl-ifplugd@net0
and checked to my satisfaction with
$ sudo systemctl status netctl-ifplugd@net0

- set up automatic scan and wireless connectivity  - that I do as above replacing 'netctl-ifplugd@net0' by 'netctl-auto@wifi0' . Again no pbm. I configured various wifi profiles with different priorities, such as:
$ sudo cat  /etc/netctl/wifi_TestNet
Description='blabla'
Interface=wifi0
Connection=wireless

Security=wpa
IP=dhcp

ESSID='TestNet'
Key='skfmslkfm'
Priority=5

When I check:
$ip a | grep -A3 -e net0 -e wifi0
I get IPv4 assignation on both ifaces: net0 and wifi0.
Never beleiving a smiling screen, I double-checked by successfully ping'ing through both ifaces:
$ ping -I   192.168.1.38   8.8.8.8    # through wifi0
and
$ ping -I   192.168.1.45   8.8.8.8    # through net0

When I unplug and plug the Ethernet cable I automatically get wired connectivity after about 2 s. However Wifi stays on. ***How can that be remedied ? ***
Cheers, -ced

Last edited by Cbhihe (2017-10-08 10:13:12)


I like strawberries, therefore I'm not a bot.

Offline

#2 2017-10-07 17:12:19

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] How to stop wifi service when connected to wire-Ethernet.

Welcome to the forums Cbhihe smile

Do you really want to disable your wireless connection?
At the minute it looks like all your traffic is routed through the LAN unless is doesn't have a connection, which is the usual expected behaviour.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2017-10-07 18:00:34

Cbhihe
Member
Registered: 2017-04-09
Posts: 219

Re: [SOLVED] How to stop wifi service when connected to wire-Ethernet.

@slithery: I just want to save power and automatically put the WiFi iface in a kind of energy saving slumber mode while  the wired connection is active. How can I acheive that with existing service config files ? (I did snoop inside my basic system, but could not find anything readlily recognizable in the spirit of netctl-ifplugd for instance).
The idea is for the WiFi NIC to automatically become active as soon as the wired connection to Ethernet becomes absent.


I like strawberries, therefore I'm not a bot.

Offline

#4 2017-10-07 19:11:38

seth
Member
Registered: 2012-09-03
Posts: 51,312

Re: [SOLVED] How to stop wifi service when connected to wire-Ethernet.

"man 5 netctl.profile", see the Exec* keys. Edit your ethernet profile itr. to do whatever you want when it comes up/down.

Offline

#5 2017-10-07 20:46:32

Cbhihe
Member
Registered: 2017-04-09
Posts: 219

Re: [SOLVED] How to stop wifi service when connected to wire-Ethernet.

Thanks @seth ! That is where I should have gotten in the man page. :-{ My bad.
However simply adding the following two line in my /etc/netctl/ethernet-dhcp profile:

ExecUpPost="ifconfig wifi0 down" || true
ExecDownPre="ifconfig wifi0 up"

does not appear to cut it (with or without 'sudo' in front of 'ifconfig') : no effect.

Now looking at the new file:

$ sudo vim /etc/netctl/interfaces/net0
#!/bin/sh
ExecUpPost="systemctl stop netctl-auto@wifi0.service" || true
ExecDownPre="systemctl start netctl-auto@wifi0.service"


I like strawberries, therefore I'm not a bot.

Offline

#6 2017-10-07 21:00:12

seth
Member
Registered: 2012-09-03
Posts: 51,312

Re: [SOLVED] How to stop wifi service when connected to wire-Ethernet.

I've never tried, but I doubt you can rely on shell features here (leaving aside the impact the quotes then would have)
=> put that into a script and call it by absolute path. This also allows you to debug whether the script is called ("echo foo > /tmp/bar")
Don't forget to make the script executable, but you won't need sudo here.

Edit: /etc/netctl/interfaces/net0 isn't a valid netctl profile at all, btw.

Last edited by seth (2017-10-07 21:01:13)

Offline

#7 2017-10-08 10:10:19

Cbhihe
Member
Registered: 2017-04-09
Posts: 219

Re: [SOLVED] How to stop wifi service when connected to wire-Ethernet.

The solution was indeed :

$ sudo vim /etc/netctl/interfaces/net0
#!/bin/sh
ExecUpPost="systemctl stop netctl-auto@wifi0.service" || true
ExecDownPre="systemctl start netctl-auto@wifi0.service"

It works flawlessly, :-) , even in "busy" environments where accessible SSIDs (i.e. WiFi networks) are many and prioritized per the priority flag in my /etc/netctl/wifi_* profiles.
The only rub is the unavoidable  (??) latency involved in starting the host WiFi service, an unbearably long 2~3 seconds in my case.

Thank you for the earlier pointer, Seth.
(BTW, I never said `/etc/netctl/interfaces/net0` was any kind of profile. It is nothing by a file whose content is parsed everytime an _unit_ invoked by the network manager `netctl` has to deal with iface `net0` going up or down... if I have not misunderstood my readings.)

Last edited by Cbhihe (2017-10-08 10:25:31)


I like strawberries, therefore I'm not a bot.

Offline

Board footer

Powered by FluxBB