Warning: THE VOID WIKI IS DEPRECATED. It is no longer being maintained, contains outdated and incorrect information, and will eventually be shut down. Please refer to the Void Handbook, https://docs.voidlinux.org/, for the official documentation. If you can't find the information you're seeking, please raise an issue at https://github.com/void-linux/void-docs/issues

Difference between revisions of "Network Configuration"

From Void Linux Wiki
Jump to navigation Jump to search
(Style guide, syntax, typos, conversions to man/pkg templates, update re: wpa_supplicant dhcpcd hook.)
Line 1: Line 1:
 
== Static IP ==
 
== Static IP ==
  
Static IP configuration can either be done through <code>dhcpcd</code> and its configuration file <code>/etc/dhcpcd.conf</code>, or iproute commands in <code>/etc/rc.local</code> (see below). If an ethernet interface was configured at the installer, the <code>dhcpcd.conf</code> file should look as follows:
+
Static IP configuration can either be done through <code>dhcpcd</code> and its configuration file {{path|/etc/dhcpcd.conf}}, or iproute commands in {|path|/etc/rc.local}} (see below). If an ethernet interface was configured at the installer, '''dhcpcd.conf''' should look as follows:
  
<pre># Static IP configuration.
+
# Static IP configuration.
interface eth0
+
interface eth0
static ip_address=192.168.1.2
+
static ip_address=192.168.1.2
static routers=192.168.1.1
+
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 8.8.4.4</pre>
+
static domain_name_servers=8.8.8.8 8.8.4.4
  
The <code>dhcpcd</code> service must be enabled in the <code>default</code> runlevel:
+
The '''dhcpcd''' service must be enabled in the '''default''' runlevel:
  
<pre># ln -s /etc/sv/dhcpcd /var/service/</pre>
+
# ln -s /etc/sv/dhcpcd /var/service/
  
A simpler solution without the need of running the <code>dhcpcd</code> daemon would be to setup the network interface in the file <code>/etc/rc.local</code> via commands from the <code>iproute</code> package:
+
A simpler solution without the need of running the '''dhcpcd''' daemon would be to setup the network interface in {{path|/etc/rc.local}} via commands from the {{pkg|iproute2}} package:
  
<pre># Static IP configuration via iproute
+
# Static IP configuration via iproute
ip link set dev eth0 up
+
ip link set dev eth0 up
ip addr add 192.168.1.2/24 brd + dev eth0
+
ip addr add 192.168.1.2/24 brd + dev eth0
ip route add default via 192.168.1.1</pre>
+
ip route add default via 192.168.1.1
  
 
== Dynamic IP (DHCP) ==
 
== Dynamic IP (DHCP) ==
  
This is handled by the <code>dhcpcd</code> package and its service. To acquire a lease for any known interface simply enable the <code>dhcpcd</code> system service:
+
This is handled by the {{pkg|dhcpcd}} package and its service. To acquire a lease for any known interface, simply enable the <code>dhcpcd</code> system service:
  
<pre># ln -s /etc/sv/dhcpcd /var/service/</pre>
+
# ln -s /etc/sv/dhcpcd /var/service/
  
 
=== DHCP per interface ===
 
=== DHCP per interface ===
Line 49: Line 49:
 
These applications conflict with the methods mentioned above so before using <code>NetworkManager</code>, <code>wicd</code> or <code>conmman</code> make sure that <code>dhcpcd</code> and <code>wpa_supplicant</code> services are stopped and disabled:
 
These applications conflict with the methods mentioned above so before using <code>NetworkManager</code>, <code>wicd</code> or <code>conmman</code> make sure that <code>dhcpcd</code> and <code>wpa_supplicant</code> services are stopped and disabled:
  
<pre># rm -f /var/service/&lt;foo&gt;</pre>
+
# rm -f /var/service/<foo>
  
 
or for the per interface service; make sure that none of these services are started by default.
 
or for the per interface service; make sure that none of these services are started by default.
Line 55: Line 55:
 
== Wireless (default) ==
 
== Wireless (default) ==
  
Wireless connections are handled by the <code>wpa_supplicant</code> package; it can handle multiple kinds of security against the APs: none, WEP, WPA-PSK (WPA Personal), WPA-EAP (WPA Enterprise) and more.
+
Wireless connections are handled by the {{pkg|wpa_supplicant}} package; it can handle multiple kinds of security against the APs: none, WEP, WPA-PSK (WPA Personal), WPA-EAP (WPA Enterprise) and more.
  
 
Copy the <code>wpa_supplicant.conf</code> file to match your network device:
 
Copy the <code>wpa_supplicant.conf</code> file to match your network device:
  
<pre>$ cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant-&lt;device&gt;.conf</pre>
+
$ cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant-<device>.conf
  
 
=== Enabling a wireless interface ===
 
=== Enabling a wireless interface ===
Line 66: Line 66:
 
To view the available networks interfaces on your computer, run:
 
To view the available networks interfaces on your computer, run:
  
<pre>$ sudo ip link show</pre>
+
$ sudo ip link show
  
 
This will give you a list of all available interfaces. Wireless interface should be named "wlp2s0" by default, but check the command's output to corroborate this either way, just in case.
 
This will give you a list of all available interfaces. Wireless interface should be named "wlp2s0" by default, but check the command's output to corroborate this either way, just in case.
Line 72: Line 72:
 
To enable this interface, run:  
 
To enable this interface, run:  
  
<pre>$ sudo ip link set up <interface_name></pre>
+
$ sudo ip link set up <interface_name>
  
 
=== WEP encryption ===
 
=== WEP encryption ===
  
For WEP encrypted wireless networks, just edit <code>/etc/wpa_supplicant/wpa_supplicant-<device>.conf</code> and add the following lines:
+
For WEP encrypted wireless networks, just edit {{path|/etc/wpa_supplicant/wpa_supplicant-<device>.conf}} and add the following lines:
  
 
<pre># Example default configuration file for wpa_supplicant.conf(5).
 
<pre># Example default configuration file for wpa_supplicant.conf(5).
Line 86: Line 86:
 
# Add your networks here.
 
# Add your networks here.
 
network={
 
network={
     ssid=&quot;MYSSID&quot;
+
     ssid="MYSSID"
 
     key_mgmt=NONE
 
     key_mgmt=NONE
     wep_key0=&quot;YOUR AP WEP KEY&quot;
+
     wep_key0="YOUR AP WEP KEY"
 
     wep_tx_keyidx=0
 
     wep_tx_keyidx=0
 
     auth_alg=SHARED
 
     auth_alg=SHARED
Line 95: Line 95:
 
=== WPA-PSK encryption (WPA Personal) ===
 
=== WPA-PSK encryption (WPA Personal) ===
  
For <code>WPA-PSK</code> encrypted networks, we must generate the <code>pre shared key</code> with <code>wpa_passphrase(8)</code>. To do this, run the following command:
+
For <code>WPA-PSK</code> encrypted networks, we must generate the <code>pre shared key</code> with {{man|8|wpa_passphrase}}. To do this, run the following command:
  
<pre>$ wpa_passphrase <MYSSID> <key></pre>
+
$ wpa_passphrase <MYSSID> <key>
  
Then, just append the resulting output from the above command to <code>/etc/wpa_supplicant/wpa_supplicant-<device_name>.conf</code>:
+
Then, just append the resulting output from the above command to {{path|/etc/wpa_supplicant/wpa_supplicant-<device_name>.conf}}:
  
 
<pre># Example default configuration file for wpa_supplicant.conf(5).
 
<pre># Example default configuration file for wpa_supplicant.conf(5).
Line 109: Line 109:
 
# Add here your networks.
 
# Add here your networks.
 
network={
 
network={
     ssid=&quot;MYSSID&quot;
+
     ssid="MYSSID"
     #psk=&quot;YOUR AP KEY&quot;
+
     #psk="YOUR AP KEY"
 
     psk=a8c34100ab4e5afac33cad7184d45a29ee0079001577d579bec6b74e4d7b5ac8
 
     psk=a8c34100ab4e5afac33cad7184d45a29ee0079001577d579bec6b74e4d7b5ac8
 
}</pre>
 
}</pre>
  
This configuration file will be used in the following steps to start the <code>wpa_supplicant</code>
+
This configuration file will be used in the following steps to start <code>wpa_supplicant</code>.
  
 
=== Starting <code>wpa_supplicant</code> through <code>dhcpcd</code> hooks===
 
=== Starting <code>wpa_supplicant</code> through <code>dhcpcd</code> hooks===
  
You can enable the <code>dhcpcd</code> service, which has a hook to start wpa_supplicant, and use the <code>wpa_cli(8)</code> command to see details of this AP connection.
+
You can enable the <code>dhcpcd</code> service, which has a hook to start wpa_supplicant, and use the {{man|8|wpa_cli}} command to see details of this AP connection.
  
{{Note|Behaviour changed in dhcpcd-6.10.0-1: The hook is not enabled by default anymore.}}
+
Check which version you are using with
  
Check which version you are using (<code>$ dhcpcd --version</code>). If you're using 6.10.0-1 or newer you have to enable the <code>wpa_supplicant</code> hook:
+
$ dhcpcd --version
  
<pre>$ sudo ln -s /usr/share/dhcpcd/hooks/10-wpa_supplicant /usr/libexec/dhcpcd-hooks</pre>
+
If you're using and old version you may need to enable the <code>wpa_supplicant</code> hook:
 +
 
 +
$ sudo ln -s /usr/share/dhcpcd/hooks/10-wpa_supplicant /usr/libexec/dhcpcd-hooks
  
 
{{Note|Not sure if the following driver option in dhcpcd works anymore. Add -Dwext to your command if you find you have issues.
 
{{Note|Not sure if the following driver option in dhcpcd works anymore. Add -Dwext to your command if you find you have issues.
Line 130: Line 132:
 
<pre>$ sudo wpa_supplicant -B -i<interface_name> -c<path/to/configuration/file> -Dwext</pre>}}
 
<pre>$ sudo wpa_supplicant -B -i<interface_name> -c<path/to/configuration/file> -Dwext</pre>}}
  
If you happen to need a special driver (option -D) you can edit <code>/etc/dhcpcd.conf</code> and add a line like <code>env wpa_supplicant_driver=wext</code>.
+
If you happen to need a special driver (option -D) you can edit {{path|/etc/dhcpcd.conf}} and add a line like <code>env wpa_supplicant_driver=wext</code>.
  
 
After enabling this hook, don't forget to restart <code>dhcpcd</code>:
 
After enabling this hook, don't forget to restart <code>dhcpcd</code>:
  
<pre>$ sudo sv restart dhcpcd</pre>
+
$ sudo sv restart dhcpcd
  
 
If <code>wpa_supplicant</code> is still not starting after this, try starting it from the command line with
 
If <code>wpa_supplicant</code> is still not starting after this, try starting it from the command line with
  
<pre>$ sudo wpa_supplicant -i <device> -c /etc/wpa_supplicant/wpa_supplicant-<device>.conf</pre>
+
$ sudo wpa_supplicant -i <device> -c /etc/wpa_supplicant/wpa_supplicant-<device>.conf
  
 
to see if you get any errors.
 
to see if you get any errors.
Line 144: Line 146:
 
=== Starting <code>wpa_supplicant</code> manually ===
 
=== Starting <code>wpa_supplicant</code> manually ===
  
Alternatively, you can start wpa_supplicant manually, and run dhcpcd afterwards on your interface to establish the connection without configuring the dhcpcd hook
+
Alternatively, you can start wpa_supplicant manually, and run dhcpcd afterwards on your interface to establish the connection without configuring the dhcpcd hook:
  
<pre>$ sudo wpa_supplicant -B -i <interface_name> -c <path/to/configuration/file></pre>
+
$ sudo wpa_supplicant -B -i <interface_name> -c <path/to/configuration/file>
<pre>$ sudo dhcpcd <interface_name></pre>
+
$ sudo dhcpcd <interface_name>
  
 
Test the connection afterwards with:
 
Test the connection afterwards with:
 
   
 
   
<pre>$ ping <arbitrary website></pre>
+
$ ping <arbitrary website>
  
 
== Wireless (NetworkManager) ==
 
== Wireless (NetworkManager) ==
Line 157: Line 159:
 
Install required packages:
 
Install required packages:
  
<pre>
+
# xbps-install NetworkManager network-manager-applet gnome-icon-theme inetutils-ifconfig gnome-keyring
# xbps-install NetworkManager network-manager-applet gnome-icon-theme inetutils-ifconfig gnome-keyring
 
</pre>
 
  
 
If you want messages about the state:
 
If you want messages about the state:
  
<pre>
+
# xbps-install xfce4-notifyd
# xbps-install xfce4-notifyd
 
</pre>
 
  
 
Disable dhcpcd and wpa_supplicant services:
 
Disable dhcpcd and wpa_supplicant services:
  
<pre>
+
# rm -fr /var/service/dhcpcd
# rm -fr /var/service/dhcpcd
+
# rm -fr /var/service/wpa_supplicant
# rm -fr /var/service/wpa_supplicant
 
</pre>
 
  
 
Enable and start new services:
 
Enable and start new services:
  
<pre>
+
# ln -s /etc/sv/NetworkManager /var/service
# ln -s /etc/sv/NetworkManager /var/service
+
# ln -s /etc/sv/dbus /var/service
# ln -s /etc/sv/dbus /var/service
 
</pre>
 
  
 
Start <code>nm-applet</code> in the desktop manager start file:
 
Start <code>nm-applet</code> in the desktop manager start file:
  
<pre>nm-applet &</pre>
+
nm-applet &
  
 
The applet should show up in the system tray. If your desktop manager doesn't have one, look for {{pkg|stalonetray}} or {{pkg|trayer-srg}}, which are available in Void Linux.
 
The applet should show up in the system tray. If your desktop manager doesn't have one, look for {{pkg|stalonetray}} or {{pkg|trayer-srg}}, which are available in Void Linux.
Line 189: Line 183:
 
=== Captive Portal Detection ===
 
=== Captive Portal Detection ===
  
NetworkManager support connectivity detection in captive portals. In VoidLinux this is default off. You can enable it by adding creating this file: <pre>/etc/NetworkManager/conf.d/10-connectivity.conf</pre>
+
NetworkManager supports connectivity detection in captive portals. In Void Linux this is off by default. You can enable it by creating this file:
  
<pre>
+
{{hc|File: /etc/NetworkManager/conf.d/10-connectivity.conf|
/etc/NetworkManager/conf.d/10-connectivity.conf
 
 
[connectivity]
 
[connectivity]
uri=http://nmcheck.gnome.org/check_network_status.txt
+
uri&#61;http://nmcheck.gnome.org/check_network_status.txt
response=NetworkManager is online
+
response&#61;NetworkManager is online
interval=300
+
interval&#61;300
</pre>
+
}}
  
 
Then restart the NetworkManager:
 
Then restart the NetworkManager:
<pre>
+
 
# sv restart NetworkManager
+
# sv restart NetworkManager
</pre>
 
  
 
== Connecting to hotel / restaurant / airport hotspots via the command line ==
 
== Connecting to hotel / restaurant / airport hotspots via the command line ==
Line 214: Line 206:
 
==== Step 1: stop the current dhcpcd service if it's running ====
 
==== Step 1: stop the current dhcpcd service if it's running ====
  
<pre>$ sudo sv stop dhcpcd</pre>
+
$ sudo sv stop dhcpcd
  
 
==== Step 2: bring up your wireless NIC ====
 
==== Step 2: bring up your wireless NIC ====
  
<pre>$ sudo ip link set <device> up</pre>
+
$ sudo ip link set <device> up
  
Replace <device> with the name assigned to your wireless card. If you don't know its name, you can use the <code>ip a</code> or <code>ip link</code> command.
+
Replace <device> with the name assigned to your wireless card. If you don't know its name, you can use the <code>ip a</code> or <code>ip link</code> commands.
  
 
==== Step 3: connect to the ESSID of the establishment ====
 
==== Step 3: connect to the ESSID of the establishment ====
  
<pre>$ sudo iw dev <device> connect -w "AwesomeHotel"</pre>
+
$ sudo iw dev <device> connect -w "AwesomeHotel"
  
 
The <code>-w</code> option waits until the connection either succeeds or an error occurs.
 
The <code>-w</code> option waits until the connection either succeeds or an error occurs.
Line 230: Line 222:
 
==== Step 4: obtain an IP address from the network ====
 
==== Step 4: obtain an IP address from the network ====
  
<pre>$ sudo dhcpcd <device></pre>
+
$ sudo dhcpcd <device>
  
 
You should now be able to fire up your favourite web browser and log into the network normally.
 
You should now be able to fire up your favourite web browser and log into the network normally.
Line 236: Line 228:
 
=== Method 2: saving the connection ===
 
=== Method 2: saving the connection ===
  
If you're staying at a hotel for a few days, you might want to save the connection details for the duration. This method uses the <code>wpa_cli</code> command to store the ESSID of the hotel in the <code>/etc/wpa_supplicant/wpa_supplicant-<device>.conf</code> file. This assumes that you have the <code>wpa_supplicant</code> service running. This won't work if the service isn't up. Once connected, the <code>dhcpcd</code> service will obtain an IP from the network if it too is running.
+
If you're staying at a hotel for a few days, you might want to save the connection details for the duration of your stay. This method uses the {{man|8|wpa_cli}} command to store the ESSID of the hotel in the {{path|/etc/wpa_supplicant/wpa_supplicant-<device>.conf}} file. This assumes that you have the <code>wpa_supplicant</code> service running. This won't work if the service isn't up. Once connected, the <code>dhcpcd</code> service will obtain an IP from the network if it too is running.
  
 
==== Step 1: start wpa_cli in interactive mode ====
 
==== Step 1: start wpa_cli in interactive mode ====
  
<pre>$ sudo wpa_cli</pre>
+
$ sudo wpa_cli
  
 
At this point, <code>wpa_cli</code> will tell you which interface it's working on and greet you with a <code>></code> prompt. If you want to specify the interface, simply include its name with the <code>-i</code> switch when starting <code>wpa_cli</code>:
 
At this point, <code>wpa_cli</code> will tell you which interface it's working on and greet you with a <code>></code> prompt. If you want to specify the interface, simply include its name with the <code>-i</code> switch when starting <code>wpa_cli</code>:
  
<pre>$ sudo wpa_cli -i <device></pre>
+
$ sudo wpa_cli -i <device>
  
 
You might also see a bunch of unsolicited messages fly by as you move on to step 2.
 
You might also see a bunch of unsolicited messages fly by as you move on to step 2.
Line 250: Line 242:
 
==== Step 2: connect to the network and save the ESSID ====
 
==== Step 2: connect to the network and save the ESSID ====
  
<pre>
+
> add_network
> add_network
+
12
12
+
> set_network 12 ssid "The_hotel_SSID"
> set_network 12 ssid "The_hotel_SSID"
+
> set_network 12 key_mgmt NONE
> set_network 12 key_mgmt NONE
+
> enable_network 12
> enable_network 12
+
> save_config
> save_config
+
> quit
> quit
 
</pre>
 
  
 
Enjoy your stay!
 
Enjoy your stay!
  
 
== See also ==
 
== See also ==
* <code>dhcpcd(8)</code>, <code>dhcpcd-run-hooks(8)</code>
+
* {{man|8|dhcpcd}}, {{man|8|dhcpcd-run-hooks}}
  
 
[[Category:Guides]]
 
[[Category:Guides]]

Revision as of 13:16, 12 September 2017

Static IP

Static IP configuration can either be done through dhcpcd and its configuration file /etc/dhcpcd.conf, or iproute commands in {|path|/etc/rc.local}} (see below). If an ethernet interface was configured at the installer, dhcpcd.conf should look as follows:

# Static IP configuration.
interface eth0
static ip_address=192.168.1.2
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 8.8.4.4

The dhcpcd service must be enabled in the default runlevel:

# ln -s /etc/sv/dhcpcd /var/service/

A simpler solution without the need of running the dhcpcd daemon would be to setup the network interface in /etc/rc.local via commands from the iproute2 package:

# Static IP configuration via iproute
ip link set dev eth0 up
ip addr add 192.168.1.2/24 brd + dev eth0
ip route add default via 192.168.1.1

Dynamic IP (DHCP)

This is handled by the dhcpcd package and its service. To acquire a lease for any known interface, simply enable the dhcpcd system service:

# ln -s /etc/sv/dhcpcd /var/service/

DHCP per interface

The default dhcpcd runit service works in all available network interfaces, but sometimes only a single interface needs to be setup, in that case we'll make another service with some modifications:

# mkdir -p /etc/sv/dhcpcd-eth0
# vi /etc/sv/dhcpcd-eth0/run
       #!/bin/sh
       exec dhcpcd -B eth0
# chmod 755 /etc/sv/dhcpcd-eth0/run
# ln -s /run/runit/supervise.dhcpcd-eth0  /etc/sv/dhcpcd-eth0/supervise

This new runit service will only work for the eth0 device. Now you just need to symlink it to the current runlevel to enable and start it:

# ln -s /etc/sv/dhcpcd-eth0 /var/service/

You can find available network devices by executing

$ ip link

Desktop Network Daemons (NetworkManager, wicd and connman)

These applications conflict with the methods mentioned above so before using NetworkManager, wicd or conmman make sure that dhcpcd and wpa_supplicant services are stopped and disabled:

# rm -f /var/service/<foo>

or for the per interface service; make sure that none of these services are started by default.

Wireless (default)

Wireless connections are handled by the wpa_supplicant package; it can handle multiple kinds of security against the APs: none, WEP, WPA-PSK (WPA Personal), WPA-EAP (WPA Enterprise) and more.

Copy the wpa_supplicant.conf file to match your network device:

$ cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant-<device>.conf

Enabling a wireless interface

First you need to enable a wireless interface through which to connect to your wireless network. To view the available networks interfaces on your computer, run:

$ sudo ip link show

This will give you a list of all available interfaces. Wireless interface should be named "wlp2s0" by default, but check the command's output to corroborate this either way, just in case.

To enable this interface, run:

$ sudo ip link set up <interface_name>

WEP encryption

For WEP encrypted wireless networks, just edit /etc/wpa_supplicant/wpa_supplicant-<device>.conf and add the following lines:

# Example default configuration file for wpa_supplicant.conf(5).
ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=wheel
eapol_version=1
ap_scan=1
fast_reauth=1
# Add your networks here.
network={
    ssid="MYSSID"
    key_mgmt=NONE
    wep_key0="YOUR AP WEP KEY"
    wep_tx_keyidx=0
    auth_alg=SHARED
}

WPA-PSK encryption (WPA Personal)

For WPA-PSK encrypted networks, we must generate the pre shared key with wpa_passphrase(8). To do this, run the following command:

$ wpa_passphrase <MYSSID> <key>

Then, just append the resulting output from the above command to /etc/wpa_supplicant/wpa_supplicant-<device_name>.conf:

# Example default configuration file for wpa_supplicant.conf(5).
ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=wheel
eapol_version=1
ap_scan=1
fast_reauth=1
# Add here your networks.
network={
    ssid="MYSSID"
    #psk="YOUR AP KEY"
    psk=a8c34100ab4e5afac33cad7184d45a29ee0079001577d579bec6b74e4d7b5ac8
}

This configuration file will be used in the following steps to start wpa_supplicant.

Starting wpa_supplicant through dhcpcd hooks

You can enable the dhcpcd service, which has a hook to start wpa_supplicant, and use the wpa_cli(8) command to see details of this AP connection.

Check which version you are using with

$ dhcpcd --version

If you're using and old version you may need to enable the wpa_supplicant hook:

$ sudo ln -s /usr/share/dhcpcd/hooks/10-wpa_supplicant /usr/libexec/dhcpcd-hooks
Note: Not sure if the following driver option in dhcpcd works anymore. Add -Dwext to your command if you find you have issues.
$ sudo wpa_supplicant -B -i<interface_name> -c<path/to/configuration/file> -Dwext

If you happen to need a special driver (option -D) you can edit /etc/dhcpcd.conf and add a line like env wpa_supplicant_driver=wext.

After enabling this hook, don't forget to restart dhcpcd:

$ sudo sv restart dhcpcd

If wpa_supplicant is still not starting after this, try starting it from the command line with

$ sudo wpa_supplicant -i <device> -c /etc/wpa_supplicant/wpa_supplicant-<device>.conf

to see if you get any errors.

Starting wpa_supplicant manually

Alternatively, you can start wpa_supplicant manually, and run dhcpcd afterwards on your interface to establish the connection without configuring the dhcpcd hook:

$ sudo wpa_supplicant -B -i <interface_name> -c <path/to/configuration/file>
$ sudo dhcpcd <interface_name>

Test the connection afterwards with:

$ ping <arbitrary website>

Wireless (NetworkManager)

Install required packages:

# xbps-install NetworkManager network-manager-applet gnome-icon-theme inetutils-ifconfig gnome-keyring

If you want messages about the state:

# xbps-install xfce4-notifyd

Disable dhcpcd and wpa_supplicant services:

# rm -fr /var/service/dhcpcd
# rm -fr /var/service/wpa_supplicant

Enable and start new services:

# ln -s /etc/sv/NetworkManager /var/service
# ln -s /etc/sv/dbus /var/service

Start nm-applet in the desktop manager start file:

nm-applet &

The applet should show up in the system tray. If your desktop manager doesn't have one, look for stalonetray or trayer-srg, which are available in Void Linux.

Captive Portal Detection

NetworkManager supports connectivity detection in captive portals. In Void Linux this is off by default. You can enable it by creating this file:

File: /etc/NetworkManager/conf.d/10-connectivity.conf
[connectivity]
uri=http://nmcheck.gnome.org/check_network_status.txt
response=NetworkManager is online
interval=300

Then restart the NetworkManager:

# sv restart NetworkManager

Connecting to hotel / restaurant / airport hotspots via the command line

Oftentimes, wifi hotspots in various public places don't have an accompanying WPA / WEP key. They require you to connect to their ESSID, obtain an IP address, and subsequently log in via a web interface of some sort. Here are two ways that will allow you to log into these networks.

Method 1: one-time connection

If you don't foresee yourself connecting to this network more than once, the following method is an effective way to connect to the establishment's network temporarily:

Step 1: stop the current dhcpcd service if it's running

$ sudo sv stop dhcpcd

Step 2: bring up your wireless NIC

$ sudo ip link set <device> up

Replace <device> with the name assigned to your wireless card. If you don't know its name, you can use the ip a or ip link commands.

Step 3: connect to the ESSID of the establishment

$ sudo iw dev <device> connect -w "AwesomeHotel"

The -w option waits until the connection either succeeds or an error occurs.

Step 4: obtain an IP address from the network

$ sudo dhcpcd <device>

You should now be able to fire up your favourite web browser and log into the network normally.

Method 2: saving the connection

If you're staying at a hotel for a few days, you might want to save the connection details for the duration of your stay. This method uses the wpa_cli(8) command to store the ESSID of the hotel in the /etc/wpa_supplicant/wpa_supplicant-<device>.conf file. This assumes that you have the wpa_supplicant service running. This won't work if the service isn't up. Once connected, the dhcpcd service will obtain an IP from the network if it too is running.

Step 1: start wpa_cli in interactive mode

$ sudo wpa_cli

At this point, wpa_cli will tell you which interface it's working on and greet you with a > prompt. If you want to specify the interface, simply include its name with the -i switch when starting wpa_cli:

$ sudo wpa_cli -i <device>

You might also see a bunch of unsolicited messages fly by as you move on to step 2.

Step 2: connect to the network and save the ESSID

> add_network
12
> set_network 12 ssid "The_hotel_SSID"
> set_network 12 key_mgmt NONE
> enable_network 12
> save_config
> quit

Enjoy your stay!

See also