Linux中的高级网络配置 缺乏、安全感 2022-06-04 00:26 144阅读 0赞 1.网络桥接 什么是网络桥接 桥接就是把一台机器上的若干个网络接口“连接”起来。其结果是,其中一个网口收到的报文会被复制给其他网口并发送出去。以使得网口之间的报文能够互相转发。交换机就是这样一个设备,它有若干个网口,并且这些网口是桥接起来的。于是,与交换机相连的若干主机就能够通过交换机的报文转发而互相通信。 2. 网络桥接的管理命令 brctl show \#查看网桥信息 brctl addbr brname \#添加一个名字为brname的br ![这里写图片描述][SouthEast] 清空网卡和网桥配置: ![这里写图片描述][SouthEast 1] 给br0这个网桥添加ip和网关 ![这里写图片描述][SouthEast 2] 测试是否可以ping通其他主机,答案为否。 ![这里写图片描述][SouthEast 3] brctl addif brname ifname \#在brname下添加一个名字为ifname的接口(网卡) ![这里写图片描述][SouthEast 4] 添加之后,可以ping通了。 删除一个网桥和网桥接口 (1)关闭网桥ifconfig br0 down (2)删除网桥连接(接口)brctl delif brname ifname \#删除brname下的叫做ifname的网桥连接 (3)删除网桥 brctl delbr brname \#删除一个网桥 (4)最后查看br信息 ![这里写图片描述][SouthEast 5] 二、bond网络 1.什么是bond Red Hat Enterprise Linux 允许管理员使用,bonding内核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定到一个通道上。根据选择的绑定模式,通道绑定使两个或更多个网络接口作为一个网络接口,从而增加带宽和。 2.bond操作 (1)创建一个名字为bond0的bond ![这里写图片描述][SouthEast 6] 注意:新建的bond在/proc/net/bonding下查看 (2)创建两个类型为bond-slave的接口(网卡)eth0和eth1 前提:给该实验虚拟机新添加一个网卡 ![这里写图片描述][SouthEast 7] ![这里写图片描述][SouthEast 8] (3)测试 在原有的shell下ctrl+shift+t 打开一个shell watch -n 1 cat /proc/net/bonding/bond0 \#监控bond0 如图当前活动的网络接口为eth0 ![这里写图片描述][SouthEast 9] 重新打开一个shell 执行ping命令(与改实验主机在一个网段上的主机) 执行ifconfig eth0 down \#关闭网络接口eth0 ,查看ping状态以及bond0状态 . 发现一直可以ping通 ![这里写图片描述][SouthEast 10] 4.team网络 做这个实验之前,先删除之前的bond和bond接口 执行nmcli connection delete bond名字|接口名字 (1)先创建一个team0 ![这里写图片描述][SouthEast 11] (2)创建两个接口eth1和eth0 ![这里写图片描述][SouthEast 12] (3)watch -n 1 teamdctl team0 state ![这里写图片描述][SouthEast 13] 关闭一个接口 ![这里写图片描述][SouthEast 14] 一直在ping从未中断 ![这里写图片描述][SouthEast 15] 总结:以上两种bond和team可以将多个网络接口连接在一起,如果一个接口出现故障,其他网络接口会顶替上去。 [SouthEast]: /images/20220604/425f7d4b42764e67b57c72b48be6f66a.png [SouthEast 1]: /images/20220604/9782d65057a745a6967ab580f7824268.png [SouthEast 2]: /images/20220604/c941419a37b44698a1e2b85907e3a406.png [SouthEast 3]: /images/20220604/a0a79bd474fa498e9b27533b9860fc97.png [SouthEast 4]: /images/20220604/2d0a235664f642aa89fa696401f0ffc2.png [SouthEast 5]: /images/20220604/419bb45d0be34b31a4ec90b549ef6bf9.png [SouthEast 6]: /images/20220604/aabbd5091524431f909fdff45e19d498.png [SouthEast 7]: /images/20220604/d1693f6bc29e43fb9621e03d88c9bf53.png [SouthEast 8]: /images/20220604/108a6f2f760d441b884870612bd6b523.png [SouthEast 9]: /images/20220604/26d23c14539b44038b780dc9017eeb81.png [SouthEast 10]: /images/20220604/71f289c523564dee93cdfb8a1863c39a.png [SouthEast 11]: /images/20220604/85c753188e7c4a41a3657f7178a2e434.png [SouthEast 12]: /images/20220604/d7d3a3ff0f254a97a606f047553a8655.png [SouthEast 13]: /images/20220604/37b08905897843d29762e1f8875c6ff9.png [SouthEast 14]: /images/20220604/b606d8f1e7c24272b855f95a67257727.png [SouthEast 15]: /images/20220604/cd94607824224fa8b42c8d04308efea6.png
还没有评论,来说两句吧...