[FrontPage] [TitleIndex] [WordIndex

This is a read-only archived version of wiki.centos.org

在 CentOS 7 上為 Xen 設置橋接網絡

警告:在更改網絡前,請確保你不用依靠網絡亦能存取目標系統,供出錯時用。

首先,尋找你的主網絡裝置:

ip route show | grep 'default' | awk '{print $5}'

一般來說這是 eth0。本指引接下來假設你想建立一個名叫 xenbr0 的橋接器,並將 eth0 設成它的從屬裝置。

首先,建立 xenbr0,並給它適當的預設值:

nmcli con add type bridge con-name xenbr0 ifname xenbr0
nmcli con modify xenbr0 bridge.stp no
nmcli con modify xenbr0 bridge.hello-time 0

然後找出 eth0接線名稱。一般來說這是 System eth0:

# nmcli con show
NAME         UUID                                  TYPE            DEVICE 
System eth0  1619a4a0-518e-4547-9ade-31dff5ef8f5e  802-3-ethernet  eth0   

最後,把 System eth0 設成 xenbr0 的從屬裝置:

nmcli con modify "System eth0" connection.master xenbr0 connection.slave-type bridge

接著重新啟動網絡:

systemctl restart network

檢查設定是否已完成:

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master xenbr0 state UP qlen 1000
    link/ether 30:5b:d6:f1:d6:a2 brd ff:ff:ff:ff:ff:ff
4: xenbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 30:5b:d6:f1:d6:a2 brd ff:ff:ff:ff:ff:ff
    inet 10.80.237.209/20 brd 10.80.239.255 scope global dynamic xenbr0
       valid_lft 1798sec preferred_lft 1798sec
    inet6 fe80::325b:d6ff:fef1:d6a2/64 scope link 
       valid_lft forever preferred_lft forever

Translation of revision 2


2023-09-11 07:23