Difference between revisions of "Talk:Netctl"

From ArchWiki
Jump to: navigation, search
(Altering a currently enabled profile: reenable command readded)
(DHCP clients: new section)
 
(40 intermediate revisions by 14 users not shown)
Line 1: Line 1:
== Altering a currently enabled profile ==
+
== Ifplugd.conf interface name ==
  
Concerning this note:
+
Under the configuration section, there is a note stating that the interface name most probably needs to be changed in the netctl profile because of udev naming rules. When using ifplugd to automatically manage wired profile switching, there is another place to check the interface name. {{ic|/etc/ifplugd/ifplugd.conf}} contains the line:
{{Note|
+
* If there is ever a need to alter a currently enabled profile, execute {{ic|netctl reenable <profile>}} to apply the changes.
+
* ''interface'' is hardware minus, e.g netctl-auto@wlan0.service or netctl-auto@enp2s0.service
+
}}
+
I find the second line in this note confusing, and the first line may be unnecessary. I found myself having to reboot my system to get any wireless profile changes to take effect. Through trial and error, I finally figured out the command {{ic|systemctl restart netctl-auto@<interface>.service}} allows the changes to take effect without requiring a reboot. Further, it appears that the command {{ic|netctl reenable <profile>}} is not necessary to achieve these results; although, some profile modifications did require that I issue the {{ic|systemctl restart netctl-auto@<interface>.service}} command twice before my wireless Internet connection would come back up. Has anyone else observed this?
+
[[User:Mc33|Mc33]] ([[User talk:Mc33|talk]]) 04:59, 17 July 2013 (UTC)
+
  
: From netctl(1):
+
{{ic|1=INTERFACES="eth0"}}
:{{bc|<nowiki>reenable [PROFILE]
+
    Reenable the systemd unit for the profile specified. This is effectively a combination of ‘disable’ and ‘enable’.</nowiki>}}
+
: So I'd say the first line of the note is absolutely incorrect. I think your command {{ic|systemctl restart netctl-auto@<interface>.service}} should be listed instead, and we should probably add simple {{ic|netctl restart <profile>}} too in case people don't use {{ic|netctl-auto@.service}}. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 07:45, 17 July 2013 (UTC)
+
  
::On the contrary, the {{ic|reenable}} command is correct. But it applies to specific profiles, not to {{ic|netctl-auto}}. [[User:Halosghost|Halosghost]] ([[User talk:Halosghost|talk]]) 12:32, 17 July 2013 (UTC)
+
The interface should match the one used in the profile or ifplugd won't monitor the correct interface. You can include a space separated list of interfaces to monitor if more than one NIC is present.  This info is in the man page for ifplugd, and in the ifplugd.conf file, is it worth adding here as well?
  
::: Right, it does not apply to {{ic|netctl-auto}}, my mistake... But my point is, that it does not manipulate currently running processes, it only deletes & re-creates some symlink. To actually apply changes to some profile, you need to {{ic|netctl restart <profile>}}. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 13:05, 17 July 2013 (UTC)
+
[[User:Erbrecht|Erbrecht]] ([[User talk:Erbrecht|talk]]) 15:50, 10 January 2014 (UTC)
  
::::I've re-added the ''reenable'' command: [https://wiki.archlinux.org/index.php?title=Netctl&diff=275702&oldid=275546] -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 18:18, 15 September 2013 (UTC)
+
:I think it's worth adding it, maybe you can be more concise and point to the man pages for details on syntax and everything else. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 02:36, 11 January 2014 (UTC)
  
: Regarding the second line, I have absolutely no idea of what does ''interface is hardware minus'' mean... -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 07:45, 17 July 2013 (UTC)
+
== Hooks and interfaces explanations ==
  
:I've removed the note as it's not related to that section, it's confusing etc. If someone wants it, feel free to expand and clarify it and put it back. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 16:49, 25 July 2013 (UTC)
+
I am looking for documentation on using {{ic|/etc/netctl/hooks}} and {{ic|/etc/netctl/interfaces}} but this wiki and the netctl man pages don't explain the format of the scripts well. I couldn't find a great resource through google. I think an example of running scripts when a profile comes up or down would be good. {{unsigned|07:06, 20 January 2014|Seniorsassycat}}
  
== My working eduroam config (with TimeoutDHCP and anonymous identity) ==
+
:Not to give you the RTFM, but the netctl man page explains it pretty well. Interfaces at least are actually pretty simple, but I'm not sure about other hooks. Still, it might be worth adding a short section explaining the basics of creating hooks. As for running a script, you could probably use a systemd unit with {{ic|1=WantedBy=network.target}} and {{ic|1=Before=netctl@yourprofile.service}}/{{ic|1=After=netctl@yourprofile.service}}. [[User:EscapedNull|EscapedNull]] ([[User talk:EscapedNull|talk]]) 22:22, 20 January 2014 (UTC)
  
 +
:: I have RTFM and i see no explanation 'Variables available in scripts' or 'actions'. [[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 12:50, 26 December 2014‎ (UTC)
  
Description='eduroam for <your username>'
+
:I have gone through the source and these variables only appear in /usr/lib/network/auto.action. This file is only used by netctl-auto. So these variables are not available for scripts...
Interface=wlp2s0
+
:They don't even need to be to do everything you wan t[[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 07:48, 27 December 2014 (UTC)
Connection=wireless
+
Security=wpa-configsection
+
TimeoutDHCP=60
+
IP=dhcp
+
WPAConfigSection=(
+
        'ssid="eduroam"'
+
        'proto=RSN'
+
        'key_mgmt=WPA-EAP'
+
        'pairwise=CCMP'
+
        'auth_alg=OPEN'
+
        'eap=TTLS'
+
        'identity="<your username>@tu-chemnitz.de"'
+
        'password="<your password>"'
+
        'anonymous_identity="anonymous@tu-chemnitz.de"'
+
        'priority=2'
+
        'phase2="auth=PAP"'
+
)
+
  
This /etc/netctl/eduroam works for me. Maybe someone should update the main article?! Thank you!
+
== Profile Names ==
  
: I'd certainly not replace the current config in [[netctl#Eduroam]]. I have another, different config, but several people had trouble with connecting in Prague using my profile, so I think it's very specific. Perhaps separate page would be better, when there are more configs. But more information would be needed, the page can't be just set of different configs... -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 07:55, 14 August 2013 (UTC)
+
Perhaps I am missing something as I have been fighting networking stuff for at least 2 weeks. (Not all netctl, I'm glad to say.) But the eduroam profiles given here seem to be inconsistent with the advice not to name profiles with strings which include hyphens. Am I missing something? (By the way, it would be handy to know what *is* safe. Presumably [a-z], probably [A-Z0-9]. Anything else?) --[[User:Margali|cfr]] ([[User talk:Margali|talk]]) 03:56, 3 March 2014 (UTC)
  
== What is the first command used to set up netctl? ==
+
:''Everything'' is safe to use, hyphens are just more prone to PEBKAC errors. When you use directly ''netctl'' to manage profiles (i.e. you run {{ic|netctl enable ''profile''}} instead of {{ic|systemctl enable netctl@''profile''}}), nothing bad will ever happen even when there is a hyphen in the profile name.
 +
:Yes, the hyphens are encoded into {{ic|\x2d}} when the symlink in {{ic|/etc/systemd/system/}} is created, but there is nothing more than that. Searching the [https://bbs.archlinux.org/viewtopic.php?pid=1311864/ forums thread] mentioned in the note on this page, several other threads and relevant man pages, the only reference to hyphens being really ''special'' is in path units, where they substitute {{ic|/}}, which obviously can't be used in file name. Especially there are no "connection drop issues" because of hyphens.
 +
:-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 07:25, 3 March 2014 (UTC)
  
"''Once you have created your profile, make an attempt to establish a connection using the newly created profile by running:''"
+
== Wireless/Wired failover dependency management. ==
    '''# netctl start profile'''
+
  
Shouldn't the command be enable? From the man page:
+
When I set up wireless failover, I needed to create a custom dependency to avoid the "already up" problem.  Thought I would share:
  
  start [PROFILE]
+
/etc/systemd/system/netctl@failover.service.d/dependencies.conf
          Start the network profile specified on the command line.
+
  
  enable [PROFILE]
+
    [Unit]
          Enable the systemd unit for the profile specified. This will create
+
    Wants=dhcpcd@bond0.service
          a unit configuration file. If the file already exists, the command
+
    Wants=wpa_supplicant@wlan0.service
          fails. No other profiles than the one specified will be enabled.
+
    Before=dhcpcd@bond0.service
          Changes to the general options in a profile specification will not
+
    Before=wpa_supplicant@wlan0.service
          propagate to the unit configuration file automatically. After such
+
          changes, it is necessary to ‘reenable’ the profile.
+
  
[[User:Xtian|Xtian]] ([[User talk:Xtian|talk]]) 15:49, 15 September 2013 (UTC)
+
This made sure that the interfaces were bonded and up before anything else attempted to use the device; isolates this dependency to the failover (so other profiles *may* work) profile and allows the AP association to happen before DHCPCd times out.
 +
{{unsigned|16:55, 5 November 2014|Greyson}}
  
:The command is correct, you can start disabled profile. Disabled means just that it will not start automatically at boot. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 18:11, 15 September 2013 (UTC)
+
:: Yes,this is a problem that I also had, when starting the bond just with the wireless interface up. I've been studying a solution to this problem, and yours, while being correct, is parcial. If there isn't any dhcp server on the wireless network, it will timeout anyway. I played a while, and I believe the solution is to set the dhcpcd timeout to zero and, instead of having netctl calling it, create a different systemd service for the bond0 interface, so if it dies for any reason, systemd will restart it. I haven't had the time to test this solution, if you can test, please share here so we can change the wiki page.
 +
:: [[User:Grazzolini|Grazzolini]] ([[User talk:Grazzolini|talk]]) 17:05, 5 November 2014 (UTC)
 +
 
 +
== Conceptual understanding ==
 +
 
 +
The fact that netctl is written in bash is extremely important in order to understand how everything works. For example, it
 +
directly explains the syntax of profiles, hooks, and interfaces. The fact that setting options is equivalent to declaring a bash variable
 +
allowed me to understand what was going on. Before that, i was lost in confusion. I believe this knowledge should be made more explicit as
 +
it cleared a lot of things up for me.
 +
 
 +
Can it be added somewhere on this page? [[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 07:58, 27 December 2014 (UTC)
 +
 
 +
:Sure. If you want to add a general sentence: the [[netctl#Usage]] section historically links to Jouke's github already, you could add a sentence under the links to the manpages. That should be phrased like "If interested, browse the source code in the repository." or something though.
 +
:If you want to add something specific for the hook section, why not crosslink in your latest edit to [https://github.com/joukewitteveen/netctl/blob/master/src/lib/auto.action]. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 09:48, 27 December 2014 (UTC)
 +
 
 +
== Explain WPAConfigSection ==
 +
 
 +
It would be nice if there were an additional example using {{ic|1=Security=wpa-configsection}} that explained each line in the example ({{ic|/etc/netctl/examples/wireless-wpa-configsection}}). I'd imagine I'm not the first person discouraged from using netctl-auto because of this. -- [[User:RyneEverett|Ryne Everett]] ([[User talk:RyneEverett|talk]]) 16:28, 21 June 2015 (UTC)
 +
 
 +
:As stated in the [https://projects.archlinux.org/netctl.git/tree/docs/netctl.profile.5.txt#n281 netctl.profile(5)] man page, the {{ic|WPAConfigSection}} variable is an array of config lines passed to [[wpa_supplicant]]. See [http://w1.fi/cgit/hostap/plain/wpa_supplicant/wpa_supplicant.conf example wpa_supplicant.conf] (shipped with the Arch package at {{ic|/etc/wpa_supplicant/wpa_supplicant.conf}}) for detailed explanation. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 19:20, 21 June 2015 (UTC)
 +
 
 +
::Thanks, I wouldn't have guessed that would be the file to explain those values. If/When I figure it out I may add an additional example section explaining just the required values. (Surely all 10 in the example aren't required?) This is too common of a need (required for netctl-auto) to require so much studying. -- [[User:RyneEverett|Ryne Everett]] ([[User talk:RyneEverett|talk]]) 19:38, 21 June 2015 (UTC)
 +
 
 +
:::Remember that you are configuring ''wpa_supplicant'', not ''netctl'', so the info belongs to [[WPA supplicant]] (it may already be there). -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 20:27, 21 June 2015 (UTC)
 +
 
 +
== DHCP clients ==
 +
 
 +
I had the problem described under "Job for netctl@wlan(...).service failed", and changing my netctl profiles to use dhclient solved it. My {{ic|/etc/dhcpcd.conf}} was unchanged from the version in the package, and my {{ic|/etc/dhclient.conf}} was based on {{ic|/usr/share/dhclient/dhclient.conf.example}} from the dhclient client package. These request different options from the DHCP server:
 +
{{hc|/etc/dhcpcd.conf|
 +
...
 +
# Rapid commit support.
 +
# Safe to enable by default because it requires the equivalent option set
 +
# on the server to actually work.
 +
option rapid_commit
 +
 
 +
# A list of options to request from the DHCP server.
 +
option domain_name_servers, domain_name, domain_search, host_name
 +
option classless_static_routes
 +
# Most distributions have NTP support.
 +
option ntp_servers
 +
# Respect the network MTU. This is applied to DHCP routes.
 +
option interface_mtu
 +
 
 +
# A ServerID is required by RFC2131.
 +
require dhcp_server_identifier}}
 +
and
 +
{{hc|/etc/dhclient.conf|
 +
...
 +
request subnet-mask, broadcast-address, time-offset, routers,
 +
domain-name, domain-name-servers, host-name;
 +
require subnet-mask, domain-name-servers;}}
 +
I removed {{ic|1=DHCPClient='dhclient'}} from my netctl profiles, and made dhcpcd request the extra options by adding
 +
{{bc|option subnet_mask, broadcast_address, time_offset, routers}}
 +
to {{ic|/etc/dhcpcd.conf}}, and netctl works O.K. with dhcpcd as the DHCP client.
 +
 
 +
I don't know why requesting the extra options should make a difference, and I haven't tried any tests to see which of them are necessary.--[[User:Pdc|Pdc]] ([[User talk:Pdc|talk]]) 19:41, 25 August 2015 (UTC)

Latest revision as of 19:41, 25 August 2015

Ifplugd.conf interface name

Under the configuration section, there is a note stating that the interface name most probably needs to be changed in the netctl profile because of udev naming rules. When using ifplugd to automatically manage wired profile switching, there is another place to check the interface name. /etc/ifplugd/ifplugd.conf contains the line:

INTERFACES="eth0"

The interface should match the one used in the profile or ifplugd won't monitor the correct interface. You can include a space separated list of interfaces to monitor if more than one NIC is present. This info is in the man page for ifplugd, and in the ifplugd.conf file, is it worth adding here as well?

Erbrecht (talk) 15:50, 10 January 2014 (UTC)

I think it's worth adding it, maybe you can be more concise and point to the man pages for details on syntax and everything else. -- Kynikos (talk) 02:36, 11 January 2014 (UTC)

Hooks and interfaces explanations

I am looking for documentation on using /etc/netctl/hooks and /etc/netctl/interfaces but this wiki and the netctl man pages don't explain the format of the scripts well. I couldn't find a great resource through google. I think an example of running scripts when a profile comes up or down would be good. —This unsigned comment is by Seniorsassycat (talk) 07:06, 20 January 2014. Please sign your posts with ~~~~!

Not to give you the RTFM, but the netctl man page explains it pretty well. Interfaces at least are actually pretty simple, but I'm not sure about other hooks. Still, it might be worth adding a short section explaining the basics of creating hooks. As for running a script, you could probably use a systemd unit with WantedBy=network.target and Before=netctl@yourprofile.service/After=netctl@yourprofile.service. EscapedNull (talk) 22:22, 20 January 2014 (UTC)
I have RTFM and i see no explanation 'Variables available in scripts' or 'actions'. Captaincurrie (talk) 12:50, 26 December 2014‎ (UTC)
I have gone through the source and these variables only appear in /usr/lib/network/auto.action. This file is only used by netctl-auto. So these variables are not available for scripts...
They don't even need to be to do everything you wan tCaptaincurrie (talk) 07:48, 27 December 2014 (UTC)

Profile Names

Perhaps I am missing something as I have been fighting networking stuff for at least 2 weeks. (Not all netctl, I'm glad to say.) But the eduroam profiles given here seem to be inconsistent with the advice not to name profiles with strings which include hyphens. Am I missing something? (By the way, it would be handy to know what *is* safe. Presumably [a-z], probably [A-Z0-9]. Anything else?) --cfr (talk) 03:56, 3 March 2014 (UTC)

Everything is safe to use, hyphens are just more prone to PEBKAC errors. When you use directly netctl to manage profiles (i.e. you run netctl enable profile instead of systemctl enable netctl@profile), nothing bad will ever happen even when there is a hyphen in the profile name.
Yes, the hyphens are encoded into \x2d when the symlink in /etc/systemd/system/ is created, but there is nothing more than that. Searching the forums thread mentioned in the note on this page, several other threads and relevant man pages, the only reference to hyphens being really special is in path units, where they substitute /, which obviously can't be used in file name. Especially there are no "connection drop issues" because of hyphens.
-- Lahwaacz (talk) 07:25, 3 March 2014 (UTC)

Wireless/Wired failover dependency management.

When I set up wireless failover, I needed to create a custom dependency to avoid the "already up" problem. Thought I would share:

/etc/systemd/system/netctl@failover.service.d/dependencies.conf

   [Unit]
   Wants=dhcpcd@bond0.service
   Wants=wpa_supplicant@wlan0.service
   Before=dhcpcd@bond0.service
   Before=wpa_supplicant@wlan0.service

This made sure that the interfaces were bonded and up before anything else attempted to use the device; isolates this dependency to the failover (so other profiles *may* work) profile and allows the AP association to happen before DHCPCd times out. —This unsigned comment is by Greyson (talk) 16:55, 5 November 2014. Please sign your posts with ~~~~!

Yes,this is a problem that I also had, when starting the bond just with the wireless interface up. I've been studying a solution to this problem, and yours, while being correct, is parcial. If there isn't any dhcp server on the wireless network, it will timeout anyway. I played a while, and I believe the solution is to set the dhcpcd timeout to zero and, instead of having netctl calling it, create a different systemd service for the bond0 interface, so if it dies for any reason, systemd will restart it. I haven't had the time to test this solution, if you can test, please share here so we can change the wiki page.
Grazzolini (talk) 17:05, 5 November 2014 (UTC)

Conceptual understanding

The fact that netctl is written in bash is extremely important in order to understand how everything works. For example, it directly explains the syntax of profiles, hooks, and interfaces. The fact that setting options is equivalent to declaring a bash variable allowed me to understand what was going on. Before that, i was lost in confusion. I believe this knowledge should be made more explicit as it cleared a lot of things up for me.

Can it be added somewhere on this page? Captaincurrie (talk) 07:58, 27 December 2014 (UTC)

Sure. If you want to add a general sentence: the netctl#Usage section historically links to Jouke's github already, you could add a sentence under the links to the manpages. That should be phrased like "If interested, browse the source code in the repository." or something though.
If you want to add something specific for the hook section, why not crosslink in your latest edit to [1]. --Indigo (talk) 09:48, 27 December 2014 (UTC)

Explain WPAConfigSection

It would be nice if there were an additional example using Security=wpa-configsection that explained each line in the example (/etc/netctl/examples/wireless-wpa-configsection). I'd imagine I'm not the first person discouraged from using netctl-auto because of this. -- Ryne Everett (talk) 16:28, 21 June 2015 (UTC)

As stated in the netctl.profile(5) man page, the WPAConfigSection variable is an array of config lines passed to wpa_supplicant. See example wpa_supplicant.conf (shipped with the Arch package at /etc/wpa_supplicant/wpa_supplicant.conf) for detailed explanation. -- Lahwaacz (talk) 19:20, 21 June 2015 (UTC)
Thanks, I wouldn't have guessed that would be the file to explain those values. If/When I figure it out I may add an additional example section explaining just the required values. (Surely all 10 in the example aren't required?) This is too common of a need (required for netctl-auto) to require so much studying. -- Ryne Everett (talk) 19:38, 21 June 2015 (UTC)
Remember that you are configuring wpa_supplicant, not netctl, so the info belongs to WPA supplicant (it may already be there). -- Lahwaacz (talk) 20:27, 21 June 2015 (UTC)

DHCP clients

I had the problem described under "Job for netctl@wlan(...).service failed", and changing my netctl profiles to use dhclient solved it. My /etc/dhcpcd.conf was unchanged from the version in the package, and my /etc/dhclient.conf was based on /usr/share/dhclient/dhclient.conf.example from the dhclient client package. These request different options from the DHCP server:

/etc/dhcpcd.conf
...
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

and

/etc/dhclient.conf
...
request subnet-mask, broadcast-address, time-offset, routers,
	domain-name, domain-name-servers, host-name;
require subnet-mask, domain-name-servers;

I removed DHCPClient='dhclient' from my netctl profiles, and made dhcpcd request the extra options by adding

option subnet_mask, broadcast_address, time_offset, routers

to /etc/dhcpcd.conf, and netctl works O.K. with dhcpcd as the DHCP client.

I don't know why requesting the extra options should make a difference, and I haven't tried any tests to see which of them are necessary.--Pdc (talk) 19:41, 25 August 2015 (UTC)