To view network adapter drivers, run:
lspci -k | grep -A2 Ethernet
You can see the list of network interfaces with the command:
ls /sys/class/net
Let's say our interface is called "ens33".
Interface settings using the "ip" utility.
ip link show #View network connections
ip -s l #View statistics on sent/received packets
ip address show #View TCP/IP configuration
ip link set dev ens33 up #Enable the interface if it was disabled
ip address flush dev ens33 #Reset interface configuration
ip addr add 192.168.0.5/24 broadcast + dev ens33 #Set IP and mask
ip addr del 192.168.0.5/24 dev ens33 #Delete IP and mask (in case of error)
ip route show #View routing table
ip route add default via 192.168.0.1 dev ens33 #Set default gateway
ip route delete default #Delete default gateway
ip route add 192.168.10.0/24 via 192.168.0.254 dev ens33 #Add route
ip route del 192.168.10.0/24 dev ens33 #Delete route
echo "nameserver 192.168.0.1 8.8.8.8" | sudo tee /etc/resolv.conf #Add DNS
These settings are temporary and will work until the OS is rebooted.
Setting up the "Etcnet" network subsystem.
1. Install the package and start the service:
sudo apt-get install etcnet
sudo systemctl enable --now network
2. To set up the interface, you need to create or edit existing files in the "/etc/net/ifaces/ens33/" directory, where "ens33" is the name of the network interface.
Configure the following parameters in the "options" file:
For DHCP:
BOOTPROTO=dhcp #Use DHCP
TYPE=eth
CONFIG_WIRELESS=no
SYSTEMD_BOOTPROTO=dhcp4
CONFIG_IPV4=yes #Enables IPv4 support for the interface
DISABLED=no #Yes - when Etcnet is not used
NM_CONTROLLED=no #Yes-when NetworkManager is used
SYSTEMD_CONTROLLED=no #Yes-when Systemd-Networkd is used
ONBOOT=yes #Activates the interface when the system boots
For static IP:
BOOTPROTO=static #Use static IP
TYPE=eth
CONFIG_WIRELESS=no
SYSTEMD_BOOTPROTO=static
CONFIG_IPV4=yes #Enables IPv4 support for the interface
DISABLED=no #Yes - when Etcnet is not used
NM_CONTROLLED=no #Yes-when NetworkManager is used
SYSTEMD_CONTROLLED=no #Yes-when Systemd-Networkd is used
ONBOOT=yes #Activates the interface when the system boots
Create a file next to it called "ipv4address" with the following content:
192.168.0.5/24 #IP and mask
Create a file next to it called "ipv4route" with the following content:
default via 192.168.0.1 #Default gateway
192.168.10.0/24 via 192.168.0.254 #Static routes
Create a file next to it called "resolv.conf" with the following content:
nameserver 192.168.0.1 #DNS1
nameserver 8.8.8.8 #DNS2
3. Restart the interface:
sudo ifdown ens33 && sudo ifup ens33
or the service:
sudo systemctl restart network
4. Perform configuration checks:
ip address show
ip route show
resolvconf -l
If you need to remove "Etcnet" components, run:
sudo apt-get remove etcnet
sudo rm -f /etc/net
sudo rm -f /etc/resolv.conf #Remove symlink
Setting up the "NetworkManager" network subsystem.
1. Install NetworkManager:
sudo apt-get install NetworkManager
2. Enable and start the service:
sudo systemctl enable --now NetworkManager
3. Configure the network interface using the terminal utility "nmtui" ("sudo apt-get install NetworkManager-tui") or in the command line with the utility "nmcli":
View:
nmcli con show #View network connections
nmcli dev show ens33 #View active connection on "ens33"
nmcli con show 'Wired connection 1' #View connection parameters
Settings for DHCP:
nmcli con mod 'Wired connection 1' ipv4.method auto
nmcli con mod 'Wired connection 1' ipv4.addresses "" ipv4.gateway ""
nmcli con mod 'Wired connection 1' ipv4.dns ""
nmcli con mod 'Wired connection 1' ipv4.routes ""
nmcli con up 'Wired connection 1'
Settings for static IP:
nmcli con mod 'Wired connection 1' ipv4.addresses 192.168.0.5/24
nmcli con mod 'Wired connection 1' ipv4.gateway 192.168.0.1
nmcli con mod 'Wired connection 1' ipv4.dns "192.168.0.1 8.8.8.8"
nmcli con mod 'Wired connection 1' +ipv4.routes "192.168.10.0/24 192.168.0.254"
nmcli con mod 'Wired connection 1' ipv4.method manual
nmcli con up 'Wired connection 1'
4. Perform configuration checks:
ip address show
ip route show
resolvconf -l
If you need to remove the "NetworkManager" components, run:
sudo apt-get remove NetworkManager openresolv
sudo rm -rf /etc/NetworkManager/ #Remove basic settings
sudo rm -rf /var/lib/NetworkManager/ #Remove service data
sudo rm -f /etc/resolv.conf #Remove symlink
Setting up the network subsystem "systemd-networkd".
1. Install the services "systemd-networkd" and "systemd-resolved", add them to autorun:
sudo apt-get install systemd-networkd
sudo systemctl enable --now systemd-networkd
sudo systemctl enable --now systemd-resolved
2. Create a configuration file (the extension ".network" is required):
sudo nano /etc/systemd/network/20-wired.network
For DHCP:
[Match]
Name=ens33
[Network]
DHCP=ipv4
For static IP:
[Match]
Name=ens33
[Network]
Address=192.168.0.5/24
Gateway=192.168.0.1
DNS=192.168.0.1 8.8.8.8
[Route]
Destination=192.168.10.0/24
Gateway=192.168.0.254
Metric=10 #Optional
3. Restart the service:
sudo systemctl restart systemd-networkd
4. Perform configuration checks:
ip address show
ip route show
resolvectl
If you need to remove "systemd-networkd" components, run:
sudo systemctl stop systemd-networkd systemd-resolved
sudo apt-get remove systemd-networkd
sudo rm -rf /etc/systemd/network/* #Remove network interface configurations
sudo rm -f /etc/resolv.conf #Remove symlink
General recommendations!!!
For simple server and virtual machine configurations, use "systemd-networkd", all other modules are recommended to be removed in this case:
sudo apt-get remove etcnet NetworkManager openresolv dhcpcd
sudo rm -rf /etc/net #Remove Etcnet settings
sudo rm -rf /etc/NetworkManager/ #Remove basic NM settings
sudo rm -rf /var/lib/NetworkManager/ #Remove NM service data
sudo rm -f /etc/resolv.conf #Remove symlink
No comments:
Post a Comment