Настройка сети в ubuntu server
Отредактирована 30.10.2025
admin@server:~$ cd /etc/netplan/ admin@server:/etc/netplan$ ls 50-cloud-init.yaml
admin@server:/etc/netplan$ sudo cat 50-cloud-init.yaml # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: (config: disabled) network: ethernets: enp0s3: dhcp4: true version: 2
admin@server:/etc/netplan$ sudo cp 50-cloud-init.yaml backup_50-cloud-init.yaml
admin@server:/etc/netplan$ sudo nano 50-cloud-init.yaml # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: version: 2 ethernets: enp0s3: # Имя интерфейса dhcp4: no dhcp6: no addresses: [192.168.1.4/24] # IP-адрес хоста routes: - to: default via: 192.168.1.1 # Шлюз nameservers: addresses: [8.8.8.8, 8.8.4.4] # DNS-сервера
admin@server:/etc/netplan$ sudo netplan apply