Chapter 12

MANAGING NETWORKING

  • Ethernet interfaces begin with en

  • WLAN interfaces begin with wl

  • WWAN interfaces begin with ww

  • oN indicates that this is an on-board device and the server's firmware provided index number N for the device. So eno1 is on-board Ethernet device 1. Many servers will not provide this information.

  • sN indicates that this device is in PCI hotplug slot N. So ens3 is an Ethernet card in PCI hotplug slot 3.

  • pMsN indicates that this is a PCI device on bus M in slot N. So wlp4s0 is a WLAN card on PCI bus 4 in slot 0. If the card is a multi-function device (possible with an Ethernet card with multiple ports, or devices that have Ethernet plus some other functionality), you may see fN added to the device name. So enp0s1f0 is function 0 of the Ethernet card on bus 0 in slot 1. There might also be a second interface named enp0s1f1 that is function 1 of that same device.

ip tool

ip command can be used in order to give static ip to operating system:

# to list available devices:
ip link show

# add static ipv4 address to device ens160
sudo ip addr add 192.168.207.133/24 dev ens160

# to bring up state device ens160:
sudo ip link set ens160 up

# to add ipv4 gateway to device:
sudo ip route add default via 192.168.207.1

nmcli tool

Usecase example, To add a new network connection named "mylaman2" and configure it to use the ens160 device with a static IP address of 192.168.207.129/24 and a gateway of 192.168.207.1, you would generally follow these steps on a Linux system using the NetworkManager command-line tool (nmcli). Here's how you can do it:

In case you need to change the ipv4 address of currently active connection:

ifcfg scripts

Note: ifcfg configuration should be added, but I was lazy.

We can also add new connection via this method:

COMMAND
PURPOSE

Show the NetworkManager status of all network interfaces.

List all connections.

nmcli con show name

List the current settings for the connection name.

nmcli con add con-name name

Add a new connection named name.

nmcli con mod name

Modify the connection name.

Reload the configuration files (useful after they have been edited by hand).

nmcli con up name

Activate the connection name.

nmcli dev dis dev

Deactivate and disconnect the current connection on the network interface dev.

nmcli con del name

Delete the connection name and its configuration file.

Last updated

Was this helpful?