Configure Networking

This page documents the various networking options available in Alpine Linux. This page helps to configure your network and to test your Internet access.
== Network setup-scripts ==
Among the alpine setup scripts that are installed as part of alpine-conf, the following network related scripts are available. 
* setup-hostname
* setup-interfaces
* setup-dns
* setup-proxy
* setup-ntp
All the above utilities are interactive. 
For a versatile networking front end refer NetworkManager. If your networking needs are more advanced, you have to refer to the following detailed guide for manual network configuration. 
== Setting hostname ==
To set the system hostname:
Then, to activate the change: 
If you're using IPv6, you should also add the following special IPv6 addresses to your file:
For a static IP configuration, it's common to also add the machine's hostname you just set (above) to the file.
Here's an IPv4 example:
And here's an IPv6 example:
== Configuring DNS ==
For a static IP address and static nameservers, use one of the following examples.
For IPv4 nameservers, edit your file to look like this:
The following example uses Google's Public DNS servers.
For IPv6 nameservers, edit your file to look like this:
The following example uses Hurricane Electric's public DNS server.
You can also use Hurricane Electric's public IPv4 DNS server:
== Interface configuration ==
=== Loopback configuration ===
To configure loopback, add the following to a new file : 
The above works to set up the IPv4 loopback address (127.0.0.1), and the IPv6 loopback address (::1) — if you enabled IPv6.
=== Wireless configuration ===
Alpine Linux supports two wireless daemons i.e wpa_supplicant and iwd. setup-interfaces script uses wpa_supplicant to configure wireless interface. 
=== Ethernet configuration ===
For the following Ethernet configuration examples, we will assume that you are using Ethernet device eth0.
==== Initial configuration ====
Add the following to the file , above any IP configuration for eth0:
==== IPv4 DHCP configuration ====
Add the following to the file , below the auto eth0 definition:
By default, the busybox DHCP client (udhcpc) requests a static set of options from the DHCP server. If you need to extend this set, you can do so by setting some additional command line options for the DHCP client, via the udhcpc_opts in your interface configuration. The following example requests
domain-search option:
For a complete list of command line options for udhcpc, see this document.
==== IPv4 Static Address Configuration ====
Add the following to the file , below the auto eth0 definition:
Since Alpine 3.13 (and only if you have ifupdown-ng installed) must be:
===== Additional IP addresses =====
Since Alpine 3.13 (and only if you have ifupdown-ng installed) must be:
==== IPv6 DHCP Configuration ====
Alpine's use of ifupdown-ng supports three DHCP clients: udhcpc, dhclient, and dhcpcd. Of these, only dhcpcd can interact with both DHCP and DHCPv6 from the same process, which ifupdown-ng requires. Thus the IPv4 DHCP configuration given above will also result in the use of DHCPv6, but only if you install the dhcpcd package. (The ifupdown-ng scripts prioritize dhclient over udhcpc, and they prioritize dhcpcd over dhclient; see .)
==== IPv6 Stateless Autoconfiguration ====
Add the following to the file , below the auto eth0 definition:
==== IPv6 Static Address Configuration ====
Add the following to the file , below the auto eth0 definition:
Since Alpine Linux 3.13 (and only if you have ifupdown-ng installed) must be as:
=== Example: Dual-Stack Configuration ===
This example shows a dual-stack configuration.
Take care since Alpine 3.13 (and only if you have ifupdown-ng installed) must be as:
== Networking service ==
Changes made to can be activated by running: 
To start (or restart) the networking service: 
To add networking service so that it starts on boot: 
== Firewall==
Alpine Linux provides multiple firewall software. Some of the prominent ones are listed below:
* Alpine Wall User's Guide
* Iptables
* nftables
* Uncomplicated Firewall
== Troubleshooting ==
=== Connectivity testing ===
Test if networking is configured properly by attempting to ping out:
For an IPv6 traceroute run traceroute6:
=== iproute2 ===
Install the package which provides the 'ss' command which is an alternate to netstat.: 
Show listening tcp ports:
Show listening tcp ports and associated processes:
Show listening and established tcp connections:
Show socket usage summary:
Show more options:
=== drill ===
Install (it will also install the 'ldns' package) which is a superior replacement for nslookup and dig etc: 
Then use it as you would for dig: 
To perform a reverse lookup (get a name from an IP) use the following syntax: 
=== Missing interface === 
Sometimes networking interface will not be detected by the installation media. Refer to the steps to check interface. 
Refer to Wifi troubleshooting page for issues related to wireless interfaces. If nothing works, you may have to use an alternate interface for installation (e.g. a usb to ethernet adapter).
== See also ==
You may also wish to review the following network related articles:
* NetworkManager - Front-end to Networking
* VLAN setup
* Bonding setup
* Network bridge setup
* udhcpc configuration
* wpa_supplicant - Default wifi daemon
* iwd - An alternate wifi daemon
Category:Networking