You are not logged in.

#1 2016-02-08 10:07:22

timfayz
Member
From: Kazan, Russia
Registered: 2016-01-14
Posts: 59
Website

How to manage automatic wire/wireless connection?

I'm new to Arch and I'm confused how to manage automatic network connections. Of course I've read all of wiki pages regarding to the topic, but it seems to me they're a little over-complicated due to too many ways/tools of doing the same. So I would be grateful if someone explain me how things are related to each other. 
So here is what I did after installation:

ip link #I get PNIC/interface name
systemctl start dhcpcd@enp0s25.service

After, when there was no wire connection, I run:

wifi-menu #using dialog I successfully configured the connection

I've noticed the wifi-menu generated config file at /etc/netctl (as I figured it's a profile used by netctl tool). Now, as far as I understand both of wireless and wire connections established automatically if available. But I have no idea how things work and how to manage them, eg:
- how to disable manually wifi, if I use wireless and vice versa
- how netctl start PROFILE and systemctl start dhcpcd@enp0s25.service are related to each other
- etc

Sometimes I face with some commands like these:

systemctl enable netctl-auto@wlp3s0
systemctl enable netctl-ifplugd@enp2s0

in order to manage automatic connections. But why do I need them if Arch already establish connection on both interface.
I hope you got the idea of my confusion.

Last edited by timfayz (2016-02-08 10:12:12)

Offline

#2 2016-02-08 10:15:22

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

Re: How to manage automatic wire/wireless connection?

Systemd-networkd can do it.  Seethe wiki.

Offline

#3 2016-02-08 10:16:43

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,999
Website

Re: How to manage automatic wire/wireless connection?

timfayz wrote:

- how to disable manually wifi, if I use wireless and vice versa

# ip l set $INTERFACE down

Works for me big_smile

timfayz wrote:

- how netctl start PROFILE and systemctl start dhcpcd@enp0s25.service are related to each other

They are not related and are completely separate .services

netctl uses `systemctl` to enable the needed .services but abstracts this away from the user (surprisingly, considering it is an Arch-native tool).

I agree that this can be confusing but you should *only* use the `netctl` command to manage the connections.

For automatic switchover between wired & wireless, I would recommend either dhcpcd.service (the non-interface-specific version) with the wpa_supplicant hook added or systemd-networkd using the dhcp RouteMetric to handle the switch, as outlined here:
https://wiki.archlinux.org/index.php/Sy … me_machine


Jin, Jîyan, Azadî

Offline

#4 2016-02-08 10:25:47

timfayz
Member
From: Kazan, Russia
Registered: 2016-01-14
Posts: 59
Website

Re: How to manage automatic wire/wireless connection?

graysky wrote:

Systemd-networkd can do it.  Seethe wiki.

Please could you be more descriptive. Messages like this give no clue to how things work sad.
The next question how systemd-networkd and netctl tools are related to each other?

Offline

#5 2016-02-08 10:28:45

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,999
Website

Re: How to manage automatic wire/wireless connection?

timfayz wrote:

how systemd-networkd and netctl tools are related to each other?

They're not.

They are completely separate tools.


Jin, Jîyan, Azadî

Offline

#6 2016-02-08 10:34:41

timfayz
Member
From: Kazan, Russia
Registered: 2016-01-14
Posts: 59
Website

Re: How to manage automatic wire/wireless connection?

Head_on_a_Stick wrote:

I agree that this can be confusing but you should *only* use the `netctl` command to manage the connections.

For automatic switchover between wired & wireless, I would recommend either dhcpcd.service (the non-interface-specific version) with the wpa_supplicant hook added or systemd-networkd using the dhcp RouteMetric to handle the switch, as outlined here:
https://wiki.archlinux.org/index.php/Sy … me_machine

So I didn't get the idea. It seems they have very similar purpose. May be I can stick with one tool? For example, use only systemd-networkd service to manage wire/wireless connections? Previously, you said
> you should *only* use the `netctl`... to manage the connections.
But then recommend to use `systemd-networkd using the dhcp RouteMetric to handle the switch`.

Offline

#7 2016-02-08 10:37:40

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,999
Website

Re: How to manage automatic wire/wireless connection?

timfayz wrote:

May be I can stick with one tool? For example, use only systemd-networkd service to manage wire/wireless connections? Previously, you said
> you should *only* use the `netctl`... to manage the connections.
But then recommend to use `systemd-networkd using the dhcp RouteMetric to handle the switch`.

Yes, sorry, now I am being unclear big_smile

I meant that *if* you use netctl to manage your connections then you shoud not attempt to use `systemctl` to control the netctl-related .services directly.

Personally, I prefer to use systemd-networkd because of the lack of abstraction.


Jin, Jîyan, Azadî

Offline

#8 2016-02-08 10:41:54

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,448

Re: How to manage automatic wire/wireless connection?

netctl is a network-manager that works with systemd (but it is not the part of systemd)
systemd-networkd is a systemd component that can manage network connections. So you can use either of it.

Dhcpcd is dhcp client for dynamic ip address resolution, it can work directly on ethernet interface if password is not required. Netctl uses dhcpcd for connecting to ethernet. (as far as I understand, I may be wrong also)

Offline

#9 2016-02-08 10:44:45

timfayz
Member
From: Kazan, Russia
Registered: 2016-01-14
Posts: 59
Website

Re: How to manage automatic wire/wireless connection?

So can I use *only* systemd-networkd and leave the netctl?
My brain become overwhelmed when there are too many tools do the same thing and no one (especially wiki pages) do not recommend what to chose/stick with leaving newbies on their own smile

Offline

#10 2016-02-08 10:46:37

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,999
Website

Re: How to manage automatic wire/wireless connection?

timfayz wrote:

So can I use *only* systemd-networkd and leave the netctl?

That is your decision, both tools should work but I don't have much experience with netctl

If you wait a bit, I'm sure other users will disagree with me.

timfayz wrote:

My brain become overwhelmed when there are too many tools do the same thing and no one (especially wiki pages) do not recommend what to chose/stick with leaving newbies on their own smile

Welcome to Arch, isn't it epic?
smile


Jin, Jîyan, Azadî

Offline

#11 2016-02-08 11:12:54

timfayz
Member
From: Kazan, Russia
Registered: 2016-01-14
Posts: 59
Website

Re: How to manage automatic wire/wireless connection?

Head_on_a_Stick wrote:

That is your decision, both tools should work but I don't have much experience with netctl

Ok, let's assume I stick with systemd-networkd. Do I need to: `disable dhcpcd@interface.service` prior to `systemctl start systemd-networkd`? What about netctl? Do I need to "disable" something relating to netctl?
I also didn't figure out what the service responsible for automatic connections of my wifi interface.

Head_on_a_Stick wrote:

Welcome to Arch, isn't it epic?
smile

If "epic" means "next to fail" then maybe...I think so:) If you mean "unusually large, powerful or wonderful" - absolutely not. There are too much mess, tons of command (interchangeably) related to each other, each (even bundled or "built-in" commands) have its own ideology, too mach different syntaxes and config files. I think this is why Plan 9 was created, but it was too late:(

Last edited by timfayz (2016-02-08 11:14:29)

Offline

#12 2016-02-08 11:22:48

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,999
Website

Re: How to manage automatic wire/wireless connection?

timfayz wrote:

Ok, let's assume I stick with systemd-networkd. Do I need to: `disable dhcpcd@interface.service` prior to `systemctl start systemd-networkd`? What about netctl? Do I need to "disable" something relating to netctl?

Yes, you should disable all other networking programs and .services

You should only have one networking program active for each interface to prevent conflicts.

Check for enabled .services (and .sockets & .targets) with:

systectl list-unit-files|grep enabled

For example, I use systemd-networkd for both wired and wireless and I have this output:

empty@Arch ~ % systemctl list-unit-files|grep enabled
autovt@.service                            enabled 
dbus-org.freedesktop.network1.service      enabled 
dbus-org.freedesktop.resolve1.service      enabled 
getty@.service                             enabled 
nftables.service                           enabled 
systemd-networkd.service                   enabled 
systemd-resolved.service                   enabled 
wpa_supplicant@.service                    enabled 
systemd-networkd.socket                    enabled 
default.target                             enabled 
multi-user.target                          enabled 
fstrim.timer                               enabled 

The wpa_supplicant@.service is needed to authenticate the wireless connection but no other networking .services are enabled wink

timfayz wrote:

If you mean "unusually large, powerful or wonderful" - absolutely not. There are too much mess, tons of command (interchangeably) related to each other, each (even bundled or "built-in" commands) have its own ideology, too mach different syntaxes and config files.

Perhaps you should switch to Ubuntu instead...
tongue


Jin, Jîyan, Azadî

Offline

#13 2016-02-08 11:28:50

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

Re: How to manage automatic wire/wireless connection?

timfayz wrote:
graysky wrote:

Systemd-networkd can do it.  Seethe wiki.

Please could you be more descriptive. Messages like this give no clue to how things work sad.
The next question how systemd-networkd and netctl tools are related to each other?

Typing from my phone. Our wiki is really good and the tool I mentioned can do what you asked.  I tried with netctl a while ago and could not get a reliable switch over.  Search on my name and wireless to find those threads if you are so inclined.

Offline

#14 2016-02-08 11:36:11

timfayz
Member
From: Kazan, Russia
Registered: 2016-01-14
Posts: 59
Website

Re: How to manage automatic wire/wireless connection?

Head_on_a_Stick wrote:

Yes, you should disable all other networking programs and .services

Good, I will try!

Head_on_a_Stick wrote:

Perhaps you should switch to Ubuntu instead...:P

It's not about Arch or Ubuntu or whatever (BTW, I moved from Ubuntu smile, because I have no idea what's going on under the hood). It's about Linux world as a whole smile I know, this is just how things was done historically and there is absolutely no one to blame.

graysky wrote:

Typing from my phone. Our wiki is really good and the tool I mentioned can do what you asked.  I tried with netctl a while ago and could not get a reliable switch over.  Search on my name and wireless to find those threads if you are so inclined.

Got it, thank you!

Last edited by timfayz (2016-02-08 11:36:45)

Offline

#15 2016-02-08 12:48:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: How to manage automatic wire/wireless connection?

timfayz wrote:

... but it seems to me they're a little over-complicated due to too many ways/tools of doing the same.

I completely agree.  I feel pretty confident in my ability to help people diagnose, understand, and fix network-connection related issues.  But lately all such threads start with struggles with all these tools that I've never used.  When someone post struggling with wifi-radar, wifi-menu, netctl, etc etc, I first have to look up that tool to figure out what it's really doing and where the problem may lie.  And generally I just give up, as many of these tools just seem absurdly complex ways of doing something that is just as absurdly simple.

When I put my own tastes for stark minimalism and CLI only tools, I can appreciate the goals of something like Network Manager with it's various gui "applets".  This is a complex tool, but it does provide a lot more than the simple tools.  But netctl and some of the other cli methods just seem to add enormous complexity without actually adding any features (sorry if this is just my ignorance of them, but I'm a reasonably capable person and I just can't see what these tools are supposed to be adding).

So I just use dhcpcd@.service.  That's it.  I couldn't imagine it possibly being easier - and all these other tools add complexity to only make it harder.

As of a recent update I had to add the wpa_supplicant hook to dhcpcd which had previously been active by default, but otherwise it "Just Works".


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#16 2016-02-08 15:17:36

timfayz
Member
From: Kazan, Russia
Registered: 2016-01-14
Posts: 59
Website

Re: How to manage automatic wire/wireless connection?

Head_on_a_Stick wrote:

Yes, you should disable all other networking programs and .services
You should only have one networking program active for each interface to prevent conflicts.

It is a noob question, but do I need to reboot after disabling services? For example, I expect when I did systemctl disable dhcpcd@interface.service and systemctl disable netctl@wlp10s0b1\x2dHangglide.service the interfaces should be inactive (like if I do: ip link interface down), but the networks are still work. What is the trick? Or services do nothing when I disable them.

Trilby wrote:

So I just use dhcpcd@.service.  That's it.  I couldn't imagine it possibly being easier - and all these other tools add complexity to only make it harder.

It would be great if so! smile But, please, could you give a simple example (I know there is a whole wiki page about it) how to configure simple dhcp wire connection?

Offline

#17 2016-02-08 15:22:13

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,999
Website

Re: How to manage automatic wire/wireless connection?

timfayz wrote:

It is a noob question, but do I need to reboot after disabling services?

Not if you use:

# systemctl disable foo.service --now

wink

EDIT: Do yourself a favour and read `man systemctl`

Last edited by Head_on_a_Stick (2016-02-08 15:23:06)


Jin, Jîyan, Azadî

Offline

#18 2016-02-08 16:35:33

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: How to manage automatic wire/wireless connection?

timfayz wrote:

It would be great if so! smile But, please, could you give a simple example (I know there is a whole wiki page about it) how to configure simple dhcp wire connection?

I already gave the example, that's it.  For a wired connection there is really absolutely nothing else required:

systemctl enable dhcpcd@enp0s25

I ran that once and never have to think about it again (enp0s25 is my interface name, get yours from `ip a` output).

For wireless you just also need to make sure you have proper entries in wpa_supplicant.conf (even for "open" networks, just use key_mgmt=NONE).  And as of a recent update to dhcpcd, you'd also need to add the wpa_supplicant hook from /usr/share/dhcpcd/hooks to /usr/lib/dhcpcd/dhcpcd-hooks.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#19 2016-02-08 16:46:03

timfayz
Member
From: Kazan, Russia
Registered: 2016-01-14
Posts: 59
Website

Re: How to manage automatic wire/wireless connection?

Hm...that's intersting!  Big thank you! smile And there are 2 consequential questions:
- What is the most "low level" tool to configure my network interfaces? ip command?
- Do the dhcpcd, systemd-networkd and netctl use in any ways the ip command underneath (hence iproute2 package)?

Offline

#20 2016-02-08 18:06:08

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: How to manage automatic wire/wireless connection?

Well, the most low level would be a charged pin, a good magnifying glass, and a very steady hand.  The most low level that remains practical is most likely dhcpcd for wired and dhcpcd + wpa_supplicant for wireless.  And these can be automated with their respective systemd service files.

I would not get rid of iproute2 as it has many useful utilites, but as far as I know dhcpcd does not depend on it.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#21 2016-02-08 18:20:44

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,999
Website

Re: How to manage automatic wire/wireless connection?

Trilby wrote:

Well, the most low level would be a charged pin, a good magnifying glass, and a very steady hand

I can tell you're not an EMACS user lol

@OP: You can use ip(8) to assign the addresses manually and do without dhcpcd (or any other dhcp client) if you want your system as slim as possible.

See https://github.com/Head-on-a-Stick/conf … 40.service for an example (that is for wireless but the ip(8) lines would be the same for an ethernet connection) wink


Jin, Jîyan, Azadî

Offline

#22 2016-02-08 18:43:56

timfayz
Member
From: Kazan, Russia
Registered: 2016-01-14
Posts: 59
Website

Re: How to manage automatic wire/wireless connection?

No, I'm Vim user big_smile. Thank you for explanations, guys - it becomes a little clearer now..

Offline

Board footer

Powered by FluxBB