免费资源网 – https://freexyz.cn/
目录KVM虚拟化Linux Bridge环境部署1 安装Linux Bridge1.1 安装bridge-utils软件包1.2 确认安装是否成功2 配置Linux Bridge2.1 创建网桥br02.2 将物理网卡ens33绑定到Linux Bridge2.3 配置ens33的ip2.4 为Linux Bridge网桥br0分配ip
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示例命令如下:
[root@superman-21 ~]# 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 ============================================================================================================================ Install 1 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! [root@superman-21 ~]# 1.2 确认安装是否成功确认bridge-utils组件是否安装成功若安装成功,可以查看软件包相关信息。
# rpm -qi bridge-utils示例命令如下:
[root@superman-21 ~]# rpm -iq bridge-utils bridge-utils-1.7.1-1.oe2203.x86_64 [root@superman-21 ~]# [root@superman-21 ~]# 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. [root@superman-21 ~]#2 配置Linux Bridge
2.1 创建网桥br0 # brctl addbr br0示例命令如下:
[root@superman-21 ~]# brctl addbr br0 [root@superman-21 ~]#查看创建的网桥br0
# brctl show示例命令如下:
[root@superman-21 ~]# brctl show bridge name bridge id STP enabled interfaces br0 8000.000000000000 no [root@superman-21 ~]# 2.2 将物理网卡ens33绑定到Linux Bridge # brctl addif br0 ens33示例命令如下:
[root@superman-21 ~]# brctl addif br0 ens33 [root@superman-21 ~]#查看绑定后Linux网桥的配置
用brctl show查看当前Linux网桥的配置,ens33已经挂到br0上了
# brctl show示例命令如下:
[root@superman-21 ~]# brctl show bridge name bridge id STP enabled interfaces br0 8000.000c2996c9d7 no ens33 [root@superman-21 ~]# 2.3 配置ens33的ipens33与网桥连接后,不再需要 IP 地址,将ens33的IP设置为0.0.0.0。
# ifconfig ens33 0.0.0.0示例命令如下:
[root@superman-21 ~]# ifconfig ens33 0.0.0.0 [root@superman-21 ~]# 2.4 为Linux Bridge网桥br0分配ip2.4.1 DHCP设置
如果有DHCP服务器,可以通过dhclient设置动态IP地址。
# dhclient br0示例命令如下:
[root@superman-21 ~]# dhclient br0 [root@superman-21 ~]#查看dhcp自动获取ip地址信息
# ip add list示例命令如下:
[root@superman-21 ~]# 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 [root@superman-21 ~]#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示例命令如下:
[root@superman-21 ~]# ifconfig br0 192.168.1.21 netmask 255.255.255.0 [root@superman-21 ~]#查看静态ip设置后信息
# ip add list示例命令如下:
[root@superman-21 ~]# 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 [root@superman-21 ~]#
免费资源网 – https://freexyz.cn/
© 版权声明
THE END
暂无评论内容