Quick nmcli setting of an IP for a device

Take a look at your devices and current configuration with the ip addr command

# ip addr # or ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether bc:24:11:8a:2e:b9 brd ff:ff:ff:ff:ff:ff
    altname enp0s18
    inet 192.168.100.10/24 brd 192.168.100.255 scope global noprefixroute ens18
       valid_lft forever preferred_lft forever
    inet6 fe80::6cda:131a:1e6c:4c60/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

Set up the ip address as needed with the commands below

nmcli connection modify ens18 ipv4.addresses 192.168.100.10/24 # Update with your own device and ip address
nmcli connection modify ens18 ipv4.gateway 192.168.100.1 # Update the gateway as your own
nmcli connection modify ens18 ipv4.dns "8.8.8.8 8.8.4.4"   # Update with your preferred DNS servers
nmcli connection modify ens18 ipv4.method manual

Bringing down and up the device

nmcli connection down ens18
nmcli connection up ens18

Deleting the device and adding information

nmcli connection delete ens18 # Delete it
nmcli connection add type ethernet con-name ens18 ifname ens18 # Add it
nmcli connection modify ens18 ipv4.addresses 192.168.100.10/24
nmcli connection modify ens18 ipv4.gateway 192.168.100.1
nmcli connection modify ens18 ipv4.method manual
nmcli connection up ens18

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.