Enter system view, return user view with Ctrl+Z.
[Huawei]vlan batch 10 20
[Huawei]int gi 0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 10
[Huawei-GigabitEthernet0/0/2]int gi 0/0/3
[Huawei-GigabitEthernet0/0/3]port link-type access
[Huawei-GigabitEthernet0/0/3]port default vlan 20
[Huawei-GigabitEthernet0/0/3]int gi 0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
由于ENSP里面不支持undo switch,所以vlan间路由没有采取三层交换,而是单臂路由,现实中可以配置三层交换
[Huawei]int gi0/0/2.1
[Huawei-GigabitEthernet0/0/2.1]dot1q termination vid 10
[Huawei-GigabitEthernet0/0/2.1]ip addr 192.168.1.254 24
[Huawei-GigabitEthernet0/0/2.1]arp broadcast enable
[Huawei-GigabitEthernet0/0/2.1]int gi 0/0/2.2
[Huawei-GigabitEthernet0/0/2.2]dot1q termination vid 20
[Huawei-GigabitEthernet0/0/2.2]ip addr 192.168.2.254 24
[Huawei-GigabitEthernet0/0/2.2]arp broadcast enable
[Huawei]int gi 0/0/0
[Huawei-GigabitEthernet0/0/0]ip addr 10.1.1.2 24
[Huawei]int gi 0/0/1
[Huawei-GigabitEthernet0/0/0]ip addr 20.1.1.2 24
[Huawei]acl 2001
[Huawei-acl-basic-2001]rule permit source 192.168.1.0 0.0.0.255
[Huawei-acl-basic-2001]acl 2002
[Huawei-acl-basic-2002]rule permit source 192.168.2.0 0.0.0.255
[Huawei-acl-basic-2002]q
[Huawei]int gi 0/0/0
[Huawei-GigabitEthernet0/0/0]nat outbound 2001
[Huawei-GigabitEthernet0/0/0]int gi 0/0/1
[Huawei-GigabitEthernet0/0/1]nat outbound 2002
[Huawei-GigabitEthernet0/0/1]q
[Huawei]int gi 0/0/0
[Huawei-GigabitEthernet0/0/0]ip addr 100.1.1.1 24
[Huawei-GigabitEthernet0/0/0]int gi 0/0/1
[Huawei-GigabitEthernet0/0/1]ip addr 10.1.1.1 24
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ospf 1 router-id 1.1.1.1
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 100.1.1.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]import-route direct type 1 //发布直连路由
[Huawei-ospf-1]q
Enter system view, return user view with Ctrl+Z.
[Huawei]int gi0/0/0
[Huawei-GigabitEthernet0/0/0]ip addr 200.1.1.1 24
[Huawei-GigabitEthernet0/0/0]int gi0/0/1
[Huawei-GigabitEthernet0/0/1]ip addr 20.1.1.1 24
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ospf 1 router-id 2.2.2.2
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 200.1.1.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]import-route direct type 1
Enter system view, return user view with Ctrl+Z.
[Huawei]int gi 0/0/0
[Huawei-GigabitEthernet0/0/0]ip addr 100.1.1.2 24
[Huawei-GigabitEthernet0/0/0]int gi 0/0/1
[Huawei-GigabitEthernet0/0/1]ip addr 200.1.1.2 24
[Huawei-GigabitEthernet0/0/1]int lo0
[Huawei-LoopBack0]ip addr 114.114.114.114 24
[Huawei-LoopBack0]ospf 1 router-id 3.3.3.3
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 100.1.1.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 200.1.1.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]import-route direct type 1
[Huawei-ospf-1]q
联通性配置完成!!!
现在可以发现不管是PC1还是PC2都可以正常上internet(错误:由于出口路由器与ISP1、ISP2之间没有路由,所以不通)
测试:
实现,PC1通过ISP电信上Internet
PC2通过ISP联通上Internet
[Huawei]acl 3001 //vlan10
[Huawei-acl-adv-3001]rule permit ip source 192.168.1.0 0.0.0.255
[Huawei-acl-adv-3001]acl 3002 //vlan 20
[Huawei-acl-adv-3002]rule permit ip source 192.168.2.0 0.0.0.255
[Huawei-acl-adv-3002]
[Huawei-acl-adv-3002]acl 3003 //两个子网地址段允许访问其网关
[Huawei-acl-adv-3003]rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.1.254 0
[Huawei-acl-adv-3003]rule permit ip source 192.168.2.0 0.0.0.255 destination 192.168.2.254 0
[Huawei-acl-adv-3003]q
配置流匹配
[Huawei]traffic classifier c1
[Huawei-classifier-c1]if-match acl 3001
[Huawei]traffic classifier c2
[Huawei-classifier-c2]if-match acl 3002
[Huawei-classifier-c2]q
[Huawei]traffic classifier c3
[Huawei-classifier-c3]if-match acl 3003
[Huawei-classifier-c3]q
配置流行为
[Huawei]traffic behavior b1
[Huawei-behavior-b1]redirect ip-nexthop 10.1.1.1
[Huawei-behavior-b1]traffic behavior b2
[Huawei-behavior-b2]redirect ip-nexthop 20.1.1.1
[Huawei-behavior-b2]traffic behavior b3
[Huawei-behavior-b3]permit
配置流策略
[Huawei-behavior-b3]traffic policy p1
[Huawei-trafficpolicy-p1]classifier c3 behavior b3
[Huawei-trafficpolicy-p1]classifier c1 behavior b1
[Huawei-trafficpolicy-p1]classifier c2 behavior b2
[Huawei-trafficpolicy-p1]q
配置流应用(端口应用)
[Huawei]int gi0/0/2.1
[Huawei-GigabitEthernet0/0/2.1]traffic-policy p1 inbound
[Huawei-GigabitEthernet0/0/2.1]int gi0/0/2.2
[Huawei-GigabitEthernet0/0/2.2]traffic-policy p1 inbound
[Huawei-GigabitEthernet0/0/2.2]q
PC1访问internet路径:
PC2访问internet路径: