Step 1: Identify Your Network Interface
First, you need to find the name of your network interface. You can list all network connections with:
nmcli connection show
Mine was enp0s3
Step 2: Configure the Static IP Address
To set a static IP address, use the following command, replacing with the name of your connection, and adjusting the IP address, gateway, and DNS as needed:
bash
sudo nmcli connection modify <your_connection_name> ipv4.addresses 192.168.12.100/24
sudo nmcli connection modify <your_connection_name> ipv4.gateway 192.168.12.1
sudo nmcli connection modify <your_connection_name> ipv4.dns 8.8.8.8
sudo nmcli connection modify <your_connection_name> ipv4.method manual
Reference for above:
ipv4.addresses: Set this to your desired static IP address and subnet mask (e.g., /24 for 255.255.255.0).
ipv4.gateway: Set this to your network's gateway.
ipv4.dns: You can specify one or more DNS servers (e.g., Google's DNS 8.8.8.8).
ipv4.method manual: This tells NetworkManager to use a static IP configuration.
Step 3: Bring the Connection Up
After modifying the connection settings, you need to bring the connection down and then back up to apply the changes:
sudo nmcli connection down <your_connection_name>
sudo nmcli connection up <your_connection_name>
Step 4: Make sure everything is correct
To confirm that your static IP address has been set correctly, you can check the current IP configuration with:
nmcli device show <your_interface_name>
Top comments (0)