KVM虚拟化Linux Bridge环境部署的方法步骤
KVM虚拟化Linux Bridge环境部署本节给出Linux Bridge网桥环境部署的方法,使虚拟机连接到网络。
1 安装Linux Bridge
以物理网卡ens33绑定到Linux Bridge br0的操作为例,使用root用户执行如下命令搭建Linux Bridge :
1.1 安装bridge-utils软件包
Linux Bridge通常通过brctl工具管理,其对应的安装包为bridge-utils,安装命令如下:
# yum install -y bridge-utils 示例命令如下:
# yum install -y bridge-utils
Last metadata expiration check: 1 day, 12:32:06 ago on 2023年02月05日 星期日 22时41分25秒.
Dependencies resolved.
============================================================================================================================
Package Architecture Version Repository Size
============================================================================================================================
Installing:
bridge-utils x86_64 1.7.1-1.oe2203 OS 33 k
Transaction Summary
============================================================================================================================
Install1 Package
Total download size: 33 k
Installed size: 62 k
Downloading Packages:
bridge-utils-1.7.1-1.oe2203.x86_64.rpm 186 kB/s |33 kB 00:00
----------------------------------------------------------------------------------------------------------------------------
Total 179 kB/s |33 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : bridge-utils-1.7.1-1.oe2203.x86_64 1/1
Running scriptlet: bridge-utils-1.7.1-1.oe2203.x86_64 1/1
Verifying : bridge-utils-1.7.1-1.oe2203.x86_64 1/1
Installed:
bridge-utils-1.7.1-1.oe2203.x86_64
Complete!
#
1.2 确认安装是否成功
确认bridge-utils组件是否安装成功若安装成功,可以查看软件包相关信息。
# rpm -qi bridge-utils 示例命令如下:
# rpm -iq bridge-utils
bridge-utils-1.7.1-1.oe2203.x86_64
#
# rpm -qi bridge-utils
Name : bridge-utils
Version : 1.7.1
Release : 1.oe2203
Architecture: x86_64
Install Date: 2023年02月07日 星期二 11时13分34秒
Group : Unspecified
Size : 63965
License : GPLv2+
Signature : RSA/SHA1, 2022年03月30日 星期三 12时42分49秒, Key ID d557065eb25e7f66
Source RPM: bridge-utils-1.7.1-1.oe2203.src.rpm
Build Date: 2021年12月08日 星期三 08时00分00秒
Build Host: ecs-obsworker-209
Packager : http://openeuler.org
Vendor : http://openeuler.org
URL : https://wiki.linuxfoundation.org/networking/bridge
Summary : Utilities for configuring the linux ethernet bridge
Description :
This package provides utilities for configuring the linux ethernet
bridge. The linux ethernet bridge can be used for connecting multiple
ethernet devices together.
#
2 配置Linux Bridge
2.1 创建网桥br0
# brctl addbr br0 示例命令如下:
# brctl addbr br0
# 查看创建的网桥br0
# brctl show 示例命令如下:
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000000000000 no
#
2.2 将物理网卡ens33绑定到Linux Bridge
# brctl addif br0 ens33 示例命令如下:
# brctl addif br0 ens33
# 查看绑定后Linux网桥的配置
用brctl show查看当前Linux网桥的配置,ens33已经挂到br0上了
# brctl show 示例命令如下:
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c2996c9d7 no ens33
#
2.3 配置ens33的ip
ens33与网桥连接后,不再需要 IP 地址,将ens33的IP设置为0.0.0.0。
# ifconfig ens33 0.0.0.0 示例命令如下:
# ifconfig ens33 0.0.0.0
#
2.4 为Linux Bridge网桥br0分配ip
2.4.1 DHCP设置
如果有DHCP服务器,可以通过dhclient设置动态IP地址。
# dhclient br0 示例命令如下:
# dhclient br0
# 查看dhcp自动获取ip地址信息
# ip add list 示例命令如下:
# ip add list
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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether 00:0c:29:96:c9:d7 brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet6 fe80::9393:f6ae:ced9:7759/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:96:c9:d7 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.131/24 brd 192.168.1.255 scope global dynamic br0
valid_lft 6804sec preferred_lft 6804sec
inet6 fe80::20c:29ff:fe96:c9d7/64 scope link
valid_lft forever preferred_lft forever
# 2.4.2 静态ip设置
如果没有DHCP服务器,给br0配置静态IP,例如设置静态IP为192.168.1.21,子网掩码为255.255.255.0。
# ifconfig br0 192.168.1.21 netmask 255.255.255.0 示例命令如下:
# ifconfig br0 192.168.1.21 netmask 255.255.255.0
# 查看静态ip设置后信息
# ip add list 示例命令如下:
# ip add list
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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether 00:0c:29:96:c9:d7 brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet6 fe80::9393:f6ae:ced9:7759/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:96:c9:d7 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.21/24 brd 192.168.1.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe96:c9d7/64 scope link
valid_lft forever preferred_lft forever
# 到此这篇关于KVM虚拟化Linux Bridge环境部署的方法步骤的文章就介绍到这了,更多相关KVM Linux Bridge环境部署内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
来源:https://www.jb51.net/article/283844.htm
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!
页:
[1]