RHCSA Rapid Track
Use the nmcli command to configure network settings.
Outcomes
Update a network connection setting from DHCP to static.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start net-configure
Instructions
Use the
sshcommand to log in to theserveramachine as thestudentuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#Display the network interface information.
Important
Network interface names are determined by their bus type and the detection order of devices during boot. Your network interface names might vary according to the course platform and hardware in use.
On your system, locate the interface name (such as
eth1,ens06, orenp0p2) that is associated with the Ethernet address52:54:00:00:fa:0a. Use this interface name to replace theeth0placeholder throughout this exercise if different.Locate the network interface name that is associated with the
52:54:00:00:fa:0aEthernet address. Record or remember this name, and use it to replace theeth0placeholder in subsequent commands.[root@servera ~]#
ip link1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether52:54:00:00:fa:0abrd ff:ff:ff:ff:ff:ff altnameenp0s3altnameens3...output omitted...Use the
nmclicommand to view network settings.Use the
nmcli con show --activecommand to display only the active connections.Your network interface name should appear under the
DEVICEcolumn of the output, and the name of the active connection for that device is listed under theNAMEcolumn. This exercise assumes that the active connection is calledSystem eth0. If the name of the active connection is different, then use that name instead ofSystem eth0for the rest of this exercise.[root@servera ~]#
nmcli con show --activeNAME UUID TYPE DEVICESystem eth05fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 etherneteth0...output omitted...Display all configuration settings for the active connection.
[root@servera ~]#
nmcli con show "System eth0"connection.id: System eth0 connection.uuid: 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: eth0 connection.autoconnect: yes ...output omitted... ipv4.method: manual ipv4.dns: 172.25.250.220 ipv4.dns-search: lab.example.com,example.com ipv4.dns-options: -- ipv4.dns-priority: 0 ipv4.addresses: 172.25.250.10/24 ipv4.gateway: 172.25.250.254 ...output omitted... GENERAL.NAME: System eth0 GENERAL.UUID: 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 GENERAL.DEVICES: eth0 GENERAL.IP-IFACE: eth0 GENERAL.STATE: activated GENERAL.DEFAULT: yes ...output omitted...Show the device status.
[root@servera ~]#
nmcli dev statusDEVICE TYPE STATE CONNECTION eth0 ethernet connected System eth0 eth1 ethernet connected System eth1 lo loopback connected (externally) loDisplay the settings for the
eth0device.[root@servera ~]#
nmcli dev show eth0GENERAL.DEVICE: eth0 GENERAL.TYPE: ethernet GENERAL.HWADDR: 52:54:00:00:FA:0A GENERAL.MTU: 1500 GENERAL.STATE: 100 (connected) GENERAL.CONNECTION: System eth0 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/2 WIRED-PROPERTIES.CARRIER: on IP4.ADDRESS[1]: 172.25.250.10/24 IP4.GATEWAY: 172.25.250.254 IP4.ROUTE[1]: dst = 172.25.250.0/24, nh = 0.0.0.0, mt = 100 IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 172.25.250.254, mt = 100 IP4.DNS[1]: 172.25.250.220 IP4.SEARCHES[1]: lab.example.com IP4.SEARCHES[2]: example.com IP6.ADDRESS[1]: fe80::5054:ff:fe00:fa0a/64 IP6.GATEWAY: -- IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 256
Create a static connection with the same IPv4 address, network prefix, and default gateway as the active connection. Name the new connection
static-addr.Warning
Because access to your machine is provided over the primary network connection, setting incorrect values during network configuration might make your machine unreachable. If you machine is unreachable, then use the button above what used to be your machine's graphical display and try again.
[root@servera ~]#
nmcli con add con-name static-addr \ ifname eth0 type ethernet ipv4.method manual ipv4.dns 172.25.250.220 \ ipv4.addresses 172.25.250.10/24 ipv4.gateway 172.25.250.254Connection 'static-addr' (3ef7c2c6-8c72-4cb6-9b19-2878e50285b1) successfully added.Display and activate the new connection.
View all connections.
[root@servera ~]#
nmcli con showNAME UUID TYPE DEVICE System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0 System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1 lo d22fdd46-f935-4212-8908-7cdd37b9f723 loopback lo static-addr 3ef7c2c6-8c72-4cb6-9b19-2878e50285b1 ethernet --View the active connections.
[root@servera ~]#
nmcli con show --activeNAME UUID TYPE DEVICE System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0 System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1 lo d22fdd46-f935-4212-8908-7cdd37b9f723 loopback loActivate the new
static-addrconnection.[root@servera ~]#
nmcli con up static-addrConnection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)Verify the new active connection.
[root@servera ~]#
nmcli con show --activeNAME UUID TYPE DEVICE static-addr 3ef7c2c6-8c72-4cb6-9b19-2878e50285b1 ethernet eth0 System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1 lo d22fdd46-f935-4212-8908-7cdd37b9f723 loopback lo
Update the previous connection so that it does not start at boot. Verify that the
static-addrconnection is used when the system reboots.Disable the original connection so that it does not start automatically at boot.
[root@servera ~]#
nmcli con mod "System eth0" \ connection.autoconnect noReboot the system.
[root@servera ~]#
systemctl rebootConnection to servera closed by remote host. Connection to servera closed. [student@workstation ~]$Log in to the
serveramachine and verify that thestatic-addrconnection is the active connection.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$nmcli con show --activeNAME UUID TYPE DEVICE static-addr 3ef7c2c6-8c72-4cb6-9b19-2878e50285b1 ethernet eth0 System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1 lo 6e328ad2-7ea6-411a-a0e8-b7658c71b4d7 loopback lo
Test connectivity by using the new network addresses.
Verify the IP address.
[student@servera ~]$
ip -br addr show eth0eth0 UP 172.25.250.10/24 fe80::1be9:a14f:c8d9:8af8/64Verify the default gateway.
[student@servera ~]$
ip routedefault via 172.25.250.254 dev eth0 proto static metric 100 10.80.0.0/16 dev eth1 proto kernel scope link src 10.80.3.1 metric 101 169.254.169.254 via 10.80.0.10 dev eth1 proto dhcp src 10.80.3.1 metric 101 172.25.250.0/24 dev eth0 proto kernel scope link src 172.25.250.10 metric 100Ping the DNS address.
[student@servera ~]$
ping -c3 172.25.250.220PING 172.25.250.220 (172.25.250.220) 56(84) bytes of data. 64 bytes from 172.25.250.220: icmp_seq=1 ttl=64 time=0.999 ms 64 bytes from 172.25.250.220: icmp_seq=2 ttl=64 time=0.250 ms 64 bytes from 172.25.250.220: icmp_seq=3 ttl=64 time=0.293 ms --- 172.25.250.220 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2004ms rtt min/avg/max/mdev = 0.250/0.514/0.999/0.343 msReturn to the
workstationsystem as thestudentuser.[student@servera ~]$
exitlogout Connection to servera closed. [student@workstation ~]$