作为一名网络工程师,经常需要解决企业分支机构间的安全互联问题。今天分享一个典型场景:两家企业通过公网建立私有连接,同时实现安全认证。这个方案结合了GRE隧道和PPP认证技术,既能保证数据传输的私密性,又能提供身份验证机制。
实验环境包含三台路由器:
物理连接方式:
注意:实际部署时,Serial接口通常用于广域网连接,模拟专线或帧中继环境
以AR1为例的接口配置:
bash复制interface Serial1/0/0
ip address 12.1.1.1 255.255.255.0
AR2作为中间节点需要配置两个接口:
bash复制interface Serial1/0/0 # 连接AR1
ip address 12.1.1.2 255.255.255.0
interface Serial1/0/1 # 连接AR3
ip address 23.1.1.2 255.255.255.0
企业路由器需要指向运营商路由器:
bash复制# AR1配置
ip route-static 0.0.0.0 0 12.1.1.2
# AR3配置
ip route-static 0.0.0.0 0 23.1.1.2
PAP(Password Authentication Protocol)采用明文传输密码,配置相对简单:
AR2(认证方)配置:
bash复制aaa
local-user admin password cipher Admin@123
local-user admin service-type ppp
interface Serial1/0/0
ppp authentication-mode pap
AR1(被认证方)配置:
bash复制interface Serial1/0/0
ppp pap local-user admin password cipher Admin@123
CHAP(Challenge Handshake Authentication Protocol)更安全,采用三次握手和哈希加密:
AR2(认证方)配置:
bash复制aaa
local-user tech password cipher Tech@456
local-user tech service-type ppp
interface Serial1/0/1
ppp authentication-mode chap
AR3(被认证方)配置:
bash复制interface Serial1/0/0
ppp chap user tech
ppp chap password cipher Tech@456
常见错误排查:
诊断命令:
bash复制display ppp packet # 查看PPP协商报文
display aaa online # 查看认证在线用户
GRE(Generic Routing Encapsulation)可以在IP网络中建立点对点的虚拟隧道:
AR1配置:
bash复制interface Tunnel0/0/0
ip address 192.168.1.1 255.255.255.0
tunnel-protocol gre
source 12.1.1.1
destination 23.1.1.3
AR3配置:
bash复制interface Tunnel0/0/0
ip address 192.168.1.2 255.255.255.0
tunnel-protocol gre
source 23.1.1.3
destination 12.1.1.1
将对方内网路由通过隧道发布:
bash复制# AR1配置
ip route-static 192.168.3.0 255.255.255.0 Tunnel0/0/0
# AR3配置
ip route-static 192.168.1.0 255.255.255.0 Tunnel0/0/0
测试隧道连通性:
bash复制ping -a 192.168.1.1 192.168.1.2
测试端到端连通性(PC1到PC2):
bash复制ping 192.168.3.100
bash复制sysname AR1
interface Serial1/0/0
ip address 12.1.1.1 255.255.255.0
ppp pap local-user admin password cipher Admin@123
interface Tunnel0/0/0
ip address 192.168.1.1 255.255.255.0
tunnel-protocol gre
source 12.1.1.1
destination 23.1.1.3
ip route-static 0.0.0.0 0 12.1.1.2
ip route-static 192.168.3.0 255.255.255.0 Tunnel0/0/0
检查GRE隧道状态:
bash复制display interface Tunnel0/0/0
查看路由表:
bash复制display ip routing-table
测试端到端时延:
bash复制ping -c 1000 -s 1400 192.168.3.100
GRE封装会导致报文增大,可能引发分片:
bash复制interface Tunnel0/0/0
mtu 1400
bash复制interface Tunnel0/0/0
tcp adjust-mss 1360
结合IPsec加密:
bash复制ipsec profile GRE_IPSEC
transform-set AES256-SHA1
sa spi inbound 1000
sa spi outbound 1001
interface Tunnel0/0/0
ipsec profile GRE_IPSEC
启用Keepalive检测:
bash复制interface Tunnel0/0/0
keepalive period 10 retry 3
监控隧道流量:
bash复制display interface Tunnel0/0/0 traffic
记录历史状态:
bash复制logging enable
logging host 192.168.1.100
在实际部署中,建议先进行小流量测试,确认稳定性后再逐步迁移业务流量。对于关键业务,可以考虑部署双GRE隧道实现冗余。