User Tools

Site Tools


zima:configuration

Configure Static IP with nmcli (via SSH)

This document explains how to set a static IP address on an Ethernet interface using `nmcli`, assuming you are connected to the machine via SSH.

Assumptions

  • The network interface is 'enp2s0'
  • The desired static IP is '192.168.0.31'
  • The default gateway is '192.168.0.1'
  • DNS servers will be '8.8.8.8' and '1.1.1.1'

Steps

1. Create a new static IP connection

sudo nmcli con add type ethernet ifname enp2s0 con-name static-ip autoconnect no ip4 192.168.0.31/24 gw4 192.168.0.1

2. Set DNS servers

sudo nmcli con mod static-ip ipv4.dns "8.8.8.8 1.1.1.1"

3. Activate the new connection

Note: This may temporarily disconnect the SSH session. Reconnect using the static IP:

sudo nmcli con up static-ip

4. (Optional) Delete the old DHCP connection

Once confirmed that the static IP connection works:

sudo nmcli con delete "Wired connection 1"

5. Ensure the connection starts automatically at boot

sudo nmcli con mod static-ip connection.autoconnect yes

6. Final verification

nmcli con show
ip addr show enp2s0

Expected result

The machine will use the static IP '192.168.0.31' permanently, even after reboots, without relying on DHCP.

zima/configuration.txt · Last modified: 2025/04/25 12:51 by jmbargallo