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

Network Configuration

From Void Linux Wiki
Jump to navigation Jump to search

Static IP

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

# Static IP configuration.
interface eth0
static ip_address=
static routers=
static domain_name_servers=

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 the file /etc/rc.local via commands from the iproute package:

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

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
       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.

NetworkManager-openvpn issues

For those having issues with NetworkManager-openvpn not connecting, it seems that the nm- openvpn user is not added. Do so (make sure dbus, cgmanager and consolekit are installed):

# groupadd -r nm-openvpn 
# useradd -r -g nm-openvpn -d / -s /sbin/nologin -c "Default user for running openvpn      spawned by NetworkManager" nm-openvpn 

This should take care of it, credits to AnAkkk on the Arch forums!

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


Just edit /etc/wpa_supplicant/wpa_supplicant-<device>.conf and add the following lines:

# Default configuration file for wpa_supplicant.conf(5).
# Add here your networks.
    wep_key0="YOUR AP WEP KEY"

WPA-PSK (WPA Personal)

For WPA-PSK we must generate the pre shared key with wpa_passphrase(8):

$ wpa_passphrase MYSSID key

Just append the resulting output from the above command to /etc/wpa_supplicant/wpa_supplicant-<device>.conf:

# Default configuration file for wpa_supplicant.conf(5).
# Add here your networks.
    #psk="YOUR AP KEY"

Starting wpa_supplicant

You can now 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.

Note: Behaviour changed in dhcpcd-6.10.0-1: The hook is not enabled by default anymore.

Check which version you are using ($ dhcpcd --version). If you're using 6.10.0-1 or newer you have to enable the wpa_supplicant hook:

$ sudo ln -s /usr/share/dhcpcd/hooks/10-wpa_supplicant /usr/libexec/dhcpcd-hooks

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 ($ sudo wpa_supplicant -i <device> -c /etc/wpa_supplicant/wpa_supplicant-<device>.conf) to see if you get any errors.

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. To do this, follow these simple steps:

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 command.

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.

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

Remove dhcpcd and wpa_supplicant services:

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

Include new services:

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

The nm-applet requires some privileges, so, in the same way explained above (NetworkManager-openvpn issues):

# groupadd -r nm-applet
# useradd -r -g nm-applet -d / -s /sbin/nologin -c "Default user for running nm-applet spawned by NetworkManager" nm-applet

Start nm-applet in the desktop manager start file:

nm-applet &

The applet would show in the system tray. If your desktop manager doesn't have one, look for stalonetray or trayer-srg which are include in voidlinux.

(See also: dhcpcd(8), dhcpcd-run-hooks(8))