VirtualBox 上的 Ubuntu 18.04 netplan 橋接出現問題

VirtualBox 上的 Ubuntu 18.04 netplan 橋接出現問題

我被困在網絡配置中,我需要幫助..

計劃是建立一個在專用 ubuntu 18.04 伺服器上執行 Windows 的 KVM。

所以我需要一個網橋來存取我的 ubuntu 中的視窗。為了嘗試這個橋接項目,我在我的 virtualbox 中創建了一個 ubuntu 18.04 伺服器,並嘗試在那裡設定一個正在運行的網橋。

每次我套用 netplan 設定時,網路連線都會停止運作。

我真的需要幫助,並解釋這個神奇的東西是如何工作的。

這是我的 ubuntu 虛擬機器中的工作 /etc/netplan/50-cloud-init.yaml 配置。

network:
  ethernets:
    enp0s3:
    gateway4: 192.168.176.1
    dhcp4: false
    addresses: [192.168.176.40/23]
  version: 2

現在我嘗試配置一個橋:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: false
  bridges:
    br0:
      dhcp4: false
      addresses: [192.168.176.40/23]
      gateway4: 192.168.176.1
      interfaces:
        - enp0s3

如果我現在運行“netplan apply”,與虛擬機器的 ssh 連線就會中斷,與網路的連線也會中斷。

你能幫我解決這個問題並解釋一下我在這裡必須做什麼嗎?

這裡我有一個來自 runnung 配置的「ifconfig」:

root@vmbuntuerver18:/etc/netplan# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.176.40  netmask 255.255.254.0  broadcast 192.168.177.255
        inet6 2003:d3:cf20:ce00:a00:27ff:fee9:ad0d  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::a00:27ff:fee9:ad0d  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:e9:ad:0d  txqueuelen 1000  (Ethernet)
        RX packets 787  bytes 71995 (71.9 KB)
        RX errors 0  dropped 546  overruns 0  frame 0
        TX packets 122  bytes 18977 (18.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 92  bytes 7036 (7.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 92  bytes 7036 (7.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

這裡是一個帶有我損壞的橋接配置的「ifconfig」:

在此輸入影像描述

(我無法複製文字,所以這裡有一張圖片)

我很感激每一個想法或答案。

答案1

我可以透過在 VertualBox 的虛擬機器設定中啟用混雜模式來解決我的問題。

我的“橋接配置”正在工作。

這是我的 VirtualBox 網路設定中的圖片: 在此輸入影像描述

答案2

您還需要在橋的 br0 行之後套用縮排,如下所示:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: false
  bridges:
    br0:
      dhcp4: false
      addresses: [192.168.176.40/23]
      gateway4: 192.168.176.1
      interfaces:
        - enp0s3

相關內容