1. Определяем какие сетевые карты у нас есть
sudo lshw -C network
в тексте ищем имя сетевой карты
root@ubuntu:/home/zloyadmin# sudo lshw -C network
*-network
description: Ethernet interface
product: AR8161 Gigabit Ethernet
vendor: Qualcomm Atheros
physical id: 0
bus info: pci@0000:02:00.0
logical name: enp2s0
version: 10
serial: 90:2b:34:57:67:39
size: 1Gbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm pciexpress msi msix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=alx duplex=full ip=192.168.0.198 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
resources: irq:29 memory:f7c00000-f7c3ffff ioport:e000(size=128)
2. Редактируем файл настоек.
Версия Ubuntu 16 и старше.
Файл с сетевыми настройками /etc/network/interfaces
Вариант получения IP адреса от DHCP сервера
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp2s0
iface enp2s0 inet dhcp
Вариант ручной установки IP адреса
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp2s0
iface enp2s0 inet static
address 195.77.196.201
netmask 255.255.255.0
network 195.77.195.0
broadcast 195.13.196.255
gateway 195.77.196.193
dns-nameservers 8.8.8.8 195.122.12.241
dns-search sait.lv
Версия Ubuntu 18.
Файл с сетевыми настройками /etc/netplan/01-netcfg.yaml
Вариант получения IP адреса от DHCP сервера
network:
ethernets:
enp2s0:
addresses: []
dhcp4: true
version: 2
Вариант ручной установки IP адреса
network:
renderer: networkd
ethernets:
enp2s0:
addresses: [195.13.196.197/28]
gateway4: 195.13.196.193
dhcp4: no
dhcp6: no
nameservers:
addresses: [8.8.8.8,8.8.4.4,195.122.12.241]
version: 2
Проверка на наличие ошибок в синтаксисе
sudo netplan try
Версия Ubuntu 20.
Файл с сетевыми настройками /etc/netplan/00-installer-config.yaml
Вариант получения IP адреса от DHCP сервера
network:
ethernets:
enp2s0:
dhcp4: true
version: 2
Вариант ручной установки IP адреса
network:
ethernets:
enp2s0:
addresses:
- 195.13.196.202/24
gateway4: 195.13.196.193
nameservers:
addresses:
- 8.8.8.8
- 195.122.12.241
search:
- data.rai.lv
version: 2
Проверка на наличие ошибок в синтаксисе
sudo netplan try