目录
准备工作
环境:VirtualBox Centos 7 镜像 网络:添加两个网卡 网络一:VirualBox host-only Ethernet
Adapter 网络2 、网络3 :VirualBox host-only Ethernet Adapter #2
1、查看一下网络
可以看到三个 分别是 -enp0s3 enp0s8 、enp0s9
2、添加聚合端口(bond0)
2.1、修改bond0 配置文件
TYPE=Bond
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=bond0
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.82.5
PREFIX=24
GATEWAY1=192.168.56.200
BONDIGN_MASTER=yes
BONDING_OPTS="mode=0 miimon=100"
USERCTL=no
2.2、修改ensp0s8 配置文件
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s8
UUID=a4fda7b8-26dd-4e9a-9946-471d36da9135
DEVICE=enp0s8
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
2.3、修改ensp0s9 配置文件
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s9
UUID=1cddb331-e5d5-407f-a88d-9ea3e4f4f0b2
DEVICE=enp0s9
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
3、可以看一下聚合情况
[root@localhost network-scripts]# ethtool bond0
Settings for bond0:
Supported ports: [ ]
Supported link modes: Not reported
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
== Speed: 2000Mb/s==
Duplex: Full
Port: Other
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
Link detected: yes
== Speed: 2000Mb/s==
3.1 、测试连通性
4、设置多运营商出接口,创建联通 、电信两个路由表
vim /etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
0 unspec
252 82
251 56
#
# local
#
#1 inr.ruhep
~
4.1 、配置脚本文件
设置网络的路由策略
#vim /etc/init.d/networking
ip route flush table 56
ip route add default via 192.168.56.200 dev enp0s3 src 192.168.56.102 table 56
ip rule add from 192.168.56.102 table 56 pref 1001
ip route flush table 82
ip route add default via 192.168.82.200 dev bond0 src 192.168.82.5 table 82
ip rule add from 192.168.82.5 table 82 pref 1000
5、查看IP路由表
ip rule list
[root@localhost network-scripts]# ip rule list
0: from all lookup local
1000: from 192.168.82.5 lookup 82
1001: from 192.168.56.102 lookup 56
32766: from all lookup main
32767: from all lookup default
6、设置开机自启
vim /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
/etc/init.d/networking
7、 设置权限
给他修改的权限,足以运行网络,
[root@localhost rc.d]# cd /etc/init.d/
[root@localhost init.d]# chmod 755 networking
[root@localhost init.d]# ./networking
8、测试联通性
[root@localhost init.d]# ping -I 192.168.82.5 192.168.200.100
PING 192.168.200.100 (192.168.200.100) from 192.168.82.5 : 56(84) bytes of data.
64 bytes from 192.168.200.100: icmp_seq=1 ttl=254 time=1.18 ms
64 bytes from 192.168.200.100: icmp_seq=2 ttl=254 time=1.12 ms
64 bytes from 192.168.200.100: icmp_seq=3 ttl=254 time=0.796 ms
64 bytes from 192.168.200.100: icmp_seq=4 ttl=254 time=0.820 ms
64 bytes from 192.168.200.100: icmp_seq=5 ttl=254 time=0.895 ms
8.1、在pc2 ping 56网段
ping 192.168.56.102
Ping 192.168.56.102 (192.168.56.102): 56 data bytes, press CTRL_C to break
56 bytes from 192.168.56.102: icmp_seq=0 ttl=63 time=2.000 ms
56 bytes from 192.168.56.102: icmp_seq=1 ttl=63 time=1.000 ms
56 bytes from 192.168.56.102: icmp_seq=2 ttl=63 time=1.000 ms
56 bytes from 192.168.56.102: icmp_seq=3 ttl=63 time=1.000 ms
56 bytes from 192.168.56.102: icmp_seq=4 ttl=63 time=2.000 ms
--- Ping statistics for 192.168.56.102 ---
8.2、 在pc2 ping 82 网段
<H3C>ping 192.168.82.5
Ping 192.168.82.5 (192.168.82.5): 56 data bytes, press CTRL_C to break
56 bytes from 192.168.82.5: icmp_seq=0 ttl=63 time=1.000 ms
56 bytes from 192.168.82.5: icmp_seq=1 ttl=63 time=1.000 ms
56 bytes from 192.168.82.5: icmp_seq=2 ttl=63 time=1.000 ms
56 bytes from 192.168.82.5: icmp_seq=3 ttl=63 time=2.000 ms
56 bytes from 192.168.82.5: icmp_seq=4 ttl=63 time=1.000 ms
--- Ping statistics for 192.168.82.5 ---
目的
1、设置聚合端口为了 增加链路带宽;
2、设置多运营商出接口为了 备份 冗余;如果一条链路 DOWN 掉,另外一条链路可以正常工作。
版权声明:本文为m0_54193894原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。