MAC header | IP header | GRE header | Data ::: |
GRE header, version 0:
00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
C | R | K | S | s | Recur | Flags | Version | Protocol | |||||||||||||||||||||||
Checksum | Offset | ||||||||||||||||||||||||||||||
Key | |||||||||||||||||||||||||||||||
Sequence Number | |||||||||||||||||||||||||||||||
Routing ::: |
C, Checksum Present. 1 bit.
The Checksum field is present and contains valid information if set. If either the Checksum Present bit or the Routing Present bit are set, the Checksum and Offsetfields are both present.
R, Routing Present. 1 bit.
If set then the Offset field is present and contains valid information. If either the Checksum Present bit or the Routing Present bit are set, the Checksum and Offsetfields are both present.
K, Key Present. 1 bit.
If set then the Key field is present and contains valid information.
S, Sequence Number present. 1 bit.
If set then the Sequence Number field is present and contains valid information.
s, Strict Source Route. 1 bit.
The meaning of this bit is defined in other documents. It is recommended that this bit only be set if all of the the Routing Information consists of Strict Source Routes.
Recur, Recursion Control. 3 bits, unsigned integer.
Contains the number of additional encapsulations which are permitted. 0 is the default value.
Flags. 5 bits.
These bits are reserved and must be transmitted as 0.
Version. 3 bits.
GRE protocol version. Must be cleared to 0.
Protocol. 16 bits.
Contains the protocol type of the payload packet. In general, the value will be the Ethernet protocol type field for the packet. Additional values may be defined in other documents.
Checksum. 16 bits.
Optional. Contains the IP (one's complement) checksum of the GRE header and the payload packet.
Offset. 16 bits.
Optional. Indicates the byte offset from the start of the Routing field to the first byte of the active Source Route Entry to be examined.
Key. 32 bits.
Optional. Contains a number which was inserted by the encapsulator. It may be used by the receiver to authenticate the source of the packet.
Sequence Number. 32 bits, unsigned.
Optional. Contains a number which is inserted by the encapsulator. It may be used by the receiver to establish the order in which packets have been transmitted from the encapsulator to the receiver.
Routing. Variable length.
Optional. This field is a list of SREs.
R1(config-line)#int s1/1
R1(config-if)#no sh
R1(config-if)#ip add 202.101.172.37 255.255.255.252
R1(config-if)#int lo0
R1(config-if)#ip add 172.16.1.1 255.255.255.0
R1(config-if)#ip add 172.16.2.1 255.255.255.0 se
R1(config-if)#exit
R1(config)#ip route 0.0.0.0 0.0.0.0 202.101.172.38 (配置一条默认路由)
R3(config-line)#int s1/0
R3(config-if)#no sh
R3(config-if)#ip add 218.108.248.202 255.255.255.252
R3(config-if)#int lo0
R3(config-if)#ip add 192.168.1.1 255.255.255.0
R3(config-if)#ip add 192.168.2.1 255.255.255.0 se
R3(config-if)#exit
R3(config)#ip route 0.0.0.0 0.0.0.0 218.108.248.201
|
R1(config)#do ping 218.108.248.202
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 218.108.248.202, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/27/64 ms
|
R1(config)#do ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
U.U.U
Success rate is 0 percent (0/5)
R1(config)#
|
R1(config)#interface tunnel 0 (启用GRE隧道)
R1(config-if)#ip add 10.1.1.1 255.255.255.0 (为隧道配置IP地址)
R1(config-if)#tunnel source serial1/1(配置隧道的本地源端口)
R1(config-if)#tunnel destination 218.108.248.202 (配置隧道的目标出口,目的IP的可达性,是通过之前配置的本地默认路由保证的)
R3(config)#int tunnel 0
R3(config-if)#ip add 10.1.1.2 255.255.255.0
R3(config-if)#tunnel source 218.108.248.202 (也可以指定隧道本地源IP)
R3(config-if)#tunnel destination 202.101.172.37
|
R3(config-if)#
*Mar 1 01:06:52.095: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel0,changed state to up
|
R1#sh interfaces tunnel0
Tunnel0 is up, line protocol is up (状态为UP)
Hardware is Tunnel (基于隧道的接口)
Internet address is 10.1.1.1/24
MTU 1514 bytes, BW 9 Kbit, DLY 500000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation TUNNEL, loopback not set (在原始的数据包上再封装了一个GRE报头)
Keepalive not set
Tunnel source 202.101.172.37 (Serial1/1), destination 218.108.248.202
Tunnel protocol/transport GRE/IP (隧道协议为GRE)
Key disabled, sequencing disabled
Checksumming of packets disabled
Tunnel TTL 255
………………
|
R1#sh ip route
…………
Gateway of last resort is 202.101.172.38 to network 0.0.0.0
202.101.172.0/30 is subnetted, 1 subnets
C 202.101.172.36 is directly connected, Serial1/1
172.16.0.0/24 is subnetted, 2 subnets
C 172.16.1.0 is directly connected, Loopback0
C 172.16.2.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Tunnel0 (显示隧道接口为直连路由)
S* 0.0.0.0/0 [1/0] via 202.101.172.38 (之前配置的默认路由)
|
R1#ping 10.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/34/68 ms
R1#
|
R3(config)#ip route 172.16.0.0 255.255.0.0 10.1.1.1 (也可以指定隧道接口对端的IP)
|
R1(config)#do ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/38/108 ms
R1(config)#do ping 192.168.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/36/84 ms
R1(config)#
|
R1#sh interface tunnel 0 stats
Tunnel0
Switching path Pkts In Chars In Pkts Out Chars Out
Processor 30 3720 30 3720
Route cache 0 0 0 0
Total 30 3720 30 3720
|