learning_record_doc/linux/ubuntu/Ubuntu netplan 网络配置.md

32 lines
594 B
Markdown
Raw Permalink Normal View History

2022-02-28 23:07:00 +08:00
### Ubuntu netplan 网络配置
+ ##### 找到配置文件
```shell
cd /etc/netplan
sudo vim ***-config.yaml
```
+ ##### 配置netplan
```shell
配置如下:
network:
ethernets:
enp4s0: #网卡名称 我这里默认是enp4s0
addresses: [192.168.0.20/24] #IP地址
gateway4: 192.168.0.1 # 网关
nameservers:
addresses: [114.114.114.114, 192.168.0.1] #DNS
dhcp4: no
optional: no
version: 2
```
+ ##### 启用生效
```shell
sudo netplan apply
```