Home >System Tutorial >LINUX >How To Configure Static IP And Dynamic IP Address In Arch Linux
This guide details how to configure static and dynamic IP addresses in Arch Linux, including derivatives like EndeavourOS and Manjaro. Arch Linux offers several methods for IP configuration: direct command-line manipulation, or using network management services such as netctl
, systemd-networkd
, or NetworkManager
.
This tutorial covers each method.
Table of Contents
netctl
netctl
systemd-networkd
NetworkManager
netctl
Method 1: Configuring a Static IP Address using netctl
netctl
is a command-line tool for managing systemd network services. It's particularly useful on systems without NetworkManager
or systemd-networkd
.
Use ip link
or ls /sys/class/net
to find your network interface name (e.g., enp0s3
).
ip link
or
ls /sys/class/net
netctl
If not already installed:
sudo pacman -S netctl
netctl
profiles reside in /etc/netctl/
. Copy a sample profile and modify it:
sudo cp /etc/netctl/examples/ethernet-static /etc/netctl/enp0s3-static
(Replace enp0s3
with your interface name). Edit the new file (e.g., using nano
):
sudo nano /etc/netctl/enp0s3-static
Configure your IP address, netmask, gateway, and DNS servers:
<code>Description='Static Ethernet Connection' Interface=enp0s3 Connection=ethernet IP=static Address=('192.168.1.102/24') Gateway=('192.168.1.1') DNS=('8.8.8.8' '8.8.4.4')</code>
Enable the profile for automatic startup:
sudo netctl enable enp0s3-static
Start the profile:
sudo netctl start enp0s3-static
Stop and disable any running DHCP services (like dhcpcd
):
sudo systemctl stop dhcpcd sudo systemctl disable dhcpcd
Reboot to apply changes.
Check your IP address:
ip addr show enp0s3
Method 2: Static IP with systemd-networkd
systemd-networkd
is Arch Linux's default network manager.
Disable NetworkManager
(if installed):
sudo systemctl stop NetworkManager sudo systemctl disable NetworkManager
Enable systemd-networkd
:
sudo systemctl enable systemd-networkd sudo systemctl start systemd-networkd
Create a configuration file:
sudo nano /etc/systemd/network/enp0s3.network
Add the following configuration:
<code>[Match] Name=enp0s3 [Network] Address=192.168.1.102/24 Gateway=192.168.1.1 DNS=8.8.8.8 DNS=8.8.4.4</code>
Disable any existing netctl
profiles. Use sudo systemctl list-unit-files | grep enabled | grep netctl
to find them and disable with sudo systemctl disable <profile_name>.service</profile_name>
.
Reboot.
Method 3: Static IP with NetworkManager
NetworkManager
offers a graphical interface. Install and enable it if needed. Use nmcli
to configure your connection.
Dynamic IP Configuration with netctl
netctl
(if not already installed).ethernet-dhcp
example profile:sudo cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/enp0s3-dhcp
IP=dhcp
.dhcpcd
:sudo systemctl enable dhcpcd sudo systemctl start dhcpcd
Conclusion
This guide provides multiple methods for configuring IP addresses in Arch Linux. Choose the method that best suits your needs and comfort level. Remember to only use one network manager at a time to avoid conflicts.
The above is the detailed content of How To Configure Static IP And Dynamic IP Address In Arch Linux. For more information, please follow other related articles on the PHP Chinese website!