Red Hat Networking

This section describes both the old and new networking commands used by RHEL 6-8, you can view the current configuration by using the below command

Current Configuration
ls -l /proc/sys/net/ipv4/conf/

Network Manager Command Line Interface

You can shorten many of commands by only using the first character

General
nmcli g [status | logging | hostname | permissions]
Networking
nmcli n [on | off | connectivity]
Radio
nmcli r [all | wifi | wwan]
Connection
nmcli c [ show | up | down | add | modify | edit | delete | reload | load ]
Device
nmcli d [ status | show | connect | disconnect | delete | wifi ]
Agent
nmcli a [ secret | polkit | all ]

There is a old fashioned GUI that you can use regarding the Network Manager

Start
nmtui
Edit
nmtui edit <device>
Connection
nmtui connection <device>
Hostname
nmtui hostname <new hostname>

IP Commands

You can configure a network interface using the ip command, but changes are not persistent across reboots; when you reboot, you will lose any changes.

Address commands
ip addr show
ip addr add <IP address> dev <device>
ip addr del <IP address> dev <device>
Link commands
ip link show
ip link set <device> up
ip link set <device> down
Route commands
ip route show
ip route add <network or host> via <gateway> dev <device>
ip route del <network or host>
ip route add default via <gateway>
ip route replace <network or host> dev <device>
ip route get <IP address>

vi /etc/sysconfig/network-scripts/route-<device>
Neighbour Objects commands
ip neigh show							show ARP
ip neigh add <IP address> lladdr <mac address> dev <device>
ip neigh del <IP address> dev <device>
ip neigh replace <IP address> lladdr <mac address> dev <device>
MultiCast Address commands
ip maddr show							show ARP
ip maddr add <multicast address> dev <device>
ip maddr del <multicast address> dev <device>

Hostnamectl Command

The hostnamectl tool is provided for administering the three separate classes of host names in use on a given system.

Hostnamectl commands
hostnamectl
hostnamectl set-hostname <new hostname>
hostnamectl set-hostname <name>      		# Set system hostname
hostnamectl set-icon-name <name>     		# Set icon name for host
hostnamectl set-chassis <name>       		# Set chassis type for host
hostnamectl set-deployment <name>    		# Set deployment environment for host
hostnamectl set-location <name>      		# Set location for host

SS Commands

ss is a command-line utility that prints statistical information about sockets, allowing administrators to assess device performance over time.

ss Commands
ss -a		# Show all sockets (listening and non-listening)
ss -e		# Show detailed socket information
ss -o		# Show timer information
ss -n		# Do not resolve addresses
ss -p		# Show process using the socket
ss -l		# Show listening sockets
ss -s		# Show socket summary

ethtool Commands

Some Introduction

ethtool Commands
ethtool			# Query or control network driver and hardware settings
ethtool -g eth0		# Display ring buffer for eth0
ethtool -i eth0		# Display driver information for eth0
ethtool -p eth0		# Identify eth0 by sight, typically by causing LEDs to blink on the network port
ethtool -S eth0		# Display network and driver statistics for eth0

arp Commands

ARP stands for Address Resolution Protocol, which is used to find the address of a network neighbor for a given IPv4 address.

arp Commands
arp -a
arp -v
arping -I eth0 192.168.1.1 		# Send ARP request to 192.168.1.1 via interface eth0
arping -D -I eth0 192.168.1.1 		# Check for duplicate MAC addresses at 192.168.1.1 on eth0

Net-Tool and IP Equivalent

Some Introduction

NET-TOOLS IPROUTE
arp -a ip neigh
arp -v ip -s neigh
arp -s 192.168.1.1 1:2:3:4:5:6 ip neigh add 192.168.1.1 lladdr 1:2:3:4:5:6 dev eth1
arp -i eth1 -d 192.168.1.1 ip neigh del 192.168.1.1 dev eth1
ifconfig -a ip addr
ifconfig eth0 down ip link set eth0 down
ifconfig eth0 up ip link set eth0 up
ifconfig eth0 192.168.1.1 ip addr add 192.168.1.1/24 dev eth0
ifconfig eth0 netmask 255.255.255.0 ip addr add 192.168.1.1/24 dev eth0
ifconfig eth0 mtu 9000 ip link set eth0 mtu 9000
ifconfig eth0:0 192.168.1.2 ip addr add 192.168.1.2/24 dev eth0
netstat ss
netstat -neopa ss -neopa
netstat -g ip maddr
route ip route
route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0 ip route add 192.168.1.0/24 dev eth0
route add default gw 192.168.1.1 ip route add default via 192.168.1.1

Network Teaming Commands

Some Introduction

Teaming Commands
nmtui										# use to add new NIC's teaming, bonding, etc (GUI)
nmcli con show									# list the NIC's

runner types: activebackup, loadbalance, lacp, roundrobin (example below is using loadbalance)								

# create team interface (network-scripts/ifcfg-myteam0 would be created)
nmcli con add type team con-name myteam0 ifname team0 config '{ "runner": {"name": "loadbalance"}}'

nmcli con show myteam0								# show the teaming properties
nmcli con mod myteam0 team.config '{ "runner": {"name": "activebackup"}}'	# change runner (or another property)

nmcli con reload								# reload connection

nmcli con mod myteam0 ipv4.addresses 192.168.1.10/24				# update ifcfg-myteam0 file
nmcli con mod myteam0 ipv4.gateway 192.168.1.1
nmcli con mod myteam0 ipv4.method manual

nmcli con add type team-slave con-name team0-slave0 ifname ens224 master team0 	# add ens224 interface (creates ifcfg-team0-slave0 file)
nmcli con add type team-slave con-name team0-slave1 ifname ens256 master team0 	# add ens224 interface (creates ifcfg-team0-slave1 file)

nmcli connection up team0-slave0						# bring up the slave interface
nmcli connection up team0-slave1						# bring up the slave interface
	
nmcli con up myteam0								# display the NIC configuration

teamdctl team0 state								# see the team status
teamdctl team0 config dump							# dump the team configuration
teamnl team0 ports 								# see the team ports
teamnl team0 options								# list teaming options

nmcli dev dis ens224								# disconnect a port to test teaming is working
nmcli dev con ens224								# reconnect port

nmcli con del team0-slave0							# remove the configuration (removes network-script files)
nmcli con del team0-slave1
nmcli con del myteam0

Network Bridging Commands

brctl command allows you to setup network bridging

brctl Commands
brctl show

brctl addbr br0

ifconfig ens224 0.0.0.0 down
ifconfig ens256 0.0.0.0 down

brctl addif br0 ens224
brctl addif br0 ens256

ifconfig ens224 up
ifconfig ens256 up
ifconfig br0 up

VLAN Commands

VLANs can be setup using the below commands

VLAN Commands
nmcli con add type vlan con-name vlan10 dev ens224 id 10		# created a ifcfg-vlan10 in network-scripts
nmcli con mod vlan10 ipv4.addresses 192.168.50.181/24			# modify/add the above
nmcli con mod vlan10 ipv4.gateway 192.168.50.2
nmcli con mod vlan10 ipv4.method manual
nmcli con up vlan10							# start the vlan

nmcli dev								# confirm that the vlan is working