KVM 宿主機上創建橋接網絡

KVM 宿主機上創建橋接網絡
宿主機上執行#virsh iface-bridge etho br0
只能執行一次
創建名爲bridge的網橋設備,並將現有網絡設備接口附加到新網橋。新橋默認立即啓動,
在啓用STP且延遲爲0的情況下;這些設置可以通過--no STP、--no start和延遲的整數秒數進行更改。所有IP地址
接口配置將移至新的橋接設備
iface-bridge interface bridge [--no-stp] [delay] [--no-start]
Create a bridge device named bridge, and attach the existing network device interface to the new bridge. The new bridge defaults to starting immediately,
with STP enabled and a delay of 0; these settings can be altered with --no-stp, --no-start, and an integer number of seconds for delay. All IP address
configuration of interface will be moved to the new bridge device.








See also iface-unbridge for undoing this operation.

~~ 有的可能會遇到報錯如下:失敗並且 終端斷開連接,不要慌有解決辦法
 [[email protected] centos6.9-4]# virsh iface-bridge ens33 br0

使用附加設備 br0 生成橋接 ens33 失敗

Socket error Event: 32 Error: 10053.
Connection closing...Socket close.

Connection closed by foreign host.~~
KVM 宿主機上創建橋接網絡
解決辦法

登上宿主機打開終端執行重啓網絡服務命令
皆可解決
CentOS7#systemctl restart network
CentOS8 #nmcli connection reload ens160
#nmcli connention up ens160
執行後Xshell重新連接 ,可以連上檢查網絡已有橋接網絡 br0
[[email protected] ~]# grep -i "." /etc/sysconfig/network-scripts/ifcfg-
/etc/sysconfig/network-scripts/ifcfg-br0:DEVICE="br0"
/etc/sysconfig/network-scripts/ifcfg-br0:ONBOOT="yes"
/etc/sysconfig/network-scripts/ifcfg-br0:TYPE="Bridge"
/etc/sysconfig/network-scripts/ifcfg-br0:BOOTPROTO="none"
/etc/sysconfig/network-scripts/ifcfg-br0:IPADDR="10.1.3.2"
/etc/sysconfig/network-scripts/ifcfg-br0:NETMASK="255.255.255.0"
/etc/sysconfig/network-scripts/ifcfg-br0:GATEWAY="10.1.3.254"
/etc/sysconfig/network-scripts/ifcfg-br0:IPV6INIT="yes"
/etc/sysconfig/network-scripts/ifcfg-br0:IPV6_AUTOCONF="yes"
/etc/sysconfig/network-scripts/ifcfg-br0:DHCPV6C="no"
/etc/sysconfig/network-scripts/ifcfg-br0:STP="on"
/etc/sysconfig/network-scripts/ifcfg-br0:DELAY="0"
/etc/sysconfig/network-scripts/ifcfg-ens33:DEVICE="ens33"
/etc/sysconfig/network-scripts/ifcfg-ens33:ONBOOT="yes"
/etc/sysconfig/network-scripts/ifcfg-ens33:BRIDGE="br0"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:TYPE="Ethernet"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:PROXY_METHOD="none"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:BROWSER_ONLY="no"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:BOOTPROTO="none"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:DEFROUTE="yes"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:IPV4_FAILURE_FATAL="yes"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:IPV6INIT="yes"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:IPV6_AUTOCONF="yes"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:IPV6_DEFROUTE="yes"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:IPV6_FAILURE_FATAL="no"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:IPV6_ADDR_GEN_MODE="stable-privacy"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:NAME="ens33"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:UUID="68f524ae-37f5-4924-8c2b-c1f9042b13d9"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:DEVICE="ens33"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:ONBOOT="yes"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:IPADDR="10.1.3.2"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:PREFIX="24"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:GATEWAY="10.1.3.254"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:DNS1="8.8.8.8"
/etc/sysconfig/network-scripts/ifcfg-ens33.bak:IPV6_PRIVACY="no"
/etc/sysconfig/network-scripts/ifcfg-lo:DEVICE=lo
/etc/sysconfig/network-scripts/ifcfg-lo:IPADDR=127.0.0.1
/etc/sysconfig/network-scripts/ifcfg-lo:NETMASK=255.0.0.0
/etc/sysconfig/network-scripts/ifcfg-lo:NETWORK=127.0.0.0
/etc/sysconfig/network-scripts/ifcfg-lo:# If you're having problems with gated making 127.0.0.0/8 a martian,
/etc/sysconfig/network-scripts/ifcfg-lo:# you can change this to something else (255.255.255.255, for example)
/etc/sysconfig/network-scripts/ifcfg-lo:BROADCAST=127.255.255.255
/etc/sysconfig/network-scripts/ifcfg-lo:ONBOOT=yes
/etc/sysconfig/network-scripts/ifcfg-lo:NAME=loopback
**[[email protected] ~]# ll /etc/sysconfig/network-scripts/ifcfg-***
-rw-r--r--. 1 root root 187 12月 31 15:55 /etc/sysconfig/network-scripts/ifcfg-br0
-rw-------. 1 root root 41 12月 31 15:55 /etc/sysconfig/network-scripts/ifcfg-ens33
-rw-r--r--. 1 root root 395 7月 8 06:58 /etc/sysconfig/network-scripts/ifcfg-ens33.bak
-rw-r--r--. 1 root root 254 8月 24 2018 /etc/sysconfig/network-scripts/ifcfg-lo
KVM 宿主機上創建橋接網絡
通過man iface-bridge 查看命令用法
KVM 宿主機上創建橋接網絡




























































虛機網絡設置
#virsh destroy vm1
#virsh edit vm1
編輯文件兩處如下截圖
KVM 宿主機上創建橋接網絡



#virsh start vm1 啓動虛機
爲虛機設置IP編輯網絡配置文件或者配置DHCP自動獲取(上層網絡編輯器是否開啓DHCP)
查看虛機內部網絡信息
#virsh
[[email protected] ~]# virsh
歡迎使用 virsh,虛擬化的交互式終端。




輸入:'help' 來獲得命令的幫助信息
'quit' 退出

virsh # iface-
iface-begin iface-commit iface-destroy iface-edit iface-mac iface-rollback iface-unbridge
iface-bridge iface-define iface-dumpxml iface-list iface-name iface-start iface-undefine
virsh # net-list
名稱 狀態 自動開始 持久



default 活動 是 是

virsh # net-edit default
未更改網絡 default XML 配置

virsh #

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章