ubuntu@ubuntu:~$ cat /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: yes
dhcp6: no
ubuntu@ubuntu:~$
查看dhcp为yes,手动通过网口改ip没起作用
改为如下:
ubuntu@ubuntu:~$ cat /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: no
dhcp6: no
addresses: [172.16.4.161/24]
gateway4: 172.16.4.1
nameservers:
addresses: [114.114.114.114]
ubuntu@ubuntu:~$
然后调用
netplan apply
即可