Home > System Tutorial > LINUX > How To Configure Static IP And Dynamic IP Address In Arch Linux

How To Configure Static IP And Dynamic IP Address In Arch Linux

尊渡假赌尊渡假赌尊渡假赌
Release: 2025-03-18 11:48:24
Original
853 people have browsed it

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

  • Method 1: Static IP with netctl
    • Step 1: Identify Network Interface
    • Step 2: Install netctl
    • Step 3: Create a Profile
    • Step 4: Enable and Start the Profile
    • Step 5: Verify Configuration
  • Method 2: Static IP with systemd-networkd
  • Method 3: Static IP with NetworkManager
  • Dynamic IP Configuration with netctl
  • Conclusion

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.

Step 1: Identify Your Network Interface

Use ip link or ls /sys/class/net to find your network interface name (e.g., enp0s3).

ip link
Copy after login

or

ls /sys/class/net
Copy after login

Step 2: Install netctl

If not already installed:

sudo pacman -S netctl
Copy after login

Step 3: Create a Profile

netctl profiles reside in /etc/netctl/. Copy a sample profile and modify it:

sudo cp /etc/netctl/examples/ethernet-static /etc/netctl/enp0s3-static
Copy after login

(Replace enp0s3 with your interface name). Edit the new file (e.g., using nano):

sudo nano /etc/netctl/enp0s3-static
Copy after login

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>
Copy after login

Step 4: Enable and Start the Profile

Enable the profile for automatic startup:

sudo netctl enable enp0s3-static
Copy after login

Start the profile:

sudo netctl start enp0s3-static
Copy after login

Stop and disable any running DHCP services (like dhcpcd):

sudo systemctl stop dhcpcd
sudo systemctl disable dhcpcd
Copy after login

Reboot to apply changes.

Step 5: Verify the Configuration

Check your IP address:

ip addr show enp0s3
Copy after login

Method 2: Static IP with systemd-networkd

systemd-networkd is Arch Linux's default network manager.

  1. Disable NetworkManager (if installed):

    sudo systemctl stop NetworkManager
    sudo systemctl disable NetworkManager
    Copy after login
  2. Enable systemd-networkd:

    sudo systemctl enable systemd-networkd
    sudo systemctl start systemd-networkd
    Copy after login
  3. Create a configuration file:

    sudo nano /etc/systemd/network/enp0s3.network
    Copy after login
  4. 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>
    Copy after login
  5. 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>.

  6. 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

  1. Install netctl (if not already installed).
  2. Copy the ethernet-dhcp example profile:
    sudo cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/enp0s3-dhcp
    Copy after login
  3. Edit the profile, setting IP=dhcp.
  4. Enable and start dhcpcd:
    sudo systemctl enable dhcpcd
    sudo systemctl start dhcpcd
    Copy after login
  5. Reboot.

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template