网卡没有ip

image.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[root@ningan netplan]# cat 01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
eth0:
dhcp4: yes
dhcp6: yes
eth1:
dhcp4: no
dhcp6: no
addresses:
- 192.168.20.201/24
routes:
- to: default
via: 192.168.20.20
nameservers:
addresses:
- 114.114.114.114
- 8.8.8.8

[root@ningan netplan]# netplan apply

(generate:22000): GLib-WARNING **: 23:11:36.612: GError set over the top of a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
The overwriting error message was: /etc/netplan/01-network-manager-all.yaml:15:9: Error in network definition: unicast route must include both a 'to' and 'via' IP
- to: default
^
/etc/netplan/01-network-manager-all.yaml:15:15: Error in network definition: invalid IP family '-1'
- to: default
^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
eth0:
dhcp4: true
eth1: # 配置网卡的名称,通过 ip a 命令查看
dhcp4: false # 关闭 DHCP,如果需要打开 DHCP 则写 true
addresses: [192.168.20.201/24] # 配置的静态 IP 地址和掩码
optional: true
gateway4: 192.168.20.20 # 网关地址
nameservers:
addresses: [8.8.8.8,114.114.114.114] # DNS 服务器地址,多个 DNS 服务器地址需要用英文逗号分隔开

网卡没有ip
http://example.com/2022/12/28/net/网卡没有ip/
作者
ningan123
发布于
2022年12月28日
许可协议