¹¦Äܼò½é£º
GRE£¨Generic Routing Encapsulation£¬Í¨Ó÷ÓÉ·â×°£©ÐÒéÊǶÔÄ³Ð©ÍøÂç²ãÐÒ飨ÈçIPºÍIPX£©µÄÊý¾Ý±¨ÎĽøÐзâ×°£¬Ê¹ÕâЩ±»·â×°µÄÊý¾Ý±¨ÎÄÄܹ»ÔÚÁíÒ»¸öÍøÂç²ãÐÒ飨ÈçIP£©Öд«Êä¡£·â×°ºóµÄÊý¾Ý±¨ÎÄÔÚÍøÂçÖд«ÊäµÄ·¾¶£¬³ÆÎªGREËíµÀ¡£GREËíµÀÊÇÒ»¸öÐéÄâµÄµãµ½µãµÄÁ¬½Ó£¬ÆäÁ½¶ËµÄÉ豸·Ö±ð¶ÔÊý¾Ý±¨½øÐзâ×°¼°½â·â×°¡£
Ò»¡¢×éÍøÐèÇó
½»»»»úSwitch AºÍ½»»»»úSwich BÖ®¼äͨ¹ýInternetÏàÁ¬¡£ÔËÐÐIPÐÒéµÄ˽ÓÐÍøÂçµÄÁ½¸ö×ÓÍøGroup 1ºÍGroup 2£¬Í¨¹ýÔÚÁ½Ì¨½»»»»úÖ®¼äʹÓÃGRE½¨Á¢ËíµÀʵÏÖ»¥Áª¡£
¶þ¡¢×éÍøÍØÆË
Èý¡¢ÅäÖÃÒªµã
GRE ËíµÀÅäÖðüÀ¨ÒÔϼ¸¸öÅäÖÃÒªµã£º
1¡¢ÅäÖÃËíµÀ½Ó¿Ú±àºÅ
2¡¢ÅäÖÃËíµÀģʽ£¨±¾ÀýÒÔÅäÖÃGRE
IPģʽΪÀý£©
3¡¢ÅäÖÃËíµÀµÄÔ´µØÖ·
4¡¢ÅäÖÃËíµÀÄ¿µÄµØÖ·
5¡¢ÅäÖÃËíµÀ·ÓÉ
×¢Ò⣺Èç¹ûËíµÀÁ½¶ËTunnel½Ó¿ÚµÄµØÖ·²»ÔÚͬһ¸öÍø¶Î£¬Ôò±ØÐëÅäÖÃͨ¹ýËíµÀµ½´ï¶Ô¶ËµÄת·¢Â·ÓÉ£¬ÒÔ±ãÐèÒª½øÐзâ×°µÄ±¨ÎÄÄÜÕý³£×ª·¢¡£Óû§¿ÉÒÔÅäÖþ²Ì¬Â·ÓÉ£¬Ò²¿ÉÒÔÅäÖö¯Ì¬Â·ÓÉ£¬ÔÚTunnelµÄÁ½¶Ë¶¼Òª½øÐдËÏîÅäÖ᣶ÔÁ½¸ö»òÁ½¸öÒÔÉÏʹÓÃͬÖÖ·â×°ÐÒéµÄTunnel½Ó¿Ú£¬²»ÄÜͬʱÅäÖÃÍêÈ«ÏàͬµÄÔ´µØÖ·ºÍÄ¿µÄµØÖ·¡£ÅäÖÃTunnel½Ó¿ÚµÄÔ´¶ËµØÖ·Ê±£¬Èô²ÉÓÃÅäÖÃÔ´½Ó¿ÚÐÎʽ£¬ÔòTunnelµÄÔ´µØÖ·È¡µÄÊÇÔ´½Ó¿ÚµÄÖ÷IPµØÖ·¡£
ËÄ¡¢ÅäÖò½Öè
˵Ã÷£ºÒѾÅäÖÃSwitchAºÍSwitchBÖ®¼äIPv4±¨ÎÄ·Óɿɴ
1£©ÔÚSwitchAµÄÅäÖÃ
Á¬½ÓIPv4Íâ²¿ÍøÂçµÄ½Ó¿Ú
SwitchA>enable
SwitchA#config ter
SwitchA#configureterminal
SwitchA(config)#interface
GigabitEthernet 2/1
SwitchA(config-if)#ip
address 2.2.2.1 255.255.255.0
Á¬½ÓIPv4ÄÚ²¿ÍøÂçµÄ½Ó¿Ú
SwitchA#configure
terminal
SwitchA(config)#interface
GigabitEthernet 2/2
SwitchA(config-if)#ip
address 1.1.1.1 255.255.255.0
ÅäÖÃGRE
IPËíµÀ½Ó¿Ú
SwitchA#configure
terminal
SwitchA(config)#interface
Tunnel 100
SwitchA(config-if-Tunnel
100)#tunnel mode gre ip
SwitchA(config-if-Tunnel
100)#ip address 5.5.5.4 255.255.255.0
SwitchA(config-if-Tunnel
100)#tunnel source 2.2.2.1
SwitchA(config-if-Tunnel
100)#tunnel destination 2.2.2.2
ÅäÖýøËíµÀµÄ·ÓÉ
SwitchA#configureterminal
SwitchA(config)#ip
route 3.3.3.0 tunnel 100
2£©ÔÚSwitchBµÄÅäÖÃ
Á¬½ÓIPv4Íâ²¿ÍøÂçµÄ½Ó¿Ú
SwitchB#configure
terminal
SwitchB(config)#interface
GigabitEthernet 2/1
SwitchB(config-if)#ip
address 2.2.2.2 255.255.255.0
Á¬½ÓIPv4ÄÚ²¿ÍøÂçµÄ½Ó¿Ú
SwitchB#configure
terminal
SwitchB(config)#interface
GigabitEthernet 2/2
SwitchB(config-if)#ip
address 3.3.3.1 255.255.255.0
ÅäÖÃGRE
IPËíµÀ½Ó¿Ú
SwitchB#configure
terminal
SwitchB(config)#interface
Tunnel 100
SwitchB(config-if-Tunnel
100)#tunnel mode gre ip
SwitchB(config-if-Tunnel
100)#ip address 5.5.5.5 255.255.255.0
SwitchB(config-if-Tunnel
100)#tunnel source 2.2.2.2
SwitchB(config-if-Tunnel
100)#tunnel destination 2.2.2.1
ÅäÖýøËíµÀµÄ·ÓÉ
SwitchB#configure
terminal
SwitchB(config)#ip
route 1.1.1.0 tunnel 100
Îå¡¢ÏÔʾÑéÖ¤
1¡¢Íê³ÉÉÏÊöÅäÖÃÖ®ºó£¬·Ö±ð²é¿´SwitchAºÍSwitchBµÄTunnel½Ó¿Ú״̬ÈçÏ£º
SwitchA#show
interface tunnel 100
Index(dec):9
(hex):9
Tunnel
100 is UP , line protocol is UP
Hardware is Tunnel
Interface address is: 5.5.5.4/24
Interface IPv6 address is:
No IPv6 address
MTU 1476 bytes, BW 9 Kbit
Encapsulation protocol is Tunnel,
loopback not set
Keepalive
interval is 10 sec ,retries 0.
Carrier delay is 2 sec
Tunnel
attributes:
Tunnel source 2.2.2.1, destination
2.2.2.2, routable
Tunnel TOS/Traffic Class not set, Tunnel
TTL 254
Tunnel config nested limit is 4, current
nested number is 0
Tunnel protocol/transport
is greip
Tunnel transport VPN is no set
Key disabled, Sequencing
disabled
Checksumming
of packets disabled
RX packets
Drop reason(Down: 0, Checksum error: 0,
sequence error: 0, routing: 0)
TX packets
Drop reason(Too big: 0, Payload Type
error: 0, Nested-limit: 0)
Rxload
is 1/255, Txload is 1/255
10 seconds input rate 0 bits/sec,
0 packets/sec
10 seconds output rate 0 bits/sec,
0 packets/sec
0 packets input, 0 bytes, 0
no buffer, 0 dropped
Received 0 broadcasts, 0
runts, 0 giants
0 input errors, 0 CRC, 0
frame, 0 overrun, 0 abort
0 packets output, 0 bytes, 0
underruns , 0 dropped
0
output errors, 0 collisions, 0 interface resets
SwitchB#show
interface tunnel 100
Index(dec):9
(hex):9
Tunnel
100 is UP , line protocol is
UP
Hardware is Tunnel
Interface address is: 5.5.5.5/24
Interface IPv6 address is:
No IPv6 address
MTU 1476 bytes, BW 9 Kbit
Encapsulation protocol is Tunnel,
loopback not set
Keepalive
interval is 10 sec ,retries 0.
Carrier delay is 2 sec
Tunnel
attributes:
Tunnel source 2.2.2.2, destination
2.2.2.1, routable
Tunnel TOS/Traffic Class not set, Tunnel
TTL 254
Tunnel config nested limit is 4, current
nested number is 0
Tunnel protocol/transport
is greip
Tunnel transport VPN is no set
Key disabled, Sequencing
disabled
Checksumming
of packets disabled
RX packets
Drop reason(Down: 0, Checksum error: 0,
sequence error: 0, routing: 0)
TX packets
Drop reason(Too big: 0, Payload Type
error: 0, Nested-limit: 0)
Rxload
is 1/255, Txload is 1/255
10 seconds input rate 0 bits/sec,
0 packets/sec
10 seconds output rate 0 bits/sec,
0 packets/sec
0 packets input, 0 bytes, 0
no buffer, 0 dropped
Received 0 broadcasts, 0
runts, 0 giants
0 input errors, 0 CRC, 0
frame, 0 overrun, 0 abort
0 packets output, 0 bytes, 0
underruns , 0 dropped
0
output errors, 0 collisions, 0 interface resets
2¡¢´ÓSwitch
AÉÏ¿ÉÒÔPingͨ¶Ô¶ËµÄ½Ó¿ÚµÄIPv4µØÖ·¡£
SwitchA#ping2.2.2.2
Sending
5, 100-byte ICMP Echoes to 2.2.2.2, timeout is 2 seconds:
<
press Ctrl+C to break >
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/10ms