Ch11. Manage Networking
Default Network interface names:
- Ethernet interfaces begin with en, WLAN interfaces begin with wl, and WWAN interfaces begin with WW
- The next character(s) represents the type of adapter with an o for on-board, s for hotplug slot, and p for PCI.
- A number N is used to represent an index, ID, or port.
- If the fixed name can not be determined, the traditional names such as ethN will be used.
- Example:
- eno1, the first embedded network interface
- enp2s0, a PCI card network interface
Displaying IP addresses:
[root@master ~]# ifconfig
[root@master ~]# ifconfig eno16777736
[root@master ~]# ip help
[root@master ~]# ip addr help
[root@master ~]# ip addr (Display IP information)
[root@master ~]# ip addr show (Display IP information)
[root@master ~]# ip addr show eno16777736
[root@master ~]# ip link show
[root@master ~]# ip -s link show
[root@master ~]# ip -s link show eno16777736
Configuring IP addresses:
[root@client ~]# ifconfig eno16777736 192.168.1.10 netmask 255.255.255.0
-Note: Prefix will be the default if not configured
[root@client ~]# ip addr add dev eno16777736 192.168.1.10/24 (Appears as a secondary IP)
-Note: Prefix will be /32 if not configured
Configuring Networking with nmcli:
[root@client ~]# nmcli
[root@client ~]# nmcli help
[root@client ~]# nmcli con show
[root@client ~]# nmcli con show eno16777736
[root@client ~]# nmcli connection add con-name testing ifname eno16777736 type ethernet ip4 192.168.1.10/24
[root@client ~]# nmcli connection down eno16777736
[root@client ~]# nmcli connection up testing
- If the testing connection is lost, the eno16777736 connection will attempt to autoconnect.
To administratively disable an interface and prevent any auto connection, use nmcli dev disconnect DEVICENAME.
[root@client ~]# nmcli con mod eno16777736 connection.autoconnect no (Turn off auto connection)
[root@client ~]# nmcli con mod eno16777736 ipv4.dns 8.8.8.8 (Configure a DNS server)
[root@client ~]# nmcli con mod eno16777736 +ipv4.dns 4.2.2.3 (Add another DNS server)
[root@client ~]# nmcli con mod eno16777736 +ipv4.address 10.0.0.1/24 (Add a secondary address)
[root@client ~]# nmcli con mod eno16777736 ipv4.method manual ipv4.address 192.168.1.10/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8
- The nmcli con mod will save the setting to the configuration files.
To activate the changes, the connection needs to be activated or reactivated.
[root@client ~]# nm-connection-editor (GUI version of nmcli)
Configuring Networking with nmtui:
[root@client ~]# nmtui
[root@client ~]# nmcli con down eno16777736 ; nmcli con up eno16777736
Editing Network Configuration Files:
[root@client ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
[root@client ~]# nmcli connection reload eno16777736
[root@client ~]# nmcli connection down eno16777736
[root@client ~]# nmcli connection up eno16777736
Configuring Host Names:
[root@client ~]# hostname
[root@client ~]# hostname master.redhat.com
[root@client ~]# vim /etc/hostname
[root@client ~]# hostnamectl (Display information about the system)
[root@client ~]# hostnamectl status (Display information about the system)
[root@client ~]# hostnamectl set-hostname www.redhat.com
- The static host name is stored in /etc/hostname. Previous versions of RHEL stored the hostname as a variable in the /etc/sysconfig/network file.
Configuring DNS:
[root@client ~]# cat /etc/resolv.conf
[root@client ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
DNS1=8.8.8.8
[root@client ~]# nmcli con mod eno16777736 ipv4.dns 8.8.8.8 (Configure a DNS server)
[root@client ~]# nmcli con mod eno16777736 +ipv4.dns 4.2.2.3 (Add another DNS server)
[root@client ~]# vim /etc/hosts
Configure Routing:
[root@client ~]# route -n (Display routing table)
[root@client ~]# ip route (Display routing table)
[root@client ~]# ip route show (Display routing table)
[root@client ~]# ip route add 20.0.0.0/8 via 192.168.1.1 (Add a static route)
[root@client ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
GATEWAY=192.168.1.1
[root@client ~]# nmcli con mod eno16777736 ipv4.gateway 192.168.1.1
Network tools:
[root@client ~]# ping -c 5 127.0.0.1
[root@client ~]# netstat -i (Packet information)
[root@client ~]# netstat -tulpen (Listening ports)
[root@client ~]# traceroute 8.8.8.8