https://wiki.archlinux.org/api.php?action=feedcontributions&user=PythonPizza&feedformat=atomArchWiki - User contributions [en]2024-03-29T15:35:24ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=User:PythonPizza&diff=727421User:PythonPizza2022-04-24T10:53:12Z<p>PythonPizza: </p>
<hr />
<div>== PythonPizza ==<br />
I wanna use this site to practice writing in this "wiki language".<br />
=== Profile ===<br />
* Timezone: Europe/Stockholm<br />
* languages: German and English<br />
* other: I use Arch btw.</div>PythonPizzahttps://wiki.archlinux.org/index.php?title=User:PythonPizza&diff=727414User:PythonPizza2022-04-24T10:10:34Z<p>PythonPizza: Created page with "== PythonPizza == I wanna use this site to practice writing in this "wiki language". === Profile === * Timezone: Europe/Stockholm * other: I use Arch btw."</p>
<hr />
<div>== PythonPizza ==<br />
I wanna use this site to practice writing in this "wiki language".<br />
=== Profile ===<br />
* Timezone: Europe/Stockholm<br />
* other: I use Arch btw.</div>PythonPizzahttps://wiki.archlinux.org/index.php?title=Netctl&diff=727412Netctl2022-04-24T10:03:19Z<p>PythonPizza: added tip becaus it helped me</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Network managers]]<br />
[[Category:Arch projects]]<br />
[[Category:Commands]]<br />
[[de:Netctl]]<br />
[[fr:Netctl]]<br />
[[ja:Netctl]]<br />
[[zh-hans:Netctl]]<br />
{{Related articles start}}<br />
{{Related|Bridge with netctl}}<br />
{{Related|Network configuration}}<br />
{{Related|Wireless network configuration}}<br />
{{Related articles end}}<br />
[https://gitlab.archlinux.org/archlinux/netctl netctl] is a CLI and profile-based network manager and an Arch project.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|netctl}} package.<br />
<br />
''netctl's'' [[#Special systemd units]] used in automating connections require some additional dependencies; see that section for more information.<br />
<br />
Other optional dependencies are shown in the table below.<br />
<br />
{| class="wikitable"<br />
! Feature<br />
! Dependency<br />
|-<br />
| WPA || {{Pkg|wpa_supplicant}}<br />
|-<br />
| DHCP || {{Pkg|dhcpcd}} or {{Pkg|dhclient}}<br />
|-<br />
| ''wifi-menu'' || {{Pkg|dialog}}<br />
|-<br />
| PPPoE || {{Pkg|ppp}}<br />
|-<br />
|}<br />
<br />
{{Warning|Do not enable concurrent, conflicting network services. Use {{ic|1=systemctl --type=service}} to ensure that no other network service is running before enabling a ''netctl'' profile/service.}}<br />
{{Tip|<br />
* If connecting to wifi doesn't work, try installing {{Pkg|dhcpcd}} '''and''' {{Pkg|dhclient}}<br />
}}<br />
<br />
== Configuration ==<br />
<br />
''netctl'' uses profiles to manage network connections and different modes of operation to start profiles automatically or manually on demand. <br />
<br />
The ''netctl'' profile files are stored in {{ic|/etc/netctl/}} and example configuration files are available in {{ic|/etc/netctl/examples/}}. <br />
<br />
To use an example profile, simply copy it from {{ic|/etc/netctl/examples/}} to {{ic|/etc/netctl/}} and configure it to your needs; see basic [[#Example profiles]] below. The first parameter you need to create a profile is the network {{ic|Interface}}, see [[Network configuration#Network interfaces]] for details.<br />
<br />
{{Tip|<br />
* For wireless settings, you can use {{ic|wifi-menu}} as root to generate the profile file in {{ic|/etc/netctl/}}. The {{pkg|dialog}} package is required to use ''wifi-menu''.<br />
* Use {{ic|1=SkipNoCarrier=yes}} in your profile to enable a static IP profile on a wired interface no matter if the cable is connected or not.<br />
}}<br />
<br />
See {{man|5|netctl.profile}} for a complete list of profile options.<br />
<br />
== Usage ==<br />
<br />
See {{man|1|netctl}} for a complete list of ''netctl'' commands.<br />
<br />
=== Starting a profile ===<br />
<br />
Once you have created your profile, attempt to establish a connection, where ''profile'' is only the profile name, not the full path:<br />
<br />
# netctl start ''profile''<br />
<br />
If the above command results in a failure, then run {{ic|journalctl -xn}} as root and {{ic|netctl status ''profile''}} to obtain a more in-depth explanation of the failure.<br />
<br />
=== Enabling a profile ===<br />
<br />
A profile can be enabled to start at boot by using:<br />
<br />
# netctl enable ''profile''<br />
<br />
This will create and enable a [[systemd]] service that will start when the computer boots. Changes to the profile file will not propagate to the service file automatically. After such changes, it is necessary to reenable the profile:<br />
<br />
# netctl reenable ''profile''<br />
<br />
After enabling a profile, it will be started at next boot. Obviously this can only be successful, if the network cable for a wired connection is plugged in, or the wireless access point used in a profile is in range respectively.<br />
<br />
If you need to switch multiple profiles frequently (i.e., traveling with a laptop), use [[#Special systemd units]] instead of enabling a profile.<br />
<br />
=== Special systemd units ===<br />
<br />
''netctl'' provides special [[systemd]] services for automatically switching of profiles for wired and wireless connections. See {{man|7|netctl.special}} for a complete list of special systemd units.<br />
<br />
==== Wired ====<br />
<br />
[[Install]] the {{Pkg|ifplugd}} package and [[start/enable]] the {{ic|netctl-ifplugd@''interface''.service}} systemd unit. DHCP profiles will be started/stopped when the network cable is plugged in/unplugged.<br />
* The {{ic|netctl-ifplugd@''interface''.service}} will prefer profiles that use [[Wikipedia:DHCP|DHCP]].<br />
* To automatically start a static IP profile the option {{ic|1=ExcludeAuto=no}} needs to be set in it.<br />
* To prioritize a profile with a static IP over DHCP profiles, you can set {{ic|1=Priority=2}}, which is higher than the default priority given to DHCP profiles of {{ic|1=Priority=1}}.<br />
<br />
==== Wireless ====<br />
<br />
[[Start/enable]] {{ic|netctl-auto@''interface''.service}} systemd unit. ''netctl'' profiles will be started/stopped automatically as you move from the range of one network into the range of another network (roaming).<br />
<br />
* Profiles must use {{ic|1=Security=wpa-configsection}} or {{ic|1=Security=wpa}} to work with ''netctl-auto'' rather than {{ic|1=Security=wpa-config}}.<br />
* If you want some wireless profile '''not''' to be started automatically by {{ic|netctl-auto@''interface''.service}}, you have to explicitly add {{ic|1=ExcludeAuto=yes}} to that profile. <br />
* You can use {{ic|1=priority=}} in the ''WPAConfigSection'' (see {{ic|/etc/netctl/examples/wireless-wpa-configsection}}) to set priority of a profile when multiple wireless access points are available. Larger numbers indicate a higher priority.<br />
<br />
Note that ''interface'' is not literal, but to be substituted by the name of your device's interface, e.g. {{ic|netctl-auto@wlp4s0.service}}. See {{ic|netctl.profile(5)}} for details.<br />
<br />
{{Note|<br />
* If any of the profiles contain errors, such as an empty or misquoted {{ic|1=Key=}} variable, the unit will fail to load with the message {{ic|"Failed to read or parse configuration '/run/network/wpa_supplicant_wlan0.conf'}}, even when that profile is not being used.<br />
* If you have previously [[#Enabling a profile|enabled a profile]] through ''netctl'', run {{ic|netctl disable ''profile''}} to prevent the profile from starting twice at boot.<br />
}}<br />
<br />
It is possible to manually control an interface otherwise managed by ''netctl-auto'' without having to stop {{ic|netctl-auto.service}}. This is done using the ''netctl-auto'' command. For a complete list of available actions see {{man|1|netctl-auto}}.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Example profiles ===<br />
<br />
==== Wired ====<br />
<br />
For a DHCP connection, only the {{ic|Interface}} has to be configured after copying the {{ic|/etc/netctl/examples/ethernet-dhcp}} example profile to {{ic|/etc/netctl}}. <br />
<br />
For example:<br />
{{hc|/etc/netctl/''my_dhcp_profile''|<nowiki><br />
Interface=enp1s0<br />
Connection=ethernet<br />
IP=dhcp</nowiki><br />
}}<br />
<br />
For a static IP configuration copy the {{ic|/etc/netctl/examples/ethernet-static}} example profile to {{ic|/etc/netctl}} and modify {{ic|Interface}}, {{ic|Address}}, {{ic|Gateway}} and {{ic|DNS}}) as needed. <br />
<br />
For example:<br />
{{hc|/etc/netctl/''my_static_profile''|<nowiki><br />
Interface=enp1s0<br />
Connection=ethernet<br />
IP=static<br />
Address=('10.1.10.2/24')<br />
Gateway='10.1.10.1'<br />
DNS=('10.1.10.1')</nowiki><br />
}}<br />
<br />
Take care to include the subnet notation of {{ic|/24}}. It equates to a netmask of {{ic|255.255.255.0}}) and without it the profile will fail to start. See also [[wikipedia:Classless Inter-Domain Routing#CIDR notation|CIDR notation]]. To alias more than one IP address per a NIC set {{ic|1=Address=('10.1.10.2/24' '192.168.1.2/24')}}.<br />
<br />
==== Wireless (WPA-PSK) ====<br />
<br />
The following applies for the standard wireless connections using a pre-shared key (WPA-PSK).<br />
<br />
{{hc|/etc/netctl/wireless-wpa|2=<br />
Description='A simple WPA encrypted wireless connection using 256-bit PSK'<br />
Interface=wlp2s2<br />
Connection=wireless<br />
Security=wpa<br />
IP=dhcp<br />
ESSID=''your_essid''<br />
Key=\"64cf3ced850ecef39197bb7b7b301fc39437a6aa6c6a599d0534b16af578e04a<br />
}}<br />
<br />
{{Note|<br />
* Make sure to use the '''special quoting rules''' for the {{ic|Key}} variable as explained at the end of [https://github.com/joukewitteveen/netctl/blob/master/docs/netctl.profile.5.txt netctl.profile(5)].<br />
* If the passphrase fails, try removing the {{ic|\"}} in the {{ic|Key}} variable.<br />
* Although "encrypted", the key that you put in the profile configuration is enough to connect to a WPA-PSK network. Therefore this process is only useful for hiding the human-readable version of the passphrase. This will not prevent anyone with read access to this file from connecting to the network.}}<br />
<br />
=== Obfuscate wireless passphrase ===<br />
<br />
You can also follow the following step to obfuscate the wireless passphrase (''wifi-menu'' does it automatically when using the {{ic|-o}} flag): <br />
<br />
Users '''not''' wishing to have the passphrase to their wireless network stored in ''plain text'' have the option of storing the corresponding 256-bit pre-shared key instead, which is calculated from the passphrase and the SSID using standard algorithms.<br />
<br />
Calculate your 256-bit PSK using [[wpa_supplicant#Connecting with wpa passphrase|wpa_passphrase]]:<br />
{{hc|$ wpa_passphrase ''your_essid''|2=<br />
network={<br />
ssid="''your_essid''"<br />
#psk="''passphrase''"<br />
psk=64cf3ced850ecef39197bb7b7b301fc39437a6aa6c6a599d0534b16af578e04a<br />
}<br />
}}<br />
<br />
The ''pre-shared key'' (psk) now needs to replace the plain text passphrase of the {{ic|Key}} variable in the profile.<br />
<br />
=== Using an experimental GUI ===<br />
<br />
If you want a graphical user interface to manage ''netctl'' and your connections and you are not afraid of highly experimental unofficial packages, there are some options available. {{AUR|netctl-gui}} provides a Qt-based graphical interface, DBus daemon and KDE widget. {{AUR|netmenu}} uses {{Pkg|dmenu}} as its graphical interface, and {{AUR|gnome-shell-extension-netctl-auto-gnome-git}} is a gnome shell extension.<br />
<br />
There is also an application that displays desktop notifications on profile changes and shows a tray icon: {{AUR|netctl-tray}}.<br />
<br />
=== Bonding ===<br />
<br />
{{Out of date|Looking at [https://github.com/archlinux/svntogit-packages/commit/f91cceb9ec8c6b1c82ce5ec0a823befc033cc38b tpowa's commit from 2022-01-14] ifenslave was removed from the repositories.}}<br />
<br />
From [https://www.kernel.org/doc/html/latest/networking/bonding.html kernel documentation]:<br />
<br />
:The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical "bonded" interface. The behavior of the bonded interfaces depends on the mode. Generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed.<br />
<br />
==== Load balancing ====<br />
<br />
To use bonding with netctl, additional package from official repositories is required: {{Pkg|ifenslave}}{{Broken package link|package not found}}.<br />
<br />
Copy {{ic|/etc/netctl/examples/bonding}} to {{ic|/etc/netctl/bond0}} and edit it, for example:<br />
<br />
{{hc|/etc/netctl/bond0|2=<br />
Description='Bond Interface'<br />
Interface='bond0'<br />
Connection=bond<br />
BindsToInterfaces=('eth0' 'eth1')<br />
IP=dhcp<br />
IP6=stateless}}<br />
<br />
Now you can disable your old configuration and set ''bond0'' to be started automatically. Switch to the new profile, for example:<br />
<br />
# netctl switch-to bond0<br />
<br />
{{Note|This uses the round-robin policy, which is the default for the {{ic|bonding}} driver. See [https://www.kernel.org/doc/html/latest/networking/bonding.html official documentation] for details. }}<br />
<br />
Setting the MODE in the netctl configuration is not always successful and it may be necessary to pass options directly to the bonding module on load as noted [https://bbs.archlinux.org/viewtopic.php?id=203255 here]. This may be needed to use LACP / mode 4.<br />
<br />
{{Tip|To check the status and bonding mode: {{bc|$ cat /proc/net/bonding/bond0}}}}<br />
<br />
==== Wired to wireless failover ====<br />
<br />
This example describes how to use ''bonding'' to fallback to wireless when the wired ethernet goes down. This is most useful when both the wired and wireless interface will be connected to the same network. Your wireless router/access point must be configured in [[bridge]] mode.<br />
<br />
You will need additional packages from the official repositories: {{Pkg|ifenslave}}{{Broken package link|package not found}} and {{Pkg|wpa_supplicant}}.<br />
<br />
First enable the bonding module to be loaded upon boot time, as instructed on [[Kernel modules#Automatic module loading with systemd]]:<br />
<br />
{{hc|/etc/modules-load.d/bonding.conf|2=<br />
bonding<br />
}}<br />
<br />
Then, configure the options of the {{ic|bonding}} driver to use {{ic|active-backup}} and configure the {{ic|primary}} parameter to the device you want to be the active one (normally the wired interface). Also, be sure to use the same device name as returned when running {{ic|ip link}}:<br />
<br />
{{hc|/etc/modprobe.d/bonding.conf|2=<br />
options bonding mode=active-backup miimon=100 primary=eth0 max_bonds=0<br />
}}<br />
<br />
The {{ic|miimon}} option is needed, for the link failure detection. The {{ic|max_bonds}} option avoids the {{ic|Interface bond0 already exists}} error. More information can be obtained on the [https://www.kernel.org/doc/html/latest/networking/bonding.html kernel documentation].<br />
<br />
Next, configure a netctl profile to enslave the two hardware interfaces. Use the name of all the devices you want to enslave. If you have more than two wired or wireless interfaces, you can enslave all of them on a bond interface. But, for most cases you will have only two devices, a wired and a wireless one:<br />
<br />
{{hc|/etc/netctl/failover|2=<br />
Description='A wired connection with failover to wireless'<br />
Interface='bond0'<br />
Connection=bond<br />
BindsToInterfaces=('eth0' 'wlan0')<br />
IP='dhcp'<br />
}}<br />
<br />
Disable any other profiles (specially a wired or wireless) you had enabled before and then enable the failover profile on startup:<br />
<br />
# netctl enable failover<br />
<br />
Now you need to configure ''wpa_supplicant'' to connect to any known network you wish. You should create a file for each interface and enable it on systemd. Create the following file with this content:<br />
<br />
{{hc|/etc/wpa_supplicant/wpa_supplicant-wlan0.conf|2=<br />
ctrl_interface=/run/wpa_supplicant<br />
update_config=1<br />
}}<br />
<br />
And append to the end of this file any network you want to connect to: <br />
<br />
network={<br />
ssid="SSID"<br />
psk=PSK<br />
}<br />
<br />
To generate the obfuscated PSK you can run ''wpa_passphrase'' as on the [[wpa_supplicant#Connecting with wpa_passphrase]] page.<br />
<br />
Now, [[enable]] the {{ic|wpa_supplicant@}} template service on the network interface, for example {{ic|wpa_supplicant@wlan0}}.<br />
<br />
You can try now to reboot your machine and see if your configuration worked.<br />
<br />
{{Note|If you get this error on boot bonding:<br />
<br />
wlan0 is up - this may be due to an out of date ifenslave<br />
<br />
Then this is happening because the ''wpa_supplicant'' is being run before the {{ic|failover}} netctl profile. This happens because [[systemd]] runs everything in parallel, unless told otherwise. ''ifenslave'' need all the interfaces to be down before bonding them to the {{ic|bond0}} interface. And, since the ''wpa_supplicant'' need to put the interface up to be able to scan for networks, this might cause the interface to not be enslaved and your bonding to only have the wired interface.<br />
<br />
If this is your case, then you will need to setup a custom dependency on the {{ic|wpa_supplicant@wlan0}} service in relation with the {{ic|netctl@failover}} profile. More specifically, the ''wpa_supplicant'' must be started '''after''' the netctl profile. To accomplish this, create a custom dependency file based on the instructions provided here: [[systemd#Handling dependencies]]<br />
<br />
{{hc|/etc/systemd/system/wpa_supplicant@wlan0.service.d/customdependency.conf|2=<br />
[Unit]<br />
After=netctl@failover.service<br />
}}<br />
<br />
After that you can try to reboot your system again and see if it works. You can check the status of your bonding by checking [[journalctl]] for the {{ic|netctl@failover.service}} unit.<br />
<br />
And by checking:<br />
<br />
# ip link<br />
<br />
You should see something like this:<br />
<br />
1: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000<br />
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff<br />
2: wlan0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP mode DORMANT group default qlen 1000<br />
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff<br />
3: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default <br />
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff<br />
}}<br />
<br />
Now, you can test your failover setup, by initiating a big download. Unplug your wired interface. Your download should keep going over the wireless interface. Then, plug your wired interface again and it should keep working. You can debug by checking [[journalctl]] for the {{ic|netctl@failover.service}} and {{ic|wpa_supplicant@wlan0.service}} units.<br />
<br />
=== Using any interface ===<br />
<br />
In some cases it may be desirable to allow a profile to use any interface on the system. A common example use case is using a common disk image across many machines with differing hardware (this is especially useful if they are headless). If you use the kernel's naming scheme, and your machine has only one ethernet interface, you can probably guess that eth0 is the right interface. If you use udev's [https://systemd.io/PREDICTABLE_INTERFACE_NAMES/ Predictable Network Interface Names], however, names will be assigned based on the specific hardware itself (e.g. enp1s0), rather than simply the order that the hardware was detected (e.g. eth0, eth1). This means that a netctl profile may work on one machine and not another, because they each have different interface names.<br />
<br />
A quick and dirty solution is to make use of the {{ic|/etc/netctl/interfaces/}} directory. Choose a name for your interface alias ({{ic|en-any}} in this example), and write the following to a file with that name (making sure it is [[executable]]).<br />
<br />
{{hc|/etc/netctl/interfaces/en-any|2=<br />
#!/bin/sh<br />
for interface in /sys/class/net/en*; do<br />
break;<br />
done<br />
Interface=$(basename "$interface")<br />
echo "en-any: using interface $Interface";<br />
}}<br />
<br />
Then create a profile that uses the interface. Pay special attention to the {{ic|Interface}} directive. The rest are only provided as examples.<br />
{{hc|/etc/netctl/wired|<nowiki><br />
Description='Wired'<br />
Interface=en-any<br />
Connection=ethernet<br />
IP=static<br />
Address=('192.168.1.15/24')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
When the {{ic|wired}} profile is started, any machine using the two files above will automatically bring up and configure the first ethernet interface found on the system, regardless of what name udev assigned to it. Note that this is not the most robust way to go about configuring interfaces. If you use multiple interfaces, netctl may try to assign the same interface to them, and will likely cause a disruption in connectivity. If you do not mind a more complicated solution, {{ic|netctl-auto}} is likely to be more reliable.<br />
<br />
=== Using hooks ===<br />
<br />
netctl supports hooks in {{ic|/etc/netctl/hooks/}} and per interface hooks in {{ic|/etc/netctl/interfaces/}}. You can set any option in a hook/interface that you can<br />
in a profile. Most importantly this includes {{ic|ExecUpPost}} and {{ic|ExecDownPre}}. <br />
<br />
When a profile is read, netctl sources '''all executable''' scripts in {{ic|hooks}}, then it reads the profile file for the connection and finally it sources an executable script with the name of the interface used in the profile from the {{ic|interfaces}} directory. Therefore, declarations in an interface script override declarations in the profile, which override declarations in hooks. <br />
<br />
The variables {{ic|$INTERFACE}} and {{ic|$ACTION}} are available in hooks/interfaces '''only''' when using {{ic|netctl-auto}}<br />
<br />
==== Examples ====<br />
<br />
===== Execute commands on established connection =====<br />
<br />
{{hc|/etc/netctl/hooks/myservices|<nowiki><br />
#!/bin/sh<br />
ExecUpPost="systemctl start crashplan.service; systemctl start dropbox@<username>.service"<br />
ExecDownPre="systemctl stop crashplan.service; systemctl stop dropbox@<username>.service"<br />
</nowiki>}}<br />
<br />
===== Set default DHCP client =====<br />
<br />
To set or change the DHCP client used for all profiles: <br />
<br />
{{hc|/etc/netctl/hooks/dhcp|<nowiki><br />
#!/bin/sh<br />
DHCPClient='dhclient'<br />
</nowiki>}}<br />
<br />
Do not forget to make the file [[executable]].<br />
<br />
Alternatively, it may also be specified for a specific network interface by creating an executable file {{ic|/etc/netctl/interfaces/<interface>}} with the following line:<br />
<br />
DHCPClient='dhclient'<br />
<br />
{{Expansion|It would be useful to replace the example with a general hook that executes different actions depending on {{ic|$ACTION}} being CONNECT and DISCONNECT.}}<br />
<br />
=== Minimal WPAConfigSection ===<br />
<br />
As stated in {{man|5|netctl.profile|OPTIONS FOR ‘WIRELESS’ CONNECTIONS}}, the {{ic|WPAConfigSection}} variable is an array of configuration lines passed to [[wpa_supplicant]]. So, a minimal WPAConfigSection would contain:<br />
<br />
Description='A wireless connection using a custom network block configuration'<br />
Interface=wlan0<br />
Connection=wireless<br />
Security=wpa-configsection<br />
IP=dhcp<br />
WPAConfigSection=(<br />
'ssid="University"'<br />
'psk="very secret passphrase"'<br />
)<br />
<br />
{{Note|If trying to connect to an SSID with non-ASCII characters (unicode, emoji, etc), you can specify the SSID as hex instead of as a string, e.g. {{ic|1=ssid=F09F90BA}} for "🐺". When unsure on the hex encoding, run ''wifi-menu'' (be sure to remove the \ and x characters).}}<br />
<br />
=== /etc/resolv.conf ===<br />
<br />
If you use {{ic|DNS*}} options in your profile, ''netctl'' calls [[resolvconf]] to overwrite [[resolv.conf]].<br />
<br />
== Troubleshooting ==<br />
<br />
=== Job for netctl@wlan(...).service failed ===<br />
<br />
{{Warning|This section assumes that there is no other network service running before starting a ''netctl'' profile/service. See [[#Installation]] for details.}}<br />
<br />
Some people have an issue when they connect to a network with ''netctl'', for example:<br />
<br />
{{hc|# netctl start wlan0-ssid|<nowiki><br />
Job for netctl@wlan0\x2ssid.service failed. See 'systemctl status netctl@wlan0\x2ssid.service' and 'journalctl -xn' for details.<br />
</nowiki>}}<br />
<br />
When looking at the journal from running {{ic|journalctl -xn}} as root, either of the following are shown:<br />
<br />
1. If your device ({{ic|wlan0}} in this case) is up:<br />
network[2322]: The interface of network profile 'wlan0-ssid' is already up<br />
<br />
Setting the interface down should resolve the problem:<br />
# ip link set wlan0 down<br />
<br />
Then retry:<br />
# netctl start wlan0-ssid<br />
<br />
2. If the error continues, try again after adding the {{ic|ForceConnect}} option:<br />
<br />
{{hc|/etc/netctl/wlan0-ssid|<nowiki><br />
...<br />
ForceConnect=yes<br />
</nowiki>}}<br />
<br />
Save it and try to connect with the profile:<br />
# netctl start wlan0-ssid<br />
<br />
=== dhcpcd: ipv4_addroute: File exists ===<br />
<br />
On some systems dhcpcd in combination with netctl causes timeout issues on resume, particularly when having switched networks in the meantime. netctl will report that you are successfully connected but you still receive timeout issues. In this case, the old default route still exists and is not being renewed. A workaround to avoid this misbehaviour is to switch to [[#Set default DHCP client|dhclient]] as the default dhcp client. More information on the issue can be found [https://bbs.archlinux.org/viewtopic.php?pid=1399842#p1399842 here].<br />
<br />
=== DHCP timeout issues ===<br />
<br />
If you are having timeout issues when requesting leases via DHCP you can set the timeout value higher than netctl's 30 seconds by default. Create a file in {{ic|/etc/netctl/hooks/}} or {{ic|/etc/netctl/interfaces/}}, add {{ic|1=TimeoutDHCP=40}} to it for a timeout of 40 seconds and make the file executable.<br />
<br />
=== dhcpcd debugging ===<br />
<br />
If dhcpcd fails to obtain an address, add the {{ic|-d}} option to {{ic|/usr/lib/netctl/dhcp}} and then run {{ic|journalctl -xe}} as root to view the debugging messages which may indicate, for example, that the IP address offered by the server is rejected by the client after detecting that the IP address is already in use.<br />
<br />
=== Connection timeout issues ===<br />
<br />
If you are having timeout issues that are unrelated to DHCP (on a static ethernet connection for example), and are experiencing errors similar to the following when starting your profile:<br />
{{hc|1=# journalctl _SYSTEMD_UNIT=netctl@''profile''.service|2=<br />
Starting network profile '''profile''<nowiki/>'...<br />
No connection found on interface 'eth0' (timeout)<br />
Failed to bring the network up for profile '<nowiki/>''profile'''<br />
}}<br />
Then you should increase carrier and up timeouts by adding {{ic|1=TimeoutUp=}} and {{ic|1=TimeoutCarrier=}} to your profile file:<br />
{{hc|/etc/netctl/''profile''|<nowiki><br />
...<br />
TimeoutUp=300<br />
TimeoutCarrier=300</nowiki><br />
}}<br />
Do not forget to reenable your profile:<br />
<br />
# netctl reenable ''profile''<br />
<br />
=== Problems with netctl-auto on resume ===<br />
<br />
Sometimes ''netctl-auto'' fails to reconnect when the system resumes from suspend, hibernate or hybrid-sleep. An easy solution is to restart the service for ''netctl-auto''. <br />
This can be automated with an additional service like the following ({{Aur|netctl-auto-resume}}):<br />
<br />
{{hc|/etc/systemd/system/netctl-auto-resume@.service|<nowiki><br />
[Unit]<br />
Description=restart netctl-auto on resume.<br />
Requisite=netctl-auto@%i.service<br />
After=sleep.target<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/systemctl restart netctl-auto@%i.service<br />
<br />
[Install]<br />
WantedBy=sleep.target<br />
</nowiki>}}<br />
<br />
To [[enable]] this service for your wireless card, for example, enable {{ic|netctl-auto-resume@wlan0.service}} as root. Change {{ic|wlan0}} to the required network interface.<br />
<br />
If the device is not yet running on resume when the unit is started, this will fail. It can be fixed by adding the following dependency in the ''After'' line:<br />
<br />
{{hc|/etc/systemd/system/netctl-auto-resume@.service|<nowiki><br />
...<br />
After=sleep.target sys-subsystem-net-devices-%i.device<br />
...<br />
</nowiki>}}<br />
<br />
=== netctl-auto does not automatically unblock a wireless card to use an interface ===<br />
<br />
Many laptops have a hardware button (or switch) to turn off wireless card, however, the card can also be blocked by the kernel. This can be handled by [[rfkill]].<br />
<br />
If you want ''netctl-auto'' to automatically unblock your wireless card to connect to a particular network, set {{ic|1=RFKill=++auto++}} option for the wireless connection of your choice, as specified in the [https://github.com/joukewitteveen/netctl/blob/master/docs/netctl.profile.5.txt netctl.profile(5)] man page.<br />
<br />
=== RTNETLINK answers: File exists (with multiple NICs) ===<br />
<br />
This is a very misleading response, it really means that you have assigned a default gateway in an earlier netctl control file. When netctl starts up the n-th NIC and goes to set its local route, it fails because there is already a default route from n-1.<br />
<br />
Remove it and everything works, except you no longer have a default route and so cannot access things such as the internet. {{ic|ExecUpPost}} does not work as it gets executed for each network card.<br />
<br />
A possible solution is creating a new service. Replace "FIRST_INTERFACE" and "SECOND_INTERFACE" with your interface names, and replace "192.168.xxx.yyy" with your default gateway.<br />
<br />
{{hc|/etc/systemd/system/defaultrouter.service|<nowiki><br />
[Unit]<br />
Description="Configure default gateway"<br />
Requires=netctl@FIRST_INTERFACE.service netctl@SECOND_INTERFACE.service<br />
After=netctl@FIRST_INTERFACE.service netctl@SECOND_INTERFACE.service<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/ip route add default via 192.168.xxx.yyy<br />
<br />
[Install]<br />
WantedBy=network-online.target<br />
</nowiki>}}<br />
<br />
=== Problems with eduroam and other MSCHAPv2 connections ===<br />
<br />
See [[wpa_supplicant#Problems with eduroam and other MSCHAPv2 connections]].<br />
<br />
=== Journal warnings for profiles using .include directives ===<br />
<br />
Profiles still using systemd's old {{ic|.include}} directives will produce journal warnings, for example:<br />
systemd[1]: /etc/systemd/system/netctl@<profile>.service:1: .include directives are deprecated, and support for them will be removed in a future version of systemd. Please use drop-in files instead.<br />
<br />
See {{Bug|59494}} for details.<br />
<br />
Executing<br />
netctl reenable ''profile''<br />
will update the profile to the new [[drop-in unit file]] format.<br />
<br />
=== Hooks do not work ===<br />
<br />
If you have multiple hooks in {{ic|/etc/netctl/hooks/}}, variables like {{ic|ExecUpPost}} and {{ic|ExecDownPre}} will be executed only from one file. To fix this, define the variables like this:<br />
<br />
{{hc|/etc/netctl/hooks/test|<nowiki><br />
ExecUpPost="some command ; "$ExecUpPost<br />
ExecDownPre="some command ; "$ExecDownPre<br />
</nowiki>}}<br />
<br />
This will append your commands to be executed with already defined ones.<br />
<br />
== See also ==<br />
<br />
* [https://lists.archlinux.org/pipermail/arch-projects/2012-December/003473.html Initial mailing list announcement]<br />
* [https://bbs.archlinux.org/viewtopic.php?id=157670 Official announcement thread]<br />
* [https://archlinux.org/news/netctl-is-now-in-core/ Official news announcement]</div>PythonPizza