我正在尝试设置一个桥接接口以用于 KVM 客户端。我可以成功地通过 SSH 连接到同一网络上的其他计算机。我也可以ping 8.8.8.8
直接这样做。但是,当我尝试时,ping google.com
我得到:ping: google.com: Name or service not known
。因此,路由等似乎工作正常,但DNS
事实并非如此。任何帮助都将不胜感激。这是我当前的 netplan 配置:
# This is the network config written by 'subiquity'
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: yes
bridges:
br0:
interfaces: [enp2s0]
addresses: [10.0.0.20/24]
routes:
- to: default
via: 10.0.0.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
search: []
parameters:
stp: false
forward-delay: 0
dhcp4: no
我在 中没有看到任何有趣的东西sudo netplan --debug apply
。以下是输出:
** (generate:7576): DEBUG: 16:06:02.092: starting new processing pass
** (generate:7576): DEBUG: 16:06:02.092: br0: adding new route
** (generate:7576): DEBUG: 16:06:02.092: We have some netdefs, pass them through a final round of validation
** (generate:7576): DEBUG: 16:06:02.092: enp2s0: setting default backend to 1
** (generate:7576): DEBUG: 16:06:02.092: Configuration is valid
** (generate:7576): DEBUG: 16:06:02.092: br0: setting default backend to 1
** (generate:7576): DEBUG: 16:06:02.092: Configuration is valid
** (generate:7576): DEBUG: 16:06:02.093: Generating output files..
** (generate:7576): DEBUG: 16:06:02.093: openvswitch: definition enp2s0 is not for us (backend 1)
** (generate:7576): DEBUG: 16:06:02.093: NetworkManager: definition enp2s0 is not for us (backend 1)
** (generate:7576): DEBUG: 16:06:02.093: openvswitch: definition br0 is not for us (backend 1)
** (generate:7576): DEBUG: 16:06:02.093: NetworkManager: definition br0 is not for us (backend 1)
(generate:7576): GLib-DEBUG: 16:06:02.093: posix_spawn avoided (fd close requested)
(generate:7576): GLib-DEBUG: 16:06:02.096: posix_spawn avoided (fd close requested)
DEBUG:netplan generated networkd configuration changed, reloading networkd
DEBUG:enp2s0 not found in {}
DEBUG:br0 not found in {}
DEBUG:Merged config:
network:
bridges:
br0:
addresses:
- 10.0.0.20/24
dhcp4: false
interfaces:
- enp2s0
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
search: []
parameters:
forward-delay: 0
stp: false
routes:
- to: default
via: 10.0.0.1
ethernets:
enp2s0:
dhcp4: true
renderer: networkd
version: 2
DEBUG:no netplan generated NM configuration exists
DEBUG:enp2s0 not found in {}
DEBUG:br0 not found in {}
DEBUG:Merged config:
network:
bridges:
br0:
addresses:
- 10.0.0.20/24
dhcp4: false
interfaces:
- enp2s0
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
search: []
parameters:
forward-delay: 0
stp: false
routes:
- to: default
via: 10.0.0.1
ethernets:
enp2s0:
dhcp4: true
renderer: networkd
version: 2
DEBUG:Link changes: {}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp2s0
DEBUG:netplan triggering .link rules for br0
DEBUG:netplan triggering .link rules for vnet0
** (process:7574): DEBUG: 16:06:02.790: starting new processing pass
** (process:7574): DEBUG: 16:06:02.790: br0: adding new route
** (process:7574): DEBUG: 16:06:02.790: We have some netdefs, pass them through a final round of validation
** (process:7574): DEBUG: 16:06:02.791: enp2s0: setting default backend to 1
** (process:7574): DEBUG: 16:06:02.791: Configuration is valid
** (process:7574): DEBUG: 16:06:02.791: br0: setting default backend to 1
** (process:7574): DEBUG: 16:06:02.791: Configuration is valid
DEBUG:enp2s0 not found in {}
DEBUG:br0 not found in {}
DEBUG:Merged config:
network:
bridges:
br0:
addresses:
- 10.0.0.20/24
dhcp4: false
interfaces:
- enp2s0
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
search: []
parameters:
forward-delay: 0
stp: false
routes:
- to: default
via: 10.0.0.1
ethernets:
enp2s0:
dhcp4: true
renderer: networkd
version: 2
答案1
不确定这是否真的是答案,但我确实设法解决了我的问题,所以我至少可以结束这个问题。无论如何,这是一个新的服务器设置,所以我刚刚重新安装了 Ubuntu 并从头开始,由于某种原因它现在可以正常工作了,所以不确定我到底做了什么来修复它。但作为参考,这是我最终得到的最终 netplan 配置:
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
dhcp4: false
dhcp6: false
bridges:
br0:
interfaces: [enp2s0]
addresses: [10.0.0.20/24]
gateway4: 10.0.0.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
parameters:
stp: false
forward-delay: 0
dhcp4: no
dhcp6: no