If you want to truly master Linux networking, don't use ifconfig. :) It's been deprecated for over 20 years now. Ifconfig does not support secondary IP addresses for example which is something you might have to do on the RHCSA exam.
File location for Linux networking
Look at /etc/resolv.conf for DNS settings. Remember it's overwritten by NetworkManager. Set DNS servers using nmtui or nmcli.
Check out /etc/NetworkManager/. This directory has everything related to NetworkManager. Check out the system-connections directory.
See network information
Display IP addresses
ip a or nmcli.
Display route/gateway information
ip -4 route or ip -6 route.
Legacy commands to see route information is either netstat -r or route -n.
Display ARP table
arp -a
Display the ARP default timeout
cat /proc/sys/net/ipv4/neigh/default/gc_stale_time
Change settings for your NIC
Assign IP address
You can use the "graphical" nmtui tool to configure your network connection. If you use nmtui, remember to set the subnet mask when you enter the IP address. Using nmtui for the exam is better than using nmcli for most people since it will save time.
Another way is to use the nmcli tool. Remember to swap out the name for the correct name you see when you execute nmcli connection show. I personally use nmcli to set my option but I never used the "edit" mode to do so.
nmcli connection edit enp1s0.
What I do instead is just find the name of my connection and then modify it directly without using the edit mode.
Find the connection name, nmcli connection show. Make sure that the bash-completion package is installed when working with nmcli, it just makes life better in every way. :)
Assign an IP address to the correct connection name.
nmcli connection modify enp0s3 ipv4.addresses 192.168.1.21/24.
Assign a second IP address, notice the "+".
nmcli connection modify enp0s3 +ipv4.addresses 10.0.0.10/24Â
Remember in the test to use nmcli dev reapply device-name to apply the setting without taking down the connection, or do nmcli connection up connection-name. That reapplies everything without taking down the connection.
IP is an excellent command for troubleshooting but using the IP command only changes the runtime environment, it does not change anything in the configuration files. Hence, the changes you make will be lost when you reboot.
Here are a few nmcli examples:
nmcli device status
nmcli connection show -active
If the connection is unmanaged or not connecting, try this command.
nmcli connection modify <connection-name> connection.autoconnect yes
Activate Changes
nmcli connection reload
This only makes the NM aware of the changes.
If you have to take the connection down and then up do nmcli connection down connection-name; nmcli connection up connection-name.
Most changes can be applied directly with nmcli dev reapply device-name.
Change the gateway
nmcli connection modify enp0s3 ipv4.gateway 192.168.1.254
Use static instead of DHCP
nmcli connection modify enp0s3 ipv4.method static
Disabling and enabling an interface
You have two options, the one we just mentioned.
nmcli connection down connection-name && nmcli connection up connection-name or you can use this command, ip link set ens33 down && ip link set ens33 up.
Changing the MTU for e.g., iSCSI
nmcli con mod ensp92 802-3-ethernet.mtu 9000
Tracing
tcpdump -i ens192 not host 10.201.170.147Â (This IP is your IP)
ss -plant | grep 104.26.0.20
Show connections with a remote IP 104.26.0.20 and the process initiating the connection on the server.
Get the PID from ss -plant and run lsof -p 25431
ps -p 25431 -o pid,ppid,cmd,%mem,%cpu
tcpdump -i any host 104.26.0.20
Just track the port the PID is using: tcpdump -i <interface> port 25431
Debug
Use nm-connection-editor if you have issues with certs for you network cards. (In general, not for the exam).
Make sure your subnet mask is correct.
Ping your gateway to see if you can reach the router.
DNS not working, check "/etc/resolv.conf" to make sure it's correct.