创建网桥后出现网络问题

创建网桥后出现网络问题

我想使用 KVM 在我的服务器上安装一些虚拟机,因此我创建了一个网桥。到目前为止一切顺利...

我的操作系统是Ubuntu 20.04

我改变了01-netcfg.yaml归档/etc/netplan

前:

network:
  version: 2
  renderer: networkd
  ethernets:
   enp5s0:
    dhcp4: no
    addresses: [192.168.192.222/24]
    gateway4: 192.168.192.1
    nameservers:
     addresses: [8.8.8.8]
     search: [example.net]

至之后:

network:
  version: 2
  renderer: networkd

  ethernets:
   enp5s0:
    dhcp4: false
    dhcp6: false
#    addresses: [192.168.192.222/24]
#    gateway4: 192.168.192.1
#    nameservers:
#     addresses: [8.8.8.8]
#     search: [example.net]
  bridges:
    br0:
      interfaces: [enp5s0]
      dhcp4: no
      dhcp6: no
      addresses: [192.168.192.222/24]
      gateway4: 192.168.192.1
      mtu: 1500
      nameservers:
        addresses: [8.8.8.8]
      parameters:
        stp: true
        forward-delay: 4

我注册了这座桥并且没有遇到任何错误。

在 /等/网络计划我得到了一个主机桥接器.xml文件:

<network>
  <name>host-bridge</name>
  <forward mode="bridge"/>
  <bridge name="br0"/>
</network>

但是...几个小时后,我与服务器的 ssh 连接消失了。我进入物理机并尝试 ping:

ping google.de -> 成功

ping 路由器 -> 错误

ping 局域网内的其他机器 -> 错误

之后我播放了我最初的 .yaml 配置文件,应用了 netplan,重新启动了......

一切又恢复正常了。

再次设置桥接后,我重现了此错误 -> 几个小时后又发生了同样的事情。播放原始 .yaml 文件有所帮助。

所以在我看来,桥接是导致错误的原因。您能告诉我解决方案是什么吗?

下面我向您发送命令和附加文件的输出:

输出知识产权

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 04:92:26:5d:0b:b7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.192.222/24 brd 192.168.192.255 scope global enp5s0
       valid_lft forever preferred_lft forever
    inet6 fe80::692:26ff:fe5d:bb7/64 scope link 
       valid_lft forever preferred_lft forever
3: enp3s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 00:15:17:a6:4e:58 brd ff:ff:ff:ff:ff:ff
4: enp3s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 00:15:17:a6:4e:59 brd ff:ff:ff:ff:ff:ff
5: enp6s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 00:1b:21:a3:b3:8e brd ff:ff:ff:ff:ff:ff
6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 04:92:26:5d:0b:b7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.192.222/24 brd 192.168.192.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::692:26ff:fe5d:bb7/64 scope link 
       valid_lft forever preferred_lft forever

输出路由

default via 192.168.192.1 dev enp5s0 
default via 192.168.192.1 dev br0 proto static 
192.168.192.0/24 dev enp5s0 proto kernel scope link src 192.168.192.222 
192.168.192.0/24 dev br0 proto kernel scope link src 192.168.192.222

输出网络状态监测

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.192.1   0.0.0.0         UG        0 0          0 enp5s0
0.0.0.0         192.168.192.1   0.0.0.0         UG        0 0          0 br0
192.168.192.0   0.0.0.0         255.255.255.0   U         0 0          0 enp5s0
192.168.192.0   0.0.0.0         255.255.255.0   U         0 0          0 br0

输出networkctl -a 状态

● 1: lo                                                     
             Link File: /lib/systemd/network/99-default.link
          Network File: n/a                                 
                  Type: loopback                            
                 State: carrier (unmanaged)                 
                   MTU: 65536                               
  Queue Length (Tx/Rx): 1/1                                 
               Address: 127.0.0.1                           
                        ::1                                 

● 2: enp5s0                                                                      
             Link File: /lib/systemd/network/99-default.link                     
          Network File: /run/systemd/network/10-netplan-enp5s0.network           
                  Type: ether                                                    
                 State: routable (configuring)                                   
                  Path: pci-0000:05:00.0                                         
                Driver: r8169                                                    
                Vendor: Realtek Semiconductor Co., Ltd.                          
                 Model: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
            HW Address: 04:92:26:5d:0b:b7 (ASUSTek COMPUTER INC.)                
                   MTU: 1500 (min: 60, max: 9200)                                
  Queue Length (Tx/Rx): 1/1                                                      
      Auto negotiation: yes                                                      
                 Speed: 1Gbps                                                    
                Duplex: full                                                     
                  Port: mii                                                      
               Address: 192.168.192.222                                          
                        fe80::692:26ff:fe5d:bb7                                  
               Gateway: 192.168.192.1                                            
                   DNS: 192.168.192.1                                            
        Search Domains: fritz.box                                                
          Connected To: Wifi2ndFloor on port 18:e8:29:69:ae:23 (br0)             
                        n/a on port 2c:56:dc:72:32:0c                            
                        UBNT on port e0:63:da:17:95:2b (br0)                     

Aug 02 13:59:30 hal9999 systemd-networkd[2380]: enp5s0: Gained IPv6LL
Aug 02 15:21:21 hal9999 systemd-networkd[3548]: enp5s0: Gained IPv6LL

● 3: enp3s0f0                                                                                                                         
             Link File: /lib/systemd/network/99-default.link                                                                          
          Network File: n/a                                                                                                           
                  Type: ether                                                                                                         
                 State: no-carrier (unmanaged)                                                                                        
                  Path: pci-0000:03:00.0                                                                                              
                Driver: e1000e                                                                                                        
                Vendor: Intel Corporation                                                                                             
                 Model: 82571EB/82571GB Gigabit Ethernet Controller D0/D1 (copper applications) (PRO/1000 PT Dual Port Server Adapter)
            HW Address: 00:15:17:a6:4e:58 (Intel Corporate)                                                                           
                   MTU: 1500 (min: 68, max: 9212)                                                                                     
  Queue Length (Tx/Rx): 1/1                                                                                                           
      Auto negotiation: yes                                                                                                           
                 Speed: n/a                                                                                                           
                  Port: tp                                                                                                            

● 4: enp3s0f1                                                                                                                         
             Link File: /lib/systemd/network/99-default.link                                                                          
          Network File: n/a                                                                                                           
                  Type: ether                                                                                                         
                 State: no-carrier (unmanaged)                                                                                        
                  Path: pci-0000:03:00.1                                                                                              
                Driver: e1000e                                                                                                        
                Vendor: Intel Corporation                                                                                             
                 Model: 82571EB/82571GB Gigabit Ethernet Controller D0/D1 (copper applications) (PRO/1000 PT Dual Port Server Adapter)
            HW Address: 00:15:17:a6:4e:59 (Intel Corporate)                                                                           
                   MTU: 1500 (min: 68, max: 9212)                                                                                     
  Queue Length (Tx/Rx): 1/1                                                                                                           
      Auto negotiation: yes                                                                                                           
                 Speed: n/a                                                                                                           
                  Port: tp                                                                                                            

● 5: enp6s0                                                                           
             Link File: /lib/systemd/network/99-default.link                          
          Network File: n/a                                                           
                  Type: ether                                                         
                 State: no-carrier (unmanaged)                                        
                  Path: pci-0000:06:00.0                                              
                Driver: e1000e                                                        
                Vendor: Intel Corporation                                             
                 Model: 82574L Gigabit Network Connection (Gigabit CT Desktop Adapter)
            HW Address: 00:1b:21:a3:b3:8e (Intel Corporate)                           
                   MTU: 1500 (min: 68, max: 9212)                                     
  Queue Length (Tx/Rx): 1/1                                                           
      Auto negotiation: yes                                                           
                 Speed: n/a                                                           
                  Port: tp                                                            

● 6: br0                                                                                       
               Link File: /lib/systemd/network/99-default.link                                 
            Network File: /run/systemd/network/10-netplan-br0.network                          
                    Type: bridge                                                               
                   State: routable (configured)                                                
                  Driver: bridge                                                               
              HW Address: 04:92:26:5d:0b:b7 (ASUSTek COMPUTER INC.)                            
                     MTU: 1500 (min: 68, max: 65535)                                           
           Forward Delay: 4s                                                                   
              Hello Time: 2s                                                                   
                 Max Age: 20s                                                                  
             Ageing Time: 5min                                                                 
                Priority: 32768                                                                
                     STP: yes                                                                  
  Multicast IGMP Version: 2                                                                    
    Queue Length (Tx/Rx): 1/1                                                                  
                 Address: 192.168.192.222                                                      
                          fe80::692:26ff:fe5d:bb7                                              
                 Gateway: 192.168.192.1 (AVM Audiovisuelles Marketing und Computersysteme GmbH)
                     DNS: 8.8.8.8                                                              

Aug 02 13:59:30 hal9999 systemd-networkd[2380]: br0: netdev ready
Aug 02 13:59:30 hal9999 systemd-networkd[2380]: br0: IPv6 successfully enabled
Aug 02 13:59:30 hal9999 systemd-networkd[2380]: br0: Link UP
Aug 02 13:59:38 hal9999 systemd-networkd[2380]: br0: Gained carrier
Aug 02 13:59:39 hal9999 systemd-networkd[2380]: br0: Gained IPv6LL
Aug 02 15:21:21 hal9999 systemd-networkd[3548]: br0: netdev ready
Aug 02 15:21:21 hal9999 systemd-networkd[3548]: br0: Gained IPv6LL
Aug 02 15:21:21 hal9999 systemd-networkd[3548]: br0: netdev exists, using existing without changing its parameters
Aug 02 15:21:21 hal9999 systemd-networkd[3548]: br0: IPv6 successfully enabled

/运行/systemd/网络/10-netplan-br0.netdev

[NetDev]
Name=br0
MACAddress=04:92:26:5d:0b:b7
MTUBytes=1500
Kind=bridge

[Bridge]
ForwardDelaySec=4
STP=true

/运行/systemd/network/10-netplan-br0.network

[Match]
Name=br0

[Link]
MTUBytes=1500

[Network]
LinkLocalAddressing=ipv6
Address=192.168.192.222/24
Gateway=192.168.192.1
DNS=8.8.8.8
ConfigureWithoutCarrier=yes

/运行/systemd/network/10-netplan-enp5s0.network

[Match]
MACAddress=04:92:26:5d:0b:b7
Type=!vlan bond bridge

[Network]
DHCP=ipv4
LinkLocalAddressing=no
DNS=192.168.192.1
Domains=fritz.box
Bridge=br0

[DHCP]
CriticalConnection=true
ClientIdentifier=mac
RouteMetric=100
UseMTU=true

按照建议将 .yaml 文件中的真实接口 mac 地址添加到接口和网桥这里没有帮助。

更新2: ls -la /run/systemd/network/应用 netplan 之前的输出:

drwxr-xr-x  2 root root  80 Aug  6 11:09 .
drwxr-xr-x 23 root root 540 Aug  6 11:09 ..
-rw-r--r--  1 root root 256 Aug  6 11:09 10-netplan-enp5s0.network

sudo netplan 申请:

drwxr-xr-x  2 root root 100 Aug  8 15:38 .
drwxr-xr-x 24 root root 560 Aug  8 15:38 ..
-rw-r--r--  1 root root  81 Aug  8 15:38 10-netplan-br0.netdev
-rw-r--r--  1 root root 164 Aug  8 15:38 10-netplan-br0.network
-rw-r--r--  1 root root 192 Aug  8 15:38 10-netplan-enp5s0.network

输出10-netplan-br0.网络

[Match]
Name=br0

[Link]
MTUBytes=1500

[Network]
LinkLocalAddressing=ipv6
Address=192.168.192.222/24
Gateway=192.168.192.1
DNS=8.8.8.8
ConfigureWithoutCarrier=yes

输出10-netplan-br0.netdev

[NetDev]
Name=br0
MTUBytes=1500
Kind=bridge

[Bridge]
ForwardDelaySec=4
STP=true

相关内容