RHCSA Rapid Track
Course update
An updated version of this course is available that uses a newer version of Red Hat Enterprise Linux in the lab environment. Therefore, the RHEL 9.0 version of the lab environment will retire on December 31, 2024. Please complete any work in this lab environment before it is removed on December 31, 2024. For the most up-to-date version of this course, we recommend moving to the RHEL 9.3 version.
In this exercise, you 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 altnameenp0s3altnameens3Use 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 calledWired connection 1. If the name of the active connection is different, then use that name instead ofWired connection 1for the rest of this exercise.[root@servera ~]#
nmcli con show --activeNAME UUID TYPE DEVICEWired connection 1ec3a15fb-2e26-3254-9433-90c66981e924 etherneteth0Display all configuration settings for the active connection.
[root@servera ~]#
nmcli con show "Wired connection 1"connection.id: Wired connection 1 connection.uuid: ec3a15fb-2e26-3254-9433-90c66981e924 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... ipv6.method: auto ipv6.dns: -- ipv6.dns-search: -- ipv6.dns-options: -- ipv6.dns-priority: 0 ipv6.addresses: -- ipv6.gateway: -- ipv6.routes: -- ...output omitted... GENERAL.NAME: Wired connection 1 GENERAL.UUID: ec3a15fb-2e26-3254-9433-90c66981e924 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 Wired connection 1 lo loopback unmanaged --Display 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: Wired connection 1 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/1 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::c38a:ac39:36a1:a43c/64 IP6.GATEWAY: -- IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 1024
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' (dc519805-48c4-4b31-b9e9-d3631cf9082c) successfully added.Display and activate the new connection.
View all connections.
[root@servera ~]#
nmcli con showNAME UUID TYPE DEVICE Wired connection 1 ec3a15fb-2e26-3254-9433-90c66981e924 ethernet eth0 static-addr dc519805-48c4-4b31-b9e9-d3631cf9082c ethernet --View the active connections.
[root@servera ~]#
nmcli con show --activeNAME UUID TYPE DEVICE Wired connection 1 ec3a15fb-2e26-3254-9433-90c66981e924 ethernet eth0Activate the new
static-addrconnection.[root@servera ~]#
nmcli con up static-addrConnection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)Verify the new active connection.
[root@servera ~]#
nmcli con show --activeNAME UUID TYPE DEVICE static-addr dc519805-48c4-4b31-b9e9-d3631cf9082c ethernet eth0
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 "Wired connection 1" \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 dc519805-48c4-4b31-b9e9-d3631cf9082c ethernet eth0
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::eb21:9a:24de:e8fe/64Verify the default gateway.
[student@servera ~]$
ip routedefault via 172.25.250.254 dev eth0 proto static metric 100 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.777 ms 64 bytes from 172.25.250.220: icmp_seq=2 ttl=64 time=0.431 ms 64 bytes from 172.25.250.220: icmp_seq=3 ttl=64 time=0.272 ms --- 172.25.250.220 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2045ms rtt min/avg/max/mdev = 0.272/0.493/0.777/0.210 msReturn to the
workstationsystem as thestudentuser.[student@servera ~]$
exitlogout Connection to servera closed. [student@workstation ~]$
This concludes the section.