Configuring a Network Adapter - Paiet/Tech-Journal-for-Everything GitHub Wiki
- Configuration methods
- SysVinit (Script based)
-
systemd (Unit based)
- NetworkManager (RHEL)
- NetPlan (Ubuntu)
- Configuring adapters with interface scripts
- Used on SysVinit and similar systems
- RHEL used
/etc/sysconfig/network-scripts/ - Ubuntu used
/etc/network/interfaces - Global configurations
- Configurations that apply to all NICs
/etc/sysconfig/networkGATEWAY=192.168.0.1
DEVICE=eth0
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
ONBOOT=yes
NM_CONTROLLED=no
- Using the NetworkManager nmcli command
- Default in RHEL-based distributions
- Viewing connections
nmcli device statusnmcli device show <int_name>nmcli connection shownmcli connection show <int_name>
- Assigning a static IP
nmcli connection edit <int_name>set connection.autoconnect yesset ipv4.method manualset ipv4.addr 192.168.0.2/24set ipv4.dns 8.8.8.8set ipv4.gateway 192.168.0.1save <temporary/persistent>quit
- Resetting connections
nmcli connection reloadnmcli connection down <int_name>nmcli connection up <int_name>
- NetPlan advantages
- Cloud Init
- Configuration tests
- Simple YAML configuration
- Disable cloud-init
sudoedit /etc/cloud/cloud.cfg.d/99-disable-network-config.cfgnetwork: {config: disabled}
- Configuring an adapter with NetPlan
- Create network configuration
sudoedit /etc/netplan/config.yaml
- Create network configuration
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: false
addresses: [10.0.222.101/16]
gateway4: 10.0.0.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
- Apply a NetPlan configuration
sudo netplan trysudo netplan apply