RHEL Networking
This is based on RHEL 7,8, and 9.
???????? ????????
systemctl enable network # does this exist?
/etc/init.d/network # does this exist?
????? ?????
- does nmcli automatically save?
- are sysconfig scripts automatically copied to the network manager location?
Format for network configuration files:
- ifcfg format # current default
- key file format # future default ( can set manually )
/etc/NetworkManager/ | VPN, mobile, PPPoE |
/etc/sysconfig/ | most network config info |
/etc/sysconfig/network-scripts/ | |
/etc/sysconfig/network | |
/etc/NetworkManager/system-connections/ | net manager configs go here |
/run/NetworkManager/system-connections/ | temporary until reboot |
/usr/lib/NetworkManager/system-connections/ | default uneditable |
Load config file into Network Manager:
nmcli connection load /etc/sysconfig/network-scripts/ifcfg-connection_name
Static interfaces with ifcfg format:
/etc/sysconfig/network-scripts/ifcfg-enp1s0DEVICE=enp1s0 BOOTPROTO=none ONBOOT=yes PREFIX=24 IPADDR=10.0.1.27 GATEWAY=10.0.1.1
Using IPv6:
/etc/sysconfig/network-scripts/ifcfg-enp1s0DEVICE=enp1s0 BOOTPROTO=none ONBOOT=yes IPV6INIT=yes IPV6ADDR=2001:db8:1::2/64
Using DHCP:
/etc/sysconfig/network-scripts/ifcfg-enp1s0DEVICE=enp1s0 BOOTPROTO=dhcp ONBOOT=yes
Pass specific hostname to DHCP server ( only use one of these ):
DHCP_HOSTNAME=hostname
DHCP_FQDN=fully.qualified.domain.name
Use specific DNS servers:
PEERDNS=no
DNS1=ip-address
DNS2=ip-address
Key file format example:
[connection]
id=example_connection
type=802-3-ethernet
autoconnect=true
[ipv4]
method=auto
[ipv6]
method=auto
[802-3-ethernet]
mac-address=00:53:00:8f:fa:66
!!!!!! need static example !!!!!!1
chown root:root /etc/NetworkManager/system-connections/example.nmconnection
chmod 600 /etc/NetworkManager/system-connections/example.nmconnection
nmcli connection reload # reload profile
nmcli -f NAME,UUID,FILENAME connection # verify
Check connection status:
nmcli connection show
nmcli connection show enp1s0
nmcli device status
Add connection and modify it with nmcli:
nmcli connection add con-name Example-Connection ifname enp7s0 type ethernet
nmcli connection modify Example-Connection ipv4.addresses 192.0.2.1/24
nmcli connection modify Example-Connection ipv6.addresses 2001:db8:1::1/64
nmcli connection modify Example-Connection ipv4.method manual
nmcli connection modify Example-Connection ipv6.method manual
nmcli connection modify Example-Connection ipv4.gateway 192.0.2.254
nmcli connection modify Example-Connection ipv6.gateway 2001:db8:1::fffe
nmcli connection modify Example-Connection ipv4.dns "192.0.2.200"
nmcli connection modify Example-Connection ipv6.dns "2001:db8:1::ffbb"
nmcli connection modify Example-Connection ipv4.dns-search example.com
nmcli connection modify Example-Connection ipv6.dns-search example.com
sudo nmcli connection modify enp1s0 +ipv4.routes "192.0.2.0/24 198.51.100.1"
sudo nmcli connection up enp1s0
sudo nmcli connection down enp1s0
Load new config into network manager:
nmcli connection load /etc/sysconfig/network-scripts/ifcfg-connection_name
Update existing network manager config:
nmcli connection up connection_name
Set unmanaged devices:
/etc/NetworkManager/conf.d/99-unmanaged-devices.conf[keyfile] unmanaged-devices=interface-name:enp1s0;enp1s1
Reload Network Manager and check status:
systemctl reload NetworkManager
nmcli device status
- nmtui
- nmcli
- nm-connection-editor
- ifup
- ifdown
Save and load configuration:
nmstatectl show enp1s0 > ~/network-config.yml # save current state to a config file
nmstatectl apply ~/network-config.yml # load state from config file
RHEL DNS
/etc/resolv.conf # configured by network manager based on interface configs /etc/NetworkManager/NetworkManager.conf # set DNS priority for interfaces here
Disable using NetworkManager for DNS so that it won’t overwrite /etc/resolv.conf:
/etc/NetworkManager/conf.d/90-dns-none.conf [main] dns=none
systemctl reload NetworkManager
Also, if /etc/resolv.conf is a symlink, it won’t be overwritten by
RHEL 8 WIFI
nmcli radio wifi on # turn radio on
nmcli radio wifi off # turn radio off
nmcli device wifi rescan # refresh
nmcli dev wifi list # view APs
nmcli dev wifi connect MyCafe password wireless-password # connect
nmcli dev wifi connect MyCafe password wireless_password hidden yes # connect to hidden network
nmcli con add con-name MyCafe ifname wlan0 type wifi ssid MyCafe ` `ip4 192.168.100.101/24 gw4 192.168.100.1
nmcli con modify con-name MyCafe ipv4.dns "192.160.100.1"
nmcli con modify con-name MyCafe ipv4.dns-search "example.com"
Other RHEL Network Topics:
- VXLAN
- Bridging
- Teaming
- Bonding
- VPN
- IP tunnels
- Fibre channel
- Port mirroring