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/network
GATEWAY=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 status
nmcli device show <int_name>
nmcli connection show
nmcli connection show <int_name>
- Assigning a static IP
nmcli connection edit <int_name>
set connection.autoconnect yes
set ipv4.method manual
set ipv4.addr 192.168.0.2/24
set ipv4.dns 8.8.8.8
set ipv4.gateway 192.168.0.1
save <temporary/persistent>
quit
- Resetting connections
nmcli connection reload
nmcli 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.cfg
network: {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 try
sudo netplan apply