GRE 封装隧道×××<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />
----------------------------------------------------------------------------------------------
config t
! 进入全局模式
hostname GRE_R1
! 主机名设置为GRE_R1
enable secret 0 star
! 特权口令设置为star
access-list 1 permit any
! 建立acl1,用来nat规则关联
interface FastEthernet 1/0
! 设置FastEthernet1/0口,用于连接Internet
ip nat outside
! 指定此接口连接外网
ip address 192.168.33.40 255.255.255.0
! 为此接口分配IP地址192.168.33.40/24
no shutdown
! 启用此接口
exit
!
interface FastEthernet 1/1
! 设置FastEthernet 1/1口,用于连接本地局域网(内网)
ip nat inside
! 指定此接口连接内网
ip address <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />10.32.1.1 255.255.255.0
! 为此接口分配IP地址10.32.1.1/24
no shutdown
! 启用此接口
exit
!
interface Tunnel0
! 创建Tunnel0接口,tunnel实现隧道,默认采用GRE封装格式
ip address 1.1.1.1 255.255.255.252
! 为Tunnel0接口分配IP地址1.1.1.1/30,用于隧道两端通信
tunnel source 192.168.33.40
! 指定隧道接口的源地址192.168.33.40即本地地址
tunnel destination 192.168.33.39
! 指定隧道接口的目的地址192.168.33.39即对端路由器地址
tunnel key 123456
! 设置tunnel接口的Key,提高tunnel两端的安全性
exit
!
ip nat inside source list 1 interface FastEthernet 1/0 overload
! 设置nat规则,关联ACL1,允许所有源主机进行nat
ip route 0.0.0.0 0.0.0.0 192.168.33.1
! 设置缺省路由即网关192.168.33.1
ip route 10.32.2.0 255.255.255.0 Tunnel0
! 添加静态路由器,目的地址为10.32.2.0/24 下一跳出口指定Tunnel0
line vty 0 4
! 设置vty 0-4的密码 即telnet口令
login
password 0 star
! telnet口令设置为star
exit
end
write
! 保存配置
----------------------------------------------------------------------------------------------
config t
! 进入全局模式
hostname GRE_R2
! 主机名设置为GRE_R2
enable secret 0 star
! 特权口令设置为star
access-list 1 permit any
! 建立acl1,用来nat规则关联
interface FastEthernet 1/0
! 设置FastEthernet1/0口,用于连接Internet
ip nat outside
! 指定此接口连接外网
ip address 192.168.33.39 255.255.255.0
! 为此接口分配IP地址192.168.33.39/24
no shutdown
! 启用此接口
exit
!
interface FastEthernet 1/1
! 设置FastEthernet 1/1口,用于连接本地局域网(内网)
ip nat inside
! 指定此接口连接内网
ip address 10.32.2.1 255.255.255.0
! 为此接口分配IP地址10.32.2.1/24
no shutdown
! 启用此接口
exit
!
interface Tunnel0
! 创建Tunnel0接口,tunnel实现隧道,默认采用GRE封装格式
ip address 1.1.1.2 255.255.255.252
! 为Tunnel0接口分配IP地址1.1.1.1/30,用于隧道两端通信
tunnel source 192.168.33.39
! 指定隧道接口的源地址192.168.33.40即本地地址
tunnel destination 192.168.33.40
! 指定隧道接口的目的地址192.168.33.39即对端路由器地址
tunnel key 123456
! 设置tunnel接口的Key,提高tunnel两端的安全性
exit
!
ip nat inside source list 1 interface FastEthernet 1/0 overload
! 设置nat规则,关联ACL1,允许所有源主机进行nat
ip route 0.0.0.0 0.0.0.0 192.168.33.1
! 设置缺省路由即网关192.168.33.1
ip route 10.32.1.0 255.255.255.0 Tunnel0
! 添加静态路由器,目的地址为10.32.2.0/24 下一跳出口指定Tunnel0
line vty 0 4
! 设置vty 0-4的密码 即telnet口令
login
password 0 star
! telnet口令设置为star
exit
end
write
! 保存配置
GRE_R1#sh interface tunnel 0
Tunnel 0 is UP , line protocol is UP
Hardware is Tunnel
Interface address is: 1.1.1.1/30
MTU 1472 bytes, BW 9 Kbit
Encapsulation protocol is Tunnel, loopback not set
Keepalive interval is 0 sec , no set
Carrier delay is 0 sec
RXload is 1 ,Txload is 1
Tunnel source 192.168.33.40, destination 192.168.33.39
Tunnel protocol/transport GRE/IP, key 0x1e240, sequencing disabled
Checksumming of packets disabled Queueing strategy: WFQ
5 minutes input rate 0 bits/sec, 0 packets/sec
5 minutes output rate 1 bits/sec, 0 packets/sec
126 packets input, 12953 bytes, 0 no buffer
Received 0 broadcasts, 0 runts, 0 giants
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 abort
135 packets output, 14824 bytes, 0 underruns
0 output errors, 0 collisions, 0 interface resets
GRE_R1#
GRE_R2#sh interface tunnel 0
Tunnel 0 is UP , line protocol is UP
Hardware is Tunnel
Interface address is: 1.1.1.2/30
MTU 1472 bytes, BW 9 Kbit
Encapsulation protocol is Tunnel, loopback not set
Keepalive interval is 0 sec , no set
Carrier delay is 0 sec
RXload is 1 ,Txload is 1
Tunnel source 192.168.33.39, destination 192.168.33.40
Tunnel protocol/transport GRE/IP, key 0x1e240, sequencing disabled
Checksumming of packets disabled Queueing strategy: WFQ
5 minutes input rate 12 bits/sec, 0 packets/sec
5 minutes output rate 16 bits/sec, 0 packets/sec
135 packets input, 12928 bytes, 0 no buffer
Received 0 broadcasts, 0 runts, 0 giants
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 abort
126 packets output, 14617 bytes, 0 underruns
0 output errors, 0 collisions, 0 interface resets
GRE_R2#
转载于:https://blog.51cto.com/hj0822/123290