✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Alpine Networking

Alpine Networking focuses on lightweight, secure connectivity solutions tailored for Alpine Linux, enabling efficient system integration and resource optimization.

Alpine Networking encompasses the configuration, management, and operation of network interfaces and services on Alpine Linux, a lightweight, security-oriented Linux distribution. It provides mechanisms for setting up network connectivity, including wired and wireless interfaces, IP addressing (both IPv4 and IPv6), routing, DNS resolution, and advanced networking constructs such as VLANs, bonding, and bridging. Alpine's networking stack is designed to be minimal and efficient, typically managed through simple configuration files and the ifupdown-ng scripts or equivalent tools, making it suitable for embedded systems, containers, and environments where resource efficiency is critical.


Alpine Network Configuration

Alpine Linux manages network interfaces primarily through configuration files located under /etc/network/, particularly /etc/network/interfaces. This file defines interface parameters, including IP addresses, gateways, and interface-specific options.

Network interfaces can be configured manually with static addressing or dynamically via DHCP. The ifup and ifdown utilities control interface activation and deactivation based on these configurations. Each interface entry in /etc/network/interfaces specifies the interface name, address family (e.g., inet for IPv4, inet6 for IPv6), and method (manual, static, dhcp).

Example static configuration for an interface eth0:

auto eth0
iface eth0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1

Alpine also supports alias interfaces and virtual interfaces, which can be defined similarly with additional naming schemes.


IPv4 and IPv6 Addressing

IPv4 and IPv6 addressing in Alpine Linux can be configured either statically or dynamically on any network interface.

IPv4 Addressing

IPv4 addresses consist of four octets separated by dots. Addresses can be assigned statically or dynamically via DHCP. The netmask defines the subnet size, and a default gateway routes packets outside the local subnet.

IPv4 static addressing requires specifying:

  • address: the IP address
  • netmask: subnet mask
  • gateway: default route

IPv6 Addressing

IPv6 addresses are 128-bit hexadecimal values separated by colons. Alpine supports manual IPv6 configuration and SLAAC (Stateless Address Autoconfiguration) or DHCPv6 for dynamic addressing.

Example IPv6 static configuration:

iface eth0 inet6 static
    address 2001:db8::1
    netmask 64
    gateway 2001:db8::fffe

IPv6 also supports link-local addresses automatically assigned to interfaces and unique local addresses (ULA) for private networks.


Dynamic Network Configuration

Dynamic configuration allows interfaces to obtain IP addresses and routing information automatically. Alpine Linux leverages the DHCP client daemon dhcpcd or udhcpc for this purpose.

DHCP Client

By specifying iface eth0 inet dhcp in /etc/network/interfaces, the interface will request configuration from a DHCP server at boot or when brought up.

Example:

auto eth0
iface eth0 inet dhcp

dhcpcd can be configured with /etc/dhcpcd.conf to customize DHCP client behavior, such as requesting specific options or setting hostname.


DNS Configuration

DNS (Domain Name System) resolution on Alpine Linux is configured via /etc/resolv.conf, which contains nameserver entries specifying DNS servers.

When using DHCP, DNS information can be automatically populated in /etc/resolv.conf. For static setups, this file should be manually created or managed by tools like resolvconf or network scripts.

Example /etc/resolv.conf:

nameserver 8.8.8.8
nameserver 8.8.4.4

Alpine also supports configuring DNS search domains and options in this file.


Wireless Networking

Wireless interfaces in Alpine Linux are managed using the wpa_supplicant daemon for WPA/WPA2 authentication and the iw utility for wireless interface configuration.

Wireless Interface Setup

Wireless devices are configured in /etc/network/interfaces with wpa_supplicant integration:

auto wlan0
iface wlan0 inet dhcp
    wpa-ssid "YourNetworkSSID"
    wpa-psk "YourPassphrase"

The wpa_supplicant.conf file can be used to define complex wireless profiles, including enterprise authentication methods.

Wireless tools such as iw and iwconfig allow for scanning, connecting, and configuring wireless parameters manually.


Network Bridges

Network bridging enables multiple network interfaces to be joined into a single Layer 2 domain, useful for virtualization and container networking.

Alpine uses brctl or the bridge command from iproute2 to create and manage bridges.

Example bridge configuration in /etc/network/interfaces:

auto br0
iface br0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    bridge_ports eth0 eth1

The bridge_ports directive binds physical interfaces to the bridge. Traffic passing through the bridge is forwarded between member interfaces transparently.


VLANs (Virtual LANs)

VLANs allow segmentation of network traffic on a single physical interface by tagging frames with VLAN IDs.

Alpine supports VLANs via the vconfig utility or native kernel VLAN support through the ip tool.

Example VLAN interface configuration:

auto eth0.100
iface eth0.100 inet static
    address 192.168.100.2
    netmask 255.255.255.0
    vlan_raw_device eth0

The VLAN interface eth0.100 represents VLAN ID 100 on physical interface eth0. VLANs isolate traffic and improve security and traffic management.


Network Bonding

Network bonding aggregates multiple physical interfaces into a single logical interface to increase throughput and provide redundancy.

Alpine configures bonding interfaces through the bonding kernel module and the ifenslave utility.

Example bonding configuration:

auto bond0
iface bond0 inet static
    address 192.168.1.50
    netmask 255.255.255.0
    gateway 192.168.1.1
    bond-slaves eth0 eth1
    bond-mode 802.3ad

Bonding modes include:

  • balance-rr (round-robin)
  • active-backup (failover)
  • 802.3ad (LACP for link aggregation)

Bonding improves link resiliency and bandwidth aggregation.


Routing

Routing determines the path network packets take to reach their destinations. Alpine Linux manages routing tables primarily via the ip route command and configurations in /etc/network/interfaces.

Static routes can be defined per interface or globally to direct traffic through specific gateways.

Example static route:

up ip route add 10.0.0.0/24 via 192.168.1.1 dev eth0
down ip route del 10.0.0.0/24 via 192.168.1.1 dev eth0

Default gateways are set to route traffic outside local networks. Alpine supports advanced routing features like policy-based routing and multiple routing tables using ip rule.


Alpine Networking integrates these features into a lean, script-driven environment that emphasizes simplicity, security, and minimal resource use, making it suitable for embedded systems, containers, and secure server environments.

Content in this section