Tutorials
goetia
Software
0x53.net

Setting up networking

Setting a hostname

Write a descriptive name for the machine into the /etc/hostname file. Source directories of the hostname service are kernel specific and contiened in goetia-linux, goetia-freebsd, ... . Symlink the corresponding directory from the installation directory to the system configuration directory, which automatically applies /etc/hostname at boot time. Add hostname to the networking bundle.

Configuring hosts

The configuration file /etc/hosts contains lines of the format @IP@ @DOMAINNAME@. It can be viewed as a most minimal DNS system, which was the purpose of this file before the advent of actual DNS. Add at least the following lines to the /etc/hosts file:

127.0.0.1 localhost
::1       localhost
			

Which causes the loopback network interface in both ipv4 and ipv6 to be associated with the domain name localhost.

Choose the DNS server

DNS server take an domain name like www.example.com and give back the ip address of the corresponding server.

Software usually queries the DNS server from /etc/resolv.conf. Put the line nameserver @IP@ into the file /etc/resolv.conf, replacing @IP@ with the actual ip address.

If multiple nameservers are desired, one should not (even though its technically possible) put them all into /etc/resolv.conf. Instead you should use dnsfunneld. Symlink the source directory to the system configuration directory. Then, add dnsfunneld to the networking bundle.

In this case, make sure the only entry in /etc/resolv.conf is nameserver localhost which will point all applications to dnsfunneld.

To configure dnsfunneld, write just the ip addresses of the desired DNS server in the order you want them tried to the file /etc/dnsfunneld.d/cache and make sure the file is readable by all users.

The loopback interface

The loopback network interface is a virtual network interface. It has no hardware counterpart and exists on all devices. The interface is used to allow software on the machine to access servers running on the same machine (think e.g. the webinterface of cups).

To have the interface set up on boot, symlink the net-lo source directory and add it to the networking bundle. It is part of the Kernel specific components goetia-linux, goetia-freebsd, ... .

Wireless interfaces

If wireless interfaces are used, these must be connected in addition to being configured as described in the next section.

wpa_supplicant

On both Linux and the BSDs, wpa_supplicant (part of goetia-base) can be used to connect to WIFI networks. The most simple setup is to symlink the provided source directory provided to the system configuration directory and add wpa_supplicant to the networking bundle. The provided script uses /etc/wpa_supplicant/wpa_supplicant.conf as the config file and /run/wpa_supplicant as the global control interface, which can be reached using wpa_cli -g /run/wpa_supplicant.

wpa_supplicant can also be ran as one daemon with one configuration file per interface. To set up wpa_supplicant as a service, create a longrun source directory called wpa_supplicant-@WIRELESSINTERFACE@-srv at the system configuration directory:

src/net/wpa_supplicant-@WIRELESSINTERFACE@-srv
├── producer-for      # @WIRELESSINTERFACE@-log
├── run               # see below
└── type              # longrun
            

run script:

#!/bin/execlineb -P

fdmove -c 2 1

wpa_supplicant -i @WIRELESSINTERFACE@ -c /etc/wpa_supplicant/@WIRELESSINTERFACE@.conf
			

Add wpa_supplicant-@WIRELESSINTERFACE@-srv to the networking bundle and configure the interface in the configuration file /etc/wpa_supplicant/@WIRELESSINTERFACE@.conf according to man wpa_supplicant.conf.

iwd

On Linux, iwd (part of goetia-linux) can be used alternatively to wpa_supplicant. Symlink the corresponding source directory and add iwd to the networking bundle. Start configuring networks using iwctl

Configuring network interfaces

Following are alternative ways to configure network interfaces.

DHCP

DHCP is a means to automatically setup a network interface based on information provided by a DHCP server (which is present on almost all networks).

dhcpcd

For both Linux and the BSDs, dhcpcd (part of goetia-base) can be used for that. If desired, symlink the dhcpcd source directory to the system configuration directory and add dhcpcd to the networking bundle.

Note that the stock service for dhcpcd depends on the bundle udev, since an udev implementation is used to automagically detect an interface to configure. If the interface to be configured is known beforehand, and/or the udev dependency is not desired, it is possible to create an interface specific script. Create a longrun source directory called dhcpcd-@INTERFACE@-srv in the system configuration directory:

dhcpcd-@INTERFACE@-srv
├── producer-for      # dhcpcd-@INTERFACE@-log
├── run               # see below
└── type              # longrun
            

run script:

#!/bin/execlineb -P

fdmove -c 2 1

dhcpcd -B @INTERFACE@
			

Replace @INTERFACE@ with the interface to configure and add the service to the networking bundle.

dhcpcd is ran as a daemon by default, automatically acquiring a new lease upon expiration. It is possible to run dhcpcd as a oneshot on boot to configure the interface once only. For that, create a oneshot source directory called dhcpcd:

dhcpcd
├── dependencies.d
│   └── udev          # empty/arbitrary
├── up                # see below
└── type              # oneshot
            

up script:

#!/bin/execlineb -P

fdmove -c 2 1

dhcpcd -1
			

Add dhcpcd to the networking bundle.

Again, by adding @INTERFACE@ as an argument, the udev dependency can be avoided.

If desired, remove the domain_name_servers option from /etc/dhcpcd.conf file, to stop dhcpcd from overwriting the DNS server set above.

dhclient

On FreeBSD, dhclient (part of goetia-freebsd) is installed by default and can be used instead of dhcpcd. For that, create a longrun source directory called dhclient-@INTERFACE@-srv in the system configuration directory:

dhclient-@INTERFACE@-srv
├── producer-for      # dhclient-@INTERFACE@-log
├── run               # see below
└── type              # longrun
            

run script:

#!/bin/execlineb -P

fdmove -c 2 1

dhclient -d @INTERFACE@
			

Add dhclient-@INTERFACE@-srv to the networking bundle.

Static ip address

If the machine is most of the time in the same network, with the same network card, setting a static ip on boot is the simplest and most resource efficient solution.

On both Linux and the BSDs, the ifconfig command can be used for that: create a oneshot source directory named net-@INTERFACE@ at the system configuration directory:

net-@INTERFACE@
├── up                # see below
├── down              # see below
└── type              # oneshot
            

up script:

#!/bin/execlineb -P

fdmove -c 2 1

if { ifconfig @INTERFACE@ up }
if { ifconfig @INTERFACE@ @IP@ }
if { ifconfig @INTERFACE@ netmask @NETMASK@ }
route add default gw @GATEWAY@
			

Additionally, to clean up the network interface and the routing table upon stopping the service, add the following down script:

#!/bin/execlineb -P

fdmove -c 2 1

if { ifconfig @INTERFACE@ 0.0.0.0 }
ifconfig @INTERFACE@ down
			

Add net-@INTERFACE@ to the networking bundle.

On Linux, the net-tools package, providing the ifconfig and route commands, is gradually being replaced by the iproute2 package. To use iproute2 for configuring a static ip, create a oneshot source directory named net-@INTERFACE@ in the system configuration directory:

net-@INTERFACE@
├── up                # see below
├── down              # see below
└── type              # oneshot
            

up script with @NETMASK@ in CIDR notation:

#!/bin/execlineb -P

fdmove -c 2 1

if { ip link set @INTERFACE@ up }
if { ip addr add @IP@/@NETMASK@ dev @INTERFACE@ }
ip route add default via @GATEWAY@ dev @INTERFACE@
			

Again, clean up both interface and route with the following down script:

#!/bin/execlineb -P

fdmove -c 2 1

if { ip addr flush dev @INTERFACE@ }
ip link set @INTERFACE@ down
			

Do not forget to add net-@INTERFACE@ to the networking bundle.

Network manager

On Linux, there is also NetworkManager (part of goetia-linux). A source directory is provided and just needs to be symlinked and added to the networking bundle by the name networkmanager.

This comes with two additional oneshots: net-nm-ready and net-nm-online, both may be symlinked and added to the networking bundle or used as a dependency elsewhere. net-nm-ready finishes once network manager has all interfaces configured; net-nm-online, once an internet connection has been established. See also.