配置KVM网络桥接功能

配置KVM网络桥接功能

配置之前我们来说说网桥:
网桥设备(Bridge),相当于现在的二层交换机,将同一网段的所有机器连接起来。我们配置的网络桥接功能就是将网络设备eth0加进br0(相当于一个交换机设备)。

在这里插入图片描述

因此,我们需要先添加一块br0设备(相当一个二层交换机)。

一、安装生成br0的工具

  [root@centos3 ~]# yum install -y bridge-utils
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.njupt.edu.cn
 * epel: hk.mirrors.thegigabit.com
 * extras: mirrors.njupt.edu.cn
 * updates: mirrors.nju.edu.cn
epel/x86_64/primary_db         FAILED                                          ETA 
http://hk.mirrors.thegigabit.com/epel/7/x86_64/repodata/256fe13c9b4274f5ab2b2c61d51d961ff7d1bb89cd8d57b6dffe1c9e78570aae-primary.sqlite.bz2: [Errno 12] Timeout on http://hk.mirrors.thegigabit.com/epel/7/x86_64/repodata/256fe13c9b4274f5ab2b2c61d51d961ff7d1bb89cd8d57b6dffe1c9e78570aae-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在尝试其它镜像。
epel/x86_64/primary_db         FAILED                                          ETA 
http://my.mirrors.thegigabit.com/epel/7/x86_64/repodata/256fe13c9b4274f5ab2b2c61d51d961ff7d1bb89cd8d57b6dffe1c9e78570aae-primary.sqlite.bz2: [Errno 12] Timeout on http://my.mirrors.thegigabit.com/epel/7/x86_64/repodata/256fe13c9b4274f5ab2b2c61d51d961ff7d1bb89cd8d57b6dffe1c9e78570aae-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在尝试其它镜像。
epel/x86_64/primary_db                                      | 6.9 MB  00:00:21     
软件包 bridge-utils-1.5-9.el7.x86_64 已安装并且是最新版本
无须任何处理

二、将eth0绑到br0下

1.更改以太网配置文件,如图中所示。

[root@centos3 ~]#  cd /etc/sysconfig/network-scripts/
[root@centos3 network-scripts]# ls
ifcfg-ens33  ifdown-isdn      ifup          ifup-plip      ifup-tunnel
ifcfg-lo     ifdown-post      ifup-aliases  ifup-plusb     ifup-wireless
ifdown       ifdown-ppp       ifup-bnep     ifup-post      init.ipv6-global
ifdown-bnep  ifdown-routes    ifup-eth      ifup-ppp       network-functions
ifdown-eth   ifdown-sit       ifup-ib       ifup-routes    network-functions-ipv6
ifdown-ib    ifdown-Team      ifup-ippp     ifup-sit
ifdown-ippp  ifdown-TeamPort  ifup-ipv6     ifup-Team
ifdown-ipv6  ifdown-tunnel    ifup-isdn     ifup-TeamPort
[root@centos3 network-scripts]# vim ifcfg-ens33

在这里插入图片描述

2.创建br0

[root@centos3 network-scripts]# vim ifcfg-br0

①配置格式如下图,内容需按照自身的ip地址。

在这里插入图片描述
②重启网络:

[root@azhan network-scripts]# service network restart
Restarting network (via systemctl):                        [  确定  ]
[root@azhan network-scripts]# 

三.查看网络设备

会发现多了个br0

[root@azhan network-scripts]# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.8.121  netmask 255.255.255.0  broadcast 192.168.8.255
        inet6 fe80::20c:29ff:fe7a:e32e  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:7a:e3:2e  txqueuelen 1000  (Ethernet)
        RX packets 90  bytes 13749 (13.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 70  bytes 7852 (7.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:0c:29:7a:e3:2e  txqueuelen 1000  (Ethernet)
        RX packets 1513  bytes 1779200 (1.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 520  bytes 43526 (42.5 KiB)
        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 32  bytes 2592 (2.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 2592 (2.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:66:07:be  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

四.检验是否通网

[root@azhan ~]# ping baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=128 time=79.9 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=128 time=91.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=128 time=77.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=128 time=81.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=5 ttl=128 time=89.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=6 ttl=128 time=91.6 ms
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值