Overview
This guide covers network configuration for Arch Linux using dhcpcd for DHCP client functionality and systemd-resolved for DNS resolution.
DHCP Configuration (dhcpcd)
Installation
Enable and start the service:
sudo systemctl enable dhcpcd
sudo systemctl start dhcpcd
Configuration File
The dhcpcd configuration is located at /etc/dhcpcd.conf.
Key Settings
Client Identification
Use DUID (DHCP Unique Identifier) for client identification:
Alternatively, use the hardware address:
Some non-RFC compliant DHCP servers may not respond when using DUID. If you experience connection issues, comment out duid and enable clientid instead.
Persistent Configuration
Maintain interface configuration when dhcpcd exits:
Vendor Class ID
Set to blank to avoid sending system information:
DHCP Options
Requested Options
Specify which options to request from the DHCP server:
option domain_name_servers, domain_name, domain_search
option classless_static_routes
option interface_mtu
option host_name
Key options:
domain_name_servers - DNS server addresses
domain_name - Domain name
domain_search - DNS search domains
classless_static_routes - Static routing information
interface_mtu - Network MTU settings
host_name - Request hostname from network
Optional Features
Enables rapid commit support for faster DHCP negotiation (requires server support).
Server Identifier Requirement
require dhcp_server_identifier
Required by RFC2131 to ensure DHCP responses are from legitimate servers.
IPv6 Configuration
SLAAC (Stateless Address Autoconfiguration)
Generate stable private IPv6 addresses:
Alternatively, use hardware address:
Disable IPv4 Link-Local
Prevents automatic assignment of 169.254.x.x addresses.
DNS Resolution Hook
Disable dhcpcd’s automatic resolv.conf management:
This allows systemd-resolved to manage DNS configuration instead.
DNS Configuration (systemd-resolved)
Installation and Setup
systemd-resolved is typically pre-installed on Arch Linux.
Enable and start the service:
sudo systemctl enable systemd-resolved
sudo systemctl start systemd-resolved
Symlink Configuration
Link the stub resolver to /etc/resolv.conf:
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
This will overwrite your existing /etc/resolv.conf. Back up any custom DNS configurations before proceeding.
DNS Stub Listener
The systemd-resolved stub listener provides DNS resolution at:
This is configured in /etc/resolv.conf (symlinked to /run/systemd/resolve/stub-resolv.conf):
nameserver 127.0.0.53
options edns0 trust-ad
search .
Options:
edns0 - Enable DNS Extension Mechanisms
trust-ad - Trust DNSSEC authenticated data
Check DNS Status
View current DNS configuration and upstream servers:
Query DNS for a specific domain:
resolvectl query example.com
View DNS statistics:
Manual DNS Configuration
To set custom DNS servers for a specific interface:
sudo resolvectl dns <interface> 1.1.1.1 8.8.8.8
To set DNS search domains:
sudo resolvectl domain <interface> example.com
Hosts File
The /etc/hosts file provides static hostname-to-IP mappings.
Basic Configuration
127.0.0.1 localhost
127.0.0.1 localhost.localdomain
127.0.1.1 linux
::1 localhost
::1 ip6-localhost
::1 ip6-loopback
IPv6 Addresses
ff00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
fe80::1%lo0 localhost
Broadcast Address
255.255.255.255 broadcasthost
Ad Blocking with Hosts File
The example configuration uses Steven Black’s unified hosts file for blocking ads, fake news, gambling, porn, and social media:
curl -o /tmp/hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
sudo cp /tmp/hosts /etc/hosts
Project: StevenBlack/hosts
Modifying /etc/hosts with large blocklists can impact DNS lookup performance. Test thoroughly before deploying.
Network Testing
Check Interface Status
ip addr show
ip link show
Test Connectivity
ping -c 4 8.8.8.8 # Test IPv4 connectivity
ping -c 4 archlinux.org # Test DNS resolution
View DHCP Leases
cat /var/lib/dhcpcd/*.lease
Monitor Network Traffic
sudo journalctl -u dhcpcd -f
sudo journalctl -u systemd-resolved -f
Troubleshooting
No Network Connection
-
Check interface status:
-
Ensure dhcpcd is running:
sudo systemctl status dhcpcd
-
Restart networking:
sudo systemctl restart dhcpcd
DNS Resolution Fails
-
Check systemd-resolved status:
-
Verify
/etc/resolv.conf symlink:
-
Restart systemd-resolved:
sudo systemctl restart systemd-resolved
Interface Not Getting IP Address
Manually request a new lease:
sudo dhcpcd -n <interface>
Release and renew:
sudo dhcpcd -k <interface> # Release
sudo dhcpcd -n <interface> # Renew
File Locations
- dhcpcd configuration:
/etc/dhcpcd.conf
- DNS configuration:
/etc/resolv.conf → /run/systemd/resolve/stub-resolv.conf
- Hosts file:
/etc/hosts
- DHCP leases:
/var/lib/dhcpcd/*.lease
Additional Resources