1 配置需求或说明
本案例适用于如S5500V2-34S-EI、S5500V2-28F-SI、S5530F-EI-D、S5560-54C-EI、S5560X-54C-PWR-EI、S5820V2-52Q、S5820V2-52QF-H3等S5500V2、S55X0、S58X0V2系列的交换机。
交换机SW1上配置一条静态路由,使终端访问114.114.114.114的时候通过R2,其中192.168.2.0这个网段,访问114.114.114.114 的时候匹配策略路由从R3去访问。
2 组网图
3 配置步骤
#在SW1上进图系统视图
System View: return to User View with Ctrl+Z.
#创建vlan 1-4
[H3C]vlan 1 to 4
#配置vlan 1-vlan 4虚接口IP地址
[H3C]interface Vlan-interface 1
[H3C-Vlan-interface1] ip address 192.168.1.1 255.255.255.0
[H3C-Vlan-interface1]quit
[H3C]interface Vlan-interface 2
[H3C-Vlan-interface2] ip address 192.168.2.1 255.255.255.0
[H3C-Vlan-interface2]quit
[H3C]interface Vlan-interface 3
[H3C-Vlan-interface3] ip address 10.10.10.1 255.255.255.0
[H3C-Vlan-interface3]quit
[H3C]interface Vlan-interface 4
[H3C-Vlan-interface4] ip address 20.20.20.1 255.255.255.0
[H3C-Vlan-interface4]quit
#将端口分别划分到所属vlan,端口1属于vlan 3,端口4属于vlan 4,端口5属于默人vlan 1,端口6属于vlan 2。
[H3C]interface GigabitEthernet 1/0/1
[H3C-GigabitEthernet1/0/1] port access vlan 3
[H3C-GigabitEthernet1/0/1]quit
[H3C]interface GigabitEthernet 1/0/4
[H3C-GigabitEthernet1/0/4] port access vlan 4
[H3C-GigabitEthernet1/0/4]quit
[H3C]interface GigabitEthernet 1/0/6
[H3C-GigabitEthernet1/0/6] port access vlan 2
[H3C-GigabitEthernet1/0/6]quit
#配置到114.114.114.0网段的静态路由
[H3C] ip route-static 114.114.114.0 24 10.10.10.2
[H3C]save force
#在R1上进图系统视图
System View: return to User View with Ctrl+Z.
#创建环回接口LoopBack 0用来模拟主机,地址是114.114.114.114/24
[H3C]interface LoopBack 0
[H3C-LoopBack0]ip address 114.114.114.114 255.255.255.0
[H3C-LoopBack0]quit
#为路由器1口和2口分别配置IP地址。
[H3C]int GigabitEthernet 0/1
[H3C-GigabitEthernet0/1] ip address 30.30.30.1 255.255.255.0
[H3C]int GigabitEthernet 0/2
[H3C-GigabitEthernet0/2] ip address 40.40.40.1 255.255.255.0
[H3C-GigabitEthernet0/2]quit
#配置到192.168.1.0网段的静态路由
[H3C]ip route-static 192.168.1.0 24 30.30.30.2
#配置到114.114.114.0网段的静态路由
[H3C]ip route-static 192.168.2.0 24 40.40.40.2
#开启设备的ICMP目的不可达报文的发送功能
[H3C]ip unreachables enable
#开启ICMP超时报文发送功能
[H3C]ip ttl-expires enable
[H3C]save force
#在R2上进图系统视图
System View: return to User View with Ctrl+Z.
#为路由器1口和2口分别配置IP地址。
[H3C]int GigabitEthernet 0/0
[H3C-GigabitEthernet0/0] ip address 30.30.30.2 255.255.255.0
[H3C]int GigabitEthernet 0/1
[H3C-GigabitEthernet0/1] ip address 10.10.10.2 255.255.255.0
#配置到114.114.114.0网段的静态路由
[H3C] ip route-static 114.114.114.0 24 30.30.30.1
#配置到192.168.1.0网段的静态路由
[H3C] ip route-static 192.168.1.0 24 10.10.10.1
#配置到114.114.114.0网段的静态路由
[H3C] ip route-static 192.168.2.0 24 10.10.10.1
#开启设备的ICMP目的不可达报文的发送功能
[H3C]ip unreachables enable
#开启ICMP超时报文发送功能
[H3C]ip ttl-expires enable
[H3C]save force
#在R3上进图系统视图
System View: return to User View with Ctrl+Z.
#为路由器1口和2口分别配置IP地址。
[H3C]int GigabitEthernet 0/0
[H3C-GigabitEthernet0/0] ip address 40.40.40.2 255.255.255.0
[H3C]int GigabitEthernet 0/1
[H3C-GigabitEthernet0/1] ip address 20.20.20.2 255.255.255.0
#配置到114.114.114.0网段的静态路由
[H3C] ip route-static 114.114.114.0 24 40.40.40.1
#配置到192.168.1.0网段的静态路由
[H3C] ip route-static 192.168.1.0 24 10.10.10.2
#配置到114.114.114.0网段的静态路由
[H3C] ip route-static 192.168.2.0 24 10.10.10.
#开启设备的ICMP目的不可达报文的发送功能
[H3C]ip unreachables enable
#开启ICMP超时报文发送功能
[H3C]ip ttl-expires enable
[H3C]save force
二.交换机策略路由配置
System View: return to User View with Ctrl+Z.
#定义访问控制列表3000,用来匹配内网源地址为192.168.2.0/24网段的数据流
[H3C]acl advanced 3000
[H3C-acl-ipv4-adv-3000]rule permit ip source 192.168.2.0 0.0.0.255
[H3C-acl-ipv4-adv-3000]quit
# 定义访问控制列表3001,用来匹配内网192.168.2.0/24网段去访问内网192.168.1.0/24网段的数据流。
[H3C]acl advanced 3001
[H3C-acl-adv-3001]rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
[H3C-acl-adv-3001]quit
# 创建策略路由,名称为aaa,节点为10,匹配acl 3001的数据流,不设置apply动作(如果不设置动作,则匹配到的数据转发时根据路由表来进行转,且不再匹配下一节点,配置这个节点的作用是实现内网不同网段之间互访的流量不匹配策略路由,达到可以互访的目的。备注:默认情况下,网关在路由器上的不同网段是可以互相访问的)。
[H3C]policy-based-route aaa permit node 10
[H3C-pbr-aaa-10]if-match acl 3001
[H3C-pbr-aaa-10]quit
#创建策略路由aaa的节点20,匹配acl 3000的数据流,设置apply动作,指定数据的下一跳为20.20.20.2。
[H3C]policy-based-route aaa node 20
[H3C-pbr-aaa-20]if-match acl 3000
[H3C-pbr-aaa-20]apply next-hop 20.20.20.2
[H3C-pbr-aaa-20]quit
#在内网VLAN虚接口(网关)上应用策略路由
[H3C]interface vlan 2
[H3C-Vlan-interface2]ip policy-based-route aaa
[H3C-Vlan-interface2]quit
[H3C]save force
4 验证配置
# 交换机上没有配置策略路由的时候,在两台终端上tracert路径的结果如下:
192.168.1.2:
192.168.2.2:
# 配置了策略路由以后
192.168.1.2:
192.168.2.2:
无
该案例暂时没有网友评论
✖
案例意见反馈
亲~登录后才可以操作哦!
确定你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作