Table of Contents

Configure Networking And Hostname Resolution Statically Or Dynamically

General Information

Networking has changed from RHEL 6 to 7. You can still edit network scripts in /etc/sysconfig/network-scripts/, but the “preferred” method is using front end tools that tie into the NetworkManager service.


Troubleshooting Tools

Show IP Address of Devices

ip addr show


Show all Established Connections

ss


Show Established and Listening TCP Connections

ss -ant

flags:


Other tools to use:


Network Manager

NetworkManager is the default network service in RHEL 7.


Open GUI for network connections (GUI Only)

nm-connection-editor


Open text based wizard

nmtui


CLI Tool: nmcli

nmcli makes configuration changes to files in: /etc/sysconfig/network-scripts/

These files can alternatively be modified manually.


Network Device Status

nmcli dev status


Show all connection configurations

nmcli con show


Example: Create new connection (dhcp)

nmcli con add con-name "mycon" autoconnect yes type ethernet ifname eth1


Example: Create new connection (static ip)

nmcli con add con-name "mycon-static" autoconnect yes type ethernet ifname eth1 ipv4.method manual ip4 10.0.0.5/24 gw4 10.0.0.254


Show only active connections

nmcli con show --active


Bring connections up/down

nmcli con down "mycon-static"
nmcli con up "mycon"


Change an existing connection's IP and Gateway

nmcli con mod eth0 ipv4.addresses 192.168.1.50/24
nmcli con mod eth0 ipv4.gateway 192.168.1.254
nmcli con mod eth0 ipv4.method manual
nmcli con up eth0

Hostname Configuration

View current hostname

hostname


Set temporary(transient) hostname

hostname myserver.domain.com
exec bash


View detailed hostname information

hostnamectl


Set persistent(static) hostname

hostnamectl set-hostname myserver.com


Order of name resolution (hosts entry)

/etc/nsswitch.conf
 
#....other entries above
 
# hosts: search local files and then DNS
hosts:      files dns
 
#....other entries below


System wide dns name server entries (static or network manager generated)

/etc/resolv.conf
 
# Generated by NetworkManager
search us-west-2.compute.internal
nameserver 172.31.0.2


Local system hostname resolution and example entry

/etc/hosts
 
# IP      Hostname                Aliases
10.1.1.2  myserver01.example.com  website.domain.com


Add DNS (not replace) for eth0 with nmcli or with config file