代码改变世界

ubuntu20.04固定ip

2023-05-29 16:59  丨o聽乄雨o丨  阅读(93)  评论(0编辑  收藏  举报

1. 编辑 01-network-manager-all.yaml 文件:

1 sudo vim /etc/netplan/01-network-manager-all.yaml

加入下面内容:

 1 # Let NetworkManager manage all devices on this system
 2 network:
 3   version: 2
 4   renderer: NetworkManager
 5   ethernets:
 6     eno1:
 7       dhcp4: no
 8       dhcp6: no
 9       addresses: [172.16.21.166/24]
10       gateway4: 172.16.21.254
11       nameservers:
12         addresses: [8.8.8.8, 114.114.114.114]

eno1为网卡名。

需要指定的内容为(从上而下)ip、gateway、dns server。

2. 应用修改

1 sudo netplan apply