ip prefix-list 1 deny 192.168.0.0/16 le 32配置如下:
=====配置IP============
Router>enabl
Router>enable
Router#conf t
Router(config)#hostname r1
r1(config)#int e0/1
r1(config-if)#ip add 13.1.1.1 255.255.255.0
r1(config-if)#no sh
r1(config-if)#int loop 0
r1(config-if)#ip add 10.1.1.1 255.255.255.255
Router>enable
Router#conf t
Router(config)#hostname r2
r2(config)#int loop 0
r2(config-if)#ip add 10.1.1.2 255.255.255.255
r2(config-if)#int e0/0
r2(config-if)#ip add 23.1.1.2 255.255.255.0
r2(config-if)#no sh
Router>enable
Router#conf t
Router(config)#hostname r3
r3(config)#int loop 0
r3(config-if)#ip add 10.1.1.3 255.255.255.255
r3(config-if)#int e0/1
r3(config-if)#ip add 13.1.1.3 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int e0/0
r3(config-if)#ip add 23.1.1.3 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int e0/2
r3(config-if)#ip add 34.1.1.3 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int e0/3
r3(config-if)#ip add 35.1.1.3 255.255.255.0
r3(config-if)#no sh
Router>enable
Router#conf t
Router(config)#hostname r4
r4(config)#int loop 0
r4(config-if)#ip add 10.1.1.4 255.255.255.255
r4(config-if)#int e0/2
r4(config-if)#ip add 34.1.1.4 255.255.255.0
r4(config-if)#no sh
Router>enable
Router#conf t
Router(config)#hostname r5
r5(config)#int loop 0
r5(config-if)#ip add 10.1.1.5 255.255.255.255
r5(config-if)#int e0/3
r5(config-if)#ip add 35.1.1.5 255.255.255.0
r5(config-if)#no sh
查看:
r3#ping 13.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 13.1.1.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
r3#ping 23.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 23.1.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/2/7 ms
r3#ping 34.1.1.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 34.1.1.4, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
r3#ping 35.1.1.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 35.1.1.5, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
-------------------------
r1(config)#int e0/0
r1(config-if)#ip add 16.1.1.1 255.255.255.0
r1(config-if)#no sh
Router#conf t
Router(config)#hostname r6
r6(config)#int e0/0
r6(config-if)#ip add 16.1.1.6 255.255.255.0
r6(config-if)#no sh
r6(config-if)#int s1/0
r6(config-if)#encapsulation ppp
r6(config-if)#ip add 26.1.1.6 255.255.255.0
r6(config-if)#no sh
r6(config)#int loop 0
r6(config-if)#ip add 66.1.1.1 255.255.255.255
r2(config)#int s1/0
r2(config-if)#encapsulation ppp
r2(config-if)#ip add 26.1.1.2 255.255.255.0
r2(config-if)#no sh
查看:
r6#ping 16.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 16.1.1.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
r6#ping 26.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 26.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 19/19/20 ms
------------------------------
r4(config)#int e0/0
r4(config-if)#ip add 47.1.1.4 255.255.255.0
r4(config-if)#no sh
Router>enable
Router#conf t
Router(config)#hostname r7
r7(config)#int e0/0
r7(config-if)#ip add 47.1.1.7 255.255.255.0
r7(config-if)#no sh
r7(config)#int e0/1
r7(config-if)#ip add 78.1.1.7 255.255.255.0
r7(config-if)#no sh
r7(config)#int loop 0
r7(config-if)#ip add 77.1.1.1 255.255.255.255
Router>enable
Router#conf t
Router(config)#hostname r8
r8(config)#int e0/1
r8(config-if)#ip add 78.1.1.8 255.255.255.0
r8(config-if)#no sh
r8(config-if)#int e0/0
r8(config-if)#ip add 58.1.1.8 255.255.255.0
r8(config-if)#no sh
r8(config)#int loop 0
r8(config-if)#ip add 88.1.1.1 255.255.255.255
r5(config)#int e0/0
r5(config-if)#ip add 58.1.1.5 255.255.255.0
r5(config-if)#no sh
查看:
r7#ping 47.1.1.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 47.1.1.4, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 5/5/6 ms
r7#ping 78.1.1.8
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 78.1.1.8, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/2 ms
r8#ping 58.1.1.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 58.1.1.5, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/2/6 ms
=====配置核心网的IGP=========
r1(config)#int e0/1
r1(config-if)#ip ospf network point-to-point
r1(config-if)#exit
r1(config)#int range e0/1,loop 0
r1(config-if-range)#ip ospf 110 area 0
r2(config)#int e0/0
r2(config-if)#ip ospf network point-to-point
r2(config-if)#exit
r2(config)#int range e0/0,loop 0
r2(config-if-range)#ip ospf 110 area 0
r3(config)#int range e0/0-3
r3(config-if-range)#ip ospf network point-to-point
r3(config-if-range)#ip ospf 110 area 0
r3(config)#int loopback 0
r3(config-if)#ip ospf 110 area 0
r4(config)#int e0/2
r4(config-if)#ip ospf network point-to-point
r4(config-if)#exit
r4(config)#int range e0/2,loop 0
r4(config-if-range)#ip ospf 110 area 0
r5(config)#int e0/3
r5(config-if)#ip ospf network point-to-point
r5(config-if)#exit
r5(config)#int range e0/3,loop 0
r5(config-if-range)#ip ospf 110 area 0
查看:
r3#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
10.1.1.5 0 FULL/ - 00:00:37 35.1.1.5 Ethernet0/3
10.1.1.4 0 FULL/ - 00:00:33 34.1.1.4 Ethernet0/2
10.1.1.1 0 FULL/ - 00:00:36 13.1.1.1 Ethernet0/1
10.1.1.2 0 FULL/ - 00:00:30 23.1.1.2 Ethernet0/0
r3#show ip route ospf
10.0.0.0/32 is subnetted, 5 subnets
O 10.1.1.1 [110/11] via 13.1.1.1, 00:02:17, Ethernet0/1
O 10.1.1.2 [110/11] via 23.1.1.2, 00:02:17, Ethernet0/0
O 10.1.1.4 [110/11] via 34.1.1.4, 00:02:27, Ethernet0/2
O 10.1.1.5 [110/11] via 35.1.1.5, 00:02:17, Ethernet0/3
r1#show ip route ospf
10.0.0.0/32 is subnetted, 4 subnets
O 10.1.1.2 [110/21] via 13.1.1.3, 00:02:29, Ethernet0/1
O 10.1.1.3 [110/21] via 13.1.1.3, 00:02:29, Ethernet0/1
O 10.1.1.4 [110/21] via 13.1.1.3, 00:02:39, Ethernet0/1
O 10.1.1.5 [110/21] via 13.1.1.3, 00:02:29, Ethernet0/1
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/20] via 13.1.1.3, 00:02:39, Ethernet0/1
34.0.0.0/24 is subnetted, 1 subnets
O 34.1.1.0 [110/20] via 13.1.1.3, 00:02:39, Ethernet0/1
35.0.0.0/24 is subnetted, 1 subnets
O 35.1.1.0 [110/20] via 13.1.1.3, 00:02:39, Ethernet0/1 //无用
r1(config)#router ospf 110
r1(config-router)#prefix-suppression //OSPF的前缀抑制(无用)
r2(config)#router ospf 110
r2(config-router)#prefix-suppression
r3(config)#router ospf 110
r3(config-router)#prefix-suppression
r4(config)#router ospf 110
r4(config-router)#prefix-suppression
r5(config)#router ospf 110
r5(config-router)#prefix-suppression
查看:
r1#show ip route ospf
10.0.0.0/32 is subnetted, 5 subnets
O 10.1.1.2 [110/21] via 13.1.1.3, 00:11:38, Ethernet0/1
O 10.1.1.3 [110/11] via 13.1.1.3, 00:00:23, Ethernet0/1
O 10.1.1.4 [110/21] via 13.1.1.3, 00:11:48, Ethernet0/1
O 10.1.1.5 [110/21] via 13.1.1.3, 00:11:38, Ethernet0/1
r1(config)#int e0/1 //OSPF的按需电路,抑制OSPF每半小时泛洪一次的功能
r1(config-if)#ip ospf demand-circuit
r2(config)#int e0/0
r2(config-if)#ip ospf demand-circuit
r3(config)#int range e0/0-3
r3(config-if-range)#ip ospf demand-circuit
r4(config)#int e0/2
r4(config-if)#ip ospf demand-circuit
r5(config)#int e0/3
r5(config-if)#ip ospf demand-circuit
=====配置PE间的MP-BPG==============
r1(config)#router bgp 100
r1(config-router)#no bgp default ipv4-unicast //关闭默认的ipv4单播承载能力
r1(config-router)#neighbor 10.1.1.4 remote-as 100
r1(config-router)#neighbor 10.1.1.4 update-source loopback 0
r1(config-router)#address-family vpnv4 unicast
r1(config-router-af)#neighbor 10.1.1.4 activate
r4(config)#router bgp 100
r4(config-router)#no bgp default ipv4-unicast
r4(config-router)#neighbor 10.1.1.1 remote-as 100
r4(config-router)#neighbor 10.1.1.1 update-source loopback 0
r4(config-router)#address-family vpnv4 unicast
r4(config-router-af)#neighbor 10.1.1.1 activate
查看:
r1#show bgp vpnv4 unicast all summary
BGP router identifier 10.1.1.1, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.1.4 4 100 5 5 1 0 0 00:01:25 0
=====配置PE上的vrf =========================
方法一:只支持IPV4
r1(config)#ip vrf ?
WORD
r1(config)#ip vrf retacn
r1(config-vrf)#rd ?
ASN:nn, IP-address:nn or 4BASN:nn VPN Route Distinguisher
r1(config-vrf)#rd 100:200
r1(config-vrf)#exit
r1(config)#int e0/0
r1(config-if)#ip vrf forwarding ?
WORD VRF name
retacn VRF Name
r1(config-if)#ip vrf forwarding retacn
% Interface Ethernet0/0 IPv4 disabled and address(es) removed due to enabling VRF retacn
r1(config-if)#do show ip int br
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 unassigned YES NVRAM up up
r1(config-if)#ip add 16.1.1.1 255.255.255.0
r1(config-if)#do show ip int br
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 16.1.1.1 YES manual up up
r1(config-if)#do show ip rou //路由表中没有该条路由
10.0.0.0/32 is subnetted, 5 subnets
C 10.1.1.1 is directly connected, Loopback0
O 10.1.1.2 [110/21] via 13.1.1.3, 00:49:24, Ethernet0/1
O 10.1.1.3 [110/11] via 13.1.1.3, 00:38:09, Ethernet0/1
O 10.1.1.4 [110/21] via 13.1.1.3, 00:49:34, Ethernet0/1
O 10.1.1.5 [110/21] via 13.1.1.3, 00:49:24, Ethernet0/1
13.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 13.1.1.0/24 is directly connected, Ethernet0/1
L 13.1.1.1/32 is directly connected, Ethernet0/1
r1(config-if)#do show ip route vrf retacn //放入单独路由表中
Routing Table: retacn
16.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 16.1.1.0/24 is directly connected, Ethernet0/0
L 16.1.1.1/32 is directly connected, Ethernet0/0
r6#ping 16.1.1.1 //客户无感知
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 16.1.1.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/3/6 ms
----------------
方法二:即支持IPV4也支持IPV6
r4(config)#vrf definition retacn
r4(config-vrf)#rd 100:200
r4(config-vrf)#address-family ipv4
r4(config)#int e0/0
r4(config-if)#vrf forwarding retacn
r4(config-if)#ip add 47.1.1.4 255.255.255.0
查看:
r7#ping 47.1.1.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 47.1.1.4, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
=====配置CE-PE的路由============================
r6(config)#ip route 77.1.1.1 255.255.255.255 e0/0 16.1.1.1
r7(config)#ip route 66.1.1.1 255.255.255.255 e0/0 47.1.1.4
r1(config)#ip route vrf retacn 66.1.1.1 255.255.255.255 e0/0 16.1.1.6
r4(config)#ip route vrf retacn 77.1.1.1 255.255.255.255 e0/0 47.1.1.7
查看:
r1#show ip route vrf retacn
Routing Table: retacn
16.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 16.1.1.0/24 is directly connected, Ethernet0/0
L 16.1.1.1/32 is directly connected, Ethernet0/0
66.0.0.0/32 is subnetted, 1 subnets
S 66.1.1.1 [1/0] via 16.1.1.6, Ethernet0/0
r1#ping vrf retacn 66.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 66.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
r4#ping vrf retacn 77.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 77.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/5 ms
=====PE设备上的双向引入===================
r1(config)#router bgp 100
r1(config-router)#address-family ipv4 vrf retacn
r1(config-router-af)#redistribute static
r1(config-router-af)#end
*Dec 9 11:17:22.146: %SYS-5-CONFIG_I: Configured from console by console
r1#show bgp vpnv4 unicast all
BGP table version is 2, local router ID is 10.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 100:200 (default for vrf retacn)
*> 66.1.1.1/32 16.1.1.6 0 32768 ?
r1#show bgp vpnv4 unicast vrf retacn 66.1.1.1
BGP routing table entry for 100:200:66.1.1.1/32, version 2
Paths: (1 available, best #1, table retacn)
Not advertised to any peer
Refresh Epoch 1
Local
16.1.1.6 (via vrf retacn) from 0.0.0.0 (10.1.1.1)
Origin incomplete, metric 0, localpref 100, weight 32768, valid, sourced, best
mpls labels in/out 16/nolabel
rx pathid: 0, tx pathid: 0x0
r1(config)#mpls label range 100 199
r2(config)#mpls label range 200 299
r3(config)#mpls label range 300 399
r4(config)#mpls label range 400 499
r5(config)#mpls label range 500 599
r4(config)#router bgp 100
r4(config-router)#address-family ipv4 vrf retacn
r4(config-router-af)#redistribute static
查看:
r1#show bgp vpnv4 unicast all labels
Network Next Hop In label/Out label
Route Distinguisher: 100:200 (retacn)
66.1.1.1/32 16.1.1.6 100/nolabel
r4#show bgp vpnv4 unicast all labels
Network Next