配置表如下

AR2–AR3

AR2 GE0/0/0

AR3 GE0/0/1

100.1.1.0/24

AR3–LSW3

AR3 GE0/0/0

LSW3 GE0/0/4

192.168.4.0/24

LSW3–FW1(上)

LSW3 GE0/0/3

FW1 GE1/0/0

192.168.3.0/24

LSW3–FW1(中)

LSW3 GE0/0/7

FW1 GE1/0/2

192.168.7.0/24(图示遮挡,按 VLAN 规划取)

LSW3–FW1(下)

LSW3 GE0/0/6

FW1 GE1/0/1

192.168.6.0/24

LSW3–LSW1

LSW3 GE0/0/1

LSW1 GE0/0/2

二层 Trunk,VLAN 10

LSW3–LSW2

LSW3 GE0/0/2

LSW2 GE0/0/2

二层 Trunk,VLAN 20

LSW1–PC1

LSW1 GE0/0/1

PC1 Ethernet0/0/1

192.168.1.0/24,VLAN 10

LSW2–PC2

LSW2 GE0/0/1

PC2 Ethernet0/0/1

192.168.2.0/24,VLAN 20

FW1–Cloud2

FW1 GE0/0/0

Cloud2 Ethernet0/0/1

云/公网侧,untrust 区

因为要求 1 需要测试“公网通”,所以 r2需要:把 GE0/0/0 配成 100.1.1.2/24,把 LoopBack0 配成 2.2.2.2/32,且让内网 ping 2.2.2.2 之后还要能回包。

system-view

sysname r2

interface GigabitEthernet0/0/0

 ip address 100.1.1.2 255.255.255.0

interface LoopBack0

 ip address 2.2.2.2 255.255.255.255

ip route-static 192.168.1.0 255.255.255.0 100.1.1.1

ip route-static 192.168.2.0 255.255.255.0 100.1.1.1

ip route-static 192.168.3.0 255.255.255.0 100.1.1.1

ip route-static 192.168.4.0 255.255.255.0 100.1.1.1

ip route-static 192.168.6.0 255.255.255.0 100.1.1.1

ip route-static 192.168.7.0 255.255.255.0 100.1.1.1

ospf 1 router-id 2.2.2.2

area 0

 network 100.1.1.0 0.0.0.255

 network 2.2.2.2 0.0.0.0

因为 r2 和 lsw3 不在同一个网段,所以 r3 要当中间的转发点:GE0/0/1 接 r2,用 100.1.1.1;GE0/0/0 接 lsw3,用 192.168.4.2。因为这个接口要参与 lsw3 的 VPN 路由传递,所以要把它放进 VPN c,并开启 MPLS、LDP 和 BGP,让两边互相知道 192.168.4.0 这一段。

sysname r3

ip vpn-instance c

 route-distinguisher 1:3

 vpn-target 1:3 export-extcommunity

vpn-target 1:3 import-extcommunity

 interface GigabitEthernet0/0/1

 ip address 100.1.1.1 255.255.255.0

interface GigabitEthernet0/0/0

 ip binding vpn-instance c

 ip address 192.168.4.2 255.255.255.0

interface LoopBack0

 ip address 3.3.3.3 255.255.255.255

mpls lsr-id 3.3.3.3

mpls

mpls ldp

interface GigabitEthernet0/0/0

 mpls

mpls ldp

ospf 1 router-id 3.3.3.3

 area 0

network 100.1.1.0 0.0.0.255

 network 3.3.3.3 0.0.0.0

ospf 2 vpn-instance c router-id 3.3.3.3

 area 0

 network 192.168.4.0 0.0.0.255

bgp 100

peer 4.4.4.4 as-number 100

 peer 4.4.4.4 connect-interface LoopBack0

ipv4-family vpnv4

peer 4.4.4.4 enable

ipv4-family vpn-instance c

import-route ospf 2

return

save force

因为要求 1 要内网通,所以先把 VLAN 10、20、30、40、60、70 建好,并给每个 VLAN 配好网关。又因PC1 和 PC2 不能混在一起,所以把接口分到 VPN a、b、c 三个组。

要求 3 要让流量经过防火墙,所以最后加两条默认路由:a 组走 192.168.6.1,b 组走 192.168.7.1,也就是 FW1。

ip vpn-instance c

route-distinguisher 1:3

 vpn-target 1:3 export-extcommunity

 vpn-target 1:3 import-extcommunity

vlan batch 10 20 30 40 60 70

interface Vlanif10

ip binding vpn-instance a

ip address 192.168.1.254 255.255.255.0

interface Vlanif20

 ip binding vpn-instance b

ip address 192.168.2.254 255.255.255.0

interface Vlanif30 

ip binding vpn-instance c

 ip address 192.168.3.254 255.255.255.0

interface Vlanif60

 ip binding vpn-instance a

ip address 192.168.6.254 255.255.255.0

interface Vlanif70

 ip binding vpn-instance b

 ip address 192.168.7.254 255.255.255.0

interface GigabitEthernet0/0/1

 port link-type access

port default vlan 10

interface GigabitEthernet0/0/2

port link-type access

port default vlan 20

interface GigabitEthernet0/0/3

port link-type access port default vlan 30

interface GigabitEthernet0/0/6

port link-type access port default vlan 60

 interface GigabitEthernet0/0/7

port link-type access

port default vlan 70

interface GigabitEthernet0/0/4

undo portswitch

ip binding vpn-instance c

 ip address 192.168.4.1 255.255.255.0

 nterface LoopBack0

 ip address 4.4.4.4 255.255.255.255

mpls lsr-id 4.4.4.4

mpls

mpls ldp

interface GigabitEthernet0/0/4

 mpls

 mpls ldp

 ospf 1

 router-id 4.4.4.4

 area 0

 network 4.4.4.4 0.0.0.0

network 192.168.4.0 0.0.0.255

 bgp 100

 peer 3.3.3.3 as-number 100

peer 3.3.3.3 connect-interface LoopBack

 ipv4-family vpnv4

 peer 3.3.3.3 enable

 ipv4-family vpn-instance a

 network 192.168.1.0 255.255.255.0

 network 192.168.6.0 255.255.255.0

ipv4-family vpn-instance b

 network 192.168.2.0 255.255.255.0

network 192.168.7.0 255.255.255.0

 ipv4-family vpn-instance c

 network 192.168.3.0 255.255.255.0

 import-route ospf 2

ip route-static vpn-instance a 0.0.0.0 0.0.0.0 192.168.6.1

ip route-static vpn-instance b 0.0.0.0 0.0.0.0 192.168.7.1

return

save force

因为 PC1 属于 VLAN 10,所以 LSW1 上只要建 VLAN 10:接 PC 的口设为 access,接 LSW3 的口设为 trunk 并放行 VLAN 10。

system-view

sysname LSW1

vlan batch 10

interface GigabitEthernet0/0/1

 port link-type access

port default vlan 10

 interface GigabitEthernet0/0/2

 port link-type trunk

 port trunk allow-pass vlan 10

 return

save force

PC2属于vlan20 操作如上,将VLAN改为20

因为要求 2 要用 easy-ip,所以 FW1 先把三个接内网的口放进 trust 区、接云的口放进 untust 区,再写一条安全策略放行 trust 到 untrust。

因为内网地址是私有地址,所以再写 NAT 策略,把源地址换成出接口地址 202.1.1.1。因为回包还要找得到 PC,所以最后写回程路由,指向 LSW3 的 192.168.6.254、192.168.7.254 和 192.168.3.254。

system-view

sysname fw2

interface GigabitEthernet0/0/0

 ip address 202.1.1.1 255.255.255.0

interface GigabitEthernet1/0/0

 ip address 192.168.3.1 255.255.255.0

interface GigabitEthernet1/0/1

 ip address 192.168.6.1 255.255.255.0

interface GigabitEthernet1/0/2

 ip address 192.168.7.1 255.255.255.0

firewall zone trust

add interface GigabitEthernet1/0/0

add interface GigabitEthernet1/0/1

 add interface GigabitEthernet1/0/2

firewall zone untrust

 add interface GigabitEthernet0/0/0

security-policy

rule name trust_to_untrust

 source-zone trust

 destination-zone untrust

 action permit

 rule name untrust_to_trust

 source-zone untrust

 destination-zone trust

 action permit

 nat-policy rule name easy_ip

source-zone trust

 destination-zone untrust

 source-address 192.168.1.0 255.255.255.0

 source-address 192.168.2.0 255.255.255.0

 source-address 192.168.3.0 255.255.255.0

source-address 192.168.6.0 255.255.255.0

 source-address 192.168.7.0 255.255.255.0

 action nat easy-ip

ip route-static 192.168.1.0 255.255.255.0 192.168.6.254

ip route-static 192.168.2.0 255.255.255.0 192.168.7.254

ip route-static 192.168.3.0 255.255.255.0 192.168.3.254

ip route-static 0.0.0.0 0.0.0.0 202.1.1.2

return

save force

PC1 192.168.1.1/24 网关192.168.1.254

PC2 192.168.2.1/24 网关192.1468.2.254

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐