5-2 Configure Networking and Hostname Resolution Statically or Dynamically: Network Manager Flashcards
/etc/sysconfig/network-scripts
ex:
cat /etc/sysconfig/network-scripts/ifcfg-eth0
Location of all configuration files for network cards, etc.
Each connection to system is a configuration, each configuration is attached to a device, each device has a configuration file
ex: for eth0
ls /sys/class/net
nmcli dev status
2 ways to
View which network cards are attached to the system, or to list all the devices.
Display a list of connections
nmcli con show
Display “device” status
nmcli dev status
Display help for adding connections
nmcli con add help
Add a connection
nmcli con add con-name
“nameofthecon” type ethernet ifname eth0
ifname is the name of the Ethernet device; can find them by doing ls /sys/class/net
By not specifying a gateway or IP, the connection will attempt to go with DHCP
nmcli con add con-name “nameofthecon”
ifname eth0 autoconnect no type Ethernet ip4 ipaddress gw4 gateway
autoconnect will automatically bring up the network connection when the system starts
Modify an existing network connection
ex:
nmcli con mod “nameofthecon”
ex:
nmcli con mod “nameofthecon” connection.autocorrect yes
cat /etc/sysconfig/network-scripts/ifcfg-nameofthecon
see if ONBOOT=yes, which means this configuration will automatically connect. if device set to DEVICE=eth0, it will connect to configuration to eth0 device
Press tab twice for auto complete to show options
After modifying a network connection, you should reload the configuration
nmcli con reload
List all devices
nmcli dev status
Turn off a network device
nmcli dev disconnect “device”
Turn on a network device
nmcli dev connect “device”
List all connections (connections are con gurations that are attached to a device)
nmcli con show
Activate or “bring up” a connection
nmcli con up “connectionname”
Deactivate or “bring down” a connection
nmcli con down “connectionname”
Delete a connection
nmcli con del “connectionname”
Change the method from static IP to DHCP
nmcli con mod “con-name ipv4.method manual
Example: Add static IP address to eno1 with an IP of 192.168.122.5/24 and gateway of 192.168.1.1
nmcli con mod eno1 ipv4.addresses “192.168.122.5/24 192.168.1.1”
nm-connection-manager
GUI interface to manage connections
nm (press tab twice)
to see commands that start with nm
nmtui
network manager text based gui to configure networking
nmcli con show –active
to display only active connections
nmcli con show “con-name”
to show a connection by name
dhcp vs static
static means manually configured
dhcp means the device is configured to find dhcp server to get its ip automatically assigned
these can be configuration differences on diff connection configuration files. Can be diff connections for same device, where connections can be switched between
See if a device is connected
nmcli dev show
Connected device has GENERAL.STATE has a (connected) value
How to see if a connection’s configuration is dhcp?
Inside /etc/sysconfig/network-scripts/ifcfg-nameofconnection
BOOTPROTO=dhcp
Start and Stop Network Manager
systemctl start NetworkManager
systemctl enable NetworkManager
systemctl restart network
If you get lost, use the man page for nmcli-examples to help when configuring nmcli