To set up a static IP for your Linux system using NetworkManager, follow these steps:

1. Identify Your Network Interface

Run the following command to find the name of your active network interface:

nmcli device

Look for the interface in the “DEVICE” column that’s connected.

2. Edit the Connection

Use the following command to modify your network connection:

`nmcli connection edit <connection_name>`

Replace <connection_name> with the name of your active connection (you can find this in the “CONNECTION” column from the nmcli device output).

3. Set a Static IP

While in the connection editor:

  1. Set the IPv4 method to manual:
set ipv4.method manual
  • Add your static IP address, subnet mask, and gateway:
set ipv4.addresses 192.168.1.x/24 set ipv4.gateway 192.168.1.1
Replace `192.168.1.x` with the desired static IP address for your system.
  • Set DNS servers (e.g., Google DNS):
set ipv4.dns 8.8.8.8,8.8.4.4
  • Save the changes and quit the editor:
save
quit

4. Bring the Connection Up

Restart the connection to apply the changes:

nmcli connection up <connection_name>

5. Verify the Static IP

Check your network configuration to ensure the static IP is set:

ip addr show <interface_name>

Replace <interface_name> with the name of your network interface.

6. Optional: Verify Connectivity

Test the connectivity with a ping:

ping -c 4 8.8.8.8 ping -c 4 google.com