Network Configuration

Configure wired and wireless networking, static IP addresses, DNS and firewall settings in MocaccinoOS.

MocaccinoOS uses NetworkManager to manage network connections by default. It handles wired and wireless connections and can be controlled through the desktop environment, the nmcli command-line tool, or the nmtui text interface.

For users who prefer a more minimal network configuration, systemd-networkd is also available as an alternative.

NetworkManager

NetworkManager is the recommended option for most desktop installations. It automatically manages network interfaces and connections, including Wi-Fi and Ethernet.

Checking network status

Check the general NetworkManager status:

1
nmcli general status

List available network interfaces and their current state:

1
nmcli device status

List configured network connections:

1
nmcli connection show

To inspect a particular connection:

1
nmcli connection show "Wired connection 1"

The connection name may differ depending on your installation.

Wi-Fi

List available wireless networks:

1
nmcli device wifi list

Connect to a wireless network:

1
nmcli device wifi connect "SSID" password "password"

Replace SSID and password with the network name and its password.

To disconnect a wireless interface:

1
nmcli device disconnect wlan0

Replace wlan0 with the name of your wireless interface. You can find it using nmcli device status.

Enable or disable Wi-Fi:

1
2
nmcli radio wifi on
nmcli radio wifi off

Wired connections

Ethernet connections are normally configured automatically using DHCP when a network cable is connected.

To activate or deactivate an existing connection:

1
2
nmcli connection up "Wired connection 1"
nmcli connection down "Wired connection 1"

Use nmcli connection show to find the correct connection name.

Configuring a static IP address

NetworkManager normally obtains an IP address automatically through DHCP. If your network requires a static address, you can configure an existing connection manually.

First, identify the connection:

1
nmcli connection show

Configure the connection with a static IPv4 address:

1
2
3
4
5
sudo nmcli connection modify "Wired connection 1" \
    ipv4.method manual \
    ipv4.addresses 192.168.1.50/24 \
    ipv4.gateway 192.168.1.1 \
    ipv4.dns "192.168.1.1"

Replace the example address, gateway and DNS server with values appropriate for your network.

Activate the connection again to apply the changes:

1
sudo nmcli connection up "Wired connection 1"

To return to automatic DHCP configuration:

1
2
3
4
5
sudo nmcli connection modify "Wired connection 1" \
    ipv4.method auto \
    ipv4.addresses "" \
    ipv4.gateway "" \
    ipv4.dns ""

Then reactivate the connection:

1
sudo nmcli connection up "Wired connection 1"

Using nmtui

If you prefer a menu-driven interface, NetworkManager includes nmtui.

Start it from a terminal:

1
nmtui

The interface allows you to:

  • Activate and deactivate connections.
  • Edit existing network profiles.
  • Configure wireless and wired connections.
  • Set static IP addresses and DNS servers.

This can be a convenient alternative to using nmcli directly.

systemd-networkd

systemd-networkd is an alternative to NetworkManager. It is primarily intended for systems where network connections are configured through system files rather than a desktop network manager.

Important: Do not run NetworkManager and systemd-networkd to manage the same network interfaces. Switching network managers can interrupt your network connection. If you are connected remotely, make sure you have an alternative way to access the machine before proceeding.

Switching from NetworkManager

Stop and disable NetworkManager:

1
sudo systemctl disable --now NetworkManager

Enable systemd-networkd:

1
sudo systemctl enable --now systemd-networkd

Enable systemd-resolved for DNS resolution:

1
sudo systemctl enable --now systemd-resolved

If your system does not already use the systemd-resolved stub resolver, configure /etc/resolv.conf to point to it:

1
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

This makes applications use systemd-resolved for DNS queries.

Identifying network interfaces

List the available network interfaces:

1
networkctl

You can also use:

1
ip link

Example output:

1
2
3
4
IDX LINK    TYPE     OPERATIONAL SETUP
  1 lo      loopback carrier     unmanaged
  2 enp3s0  ether    routable    configured
  3 enp2s0  ether    off         unmanaged

Note the name of the interface you want to configure, such as enp3s0.

Configuring DHCP

Create a network configuration file:

1
2
sudo mkdir -p /etc/systemd/network
sudo nano /etc/systemd/network/00-enp3s0.network

Replace enp3s0 with your actual interface name.

For automatic DHCP configuration, use:

1
2
3
4
5
[Match]
Name=enp3s0

[Network]
DHCP=yes

Save the file and restart systemd-networkd:

1
sudo systemctl restart systemd-networkd

Configuring a static IP address

To configure a static IPv4 address, use the following configuration:

1
2
3
4
5
6
7
8
9
[Match]
Name=enp3s0

[Network]
Address=192.168.1.50/24
DNS=192.168.1.1

[Route]
Gateway=192.168.1.1

Replace the example addresses with values appropriate for your network.

Restart systemd-networkd to apply the configuration:

1
sudo systemctl restart systemd-networkd

Checking network status

Check the status of network interfaces:

1
networkctl status

Inspect a specific interface:

1
networkctl status enp3s0

Check the service status:

1
systemctl status systemd-networkd

For DNS troubleshooting, inspect systemd-resolved:

1
resolvectl status

Firewall

MocaccinoOS includes the Linux kernel’s nftables firewall framework and the nft userspace utility.

A firewall is not automatically configured simply because these components are installed. You can create your own ruleset according to the services running on your system.

Checking the firewall

Check whether the nftables service is running:

1
systemctl status nftables

Display the currently active firewall rules:

1
sudo nft list ruleset

Configuring nftables

The main configuration file is:

1
/etc/nftables.conf

You can edit it with:

1
sudo nano /etc/nftables.conf

The following example provides a basic incoming-traffic filtering policy for a typical desktop system using DHCP. It allows loopback traffic, established connections, ICMP traffic and DHCP replies. It also allows SSH connections on port 22.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/sbin/nft -f

flush ruleset

table inet filter {
    chain input {
        type filter hook input priority 0;
        policy drop;

        # Allow loopback traffic
        iif lo accept

        # Allow established and related connections
        ct state established,related accept

        # Drop invalid packets
        ct state invalid drop

        # Allow ICMP and ICMPv6
        ip protocol icmp accept
        meta l4proto ipv6-icmp accept

        # Allow DHCPv4 client replies
        udp sport 67 udp dport 68 accept

        # Allow DHCPv6 client replies
        udp sport 547 udp dport 546 accept

        # Allow SSH connections
        tcp dport 22 accept
    }

    chain forward {
        type filter hook forward priority 0;
        policy drop;
    }

    chain output {
        type filter hook output priority 0;
        policy accept;
    }
}

Important: This is an example, not a universal firewall configuration. Remove the SSH rule if you do not need remote access, and add rules for any other services you intend to expose. Systems using VPNs, containers, network bridges or other networking configurations may need additional rules.

Before applying a restrictive firewall policy, make sure you understand which services your system needs. Incorrect rules can interrupt network access.

Enabling nftables

After saving the configuration, check it for syntax errors:

1
sudo nft -c -f /etc/nftables.conf

If the configuration is valid, enable the service:

1
sudo systemctl enable --now nftables

Display the active ruleset:

1
sudo nft list ruleset

You can add rules to the input chain to allow additional services. Common examples include:

Service Port
SSH 22/tcp
HTTP 80/tcp
HTTPS 443/tcp
FTP 21/tcp, plus the configured passive port range
Samba 445/tcp, plus other ports if required

Remember that allowing a port through the firewall does not automatically enable or configure the corresponding service.

Further reading

Last modified November 29, 2026: Update SFTP (f553589)