配置IP地址
[r1]int s4/0/0
[r1-Serial4/0/0]ip add 15.0.0.1 24
[r1-Serial4/0/0]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.1.2 24
r2]int s4/0/0
[r2-Serial4/0/0]ip add 25.0.0.1 24
[r2-Serial4/0/0]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 192.168.2.2 24
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 192.168.3.2 24
[r3-GigabitEthernet0/0/0]int s4/0/0
[r3-Serial4/0/0]ip add 35.0.0.1 24
[r4]int g0/0/01
[r4-GigabitEthernet0/0/1]ip add 45.0.0.1 24
[r4-GigabitEthernet0/0/1]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 192.168.4.2 24
lsp]int s4/0/0
[lsp-Serial4/0/0]ip add 15.0.0.2 24
[lsp-Serial4/0/0]int s4/0/1
[lsp-Serial4/0/1]ip add 25.0.0.2 24
[lsp-Serial4/0/1]int s3/0/0
[lsp-Serial3/0/0]ip add 35.0.0.2 24
[lsp-Serial3/0/0]int g0/0/0
[lsp-GigabitEthernet0/0/0]ip add 45.0.0.2 24
r1和r5用ppp认证 r5为主认证方(在华为默认封装为ppp)
首先在r5上进行注册用户和密码
[lsp]aaa
[lsp-aaa]lo
[lsp-aaa]local-user xh pa
[lsp-aaa]local-user xh password ci
[lsp-aaa]local-user xh password cipher 12345
在r1上提供认证信息
[r1-Serial4/0/0]ppp pap local-user xh password cipher 12345
r2和r5用ppp的chap认证 r5为主认证方
在r5上已经注册了用户可以直接调用
r5
lsp]int s4/0/1
[lsp-Serial4/0/1]ppp authentication-mode chap
在r2提供认证信息
r2]int 4/0/0s
[r2-Serial4/0/0]ppp chap user xh
[r2-Serial4/0/0]ppp chap password cipher 12345
r3和r5进行hdlc封装
在路由器上直接修改认证信息
[lsp]int s3/0/0
[lsp-Serial3/0/0]link-protocol hdlc
[r3]int s4/0/0
[r3-Serial4/0/0]link-protocol hdlc
r1、r2、r3构建一个mgre环境,r1为中心站点;
先写缺省将网络做通
[r1]ip route-static 0.0.0.0 0 15.0.0.2
[r2]ip route-static 0.0.0.0 0 25.0.0.2
[r3]ip route-static 0.0.0.0 0 35.0.0.2
[r4]ip route-static 0.0.0.0 0 45.0.0.2
在进行MGRE环境的搭建
[r1]int t0/0/0
[r1-Tunnel0/0/0]ip add 192.168.5.1 24
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp
[r1-Tunnel0/0/0]sou
[r1-Tunnel0/0/0]source 15.0.0.1
[r1-Tunnel0/0/0]nhrp network-id 50
[r2]int t0/0/0
[r2-Tunnel0/0/0]ip add 192.168.5.2 24
[r2-Tunnel0/0/0]tunnel-protocol gre p2mp
[r2-Tunnel0/0/0]sou
[r2-Tunnel0/0/0]source s4/0/0
[r2-Tunnel0/0/0]nhrp network-id 50
[r2-Tunnel0/0/0]nhrp entry 192.168.5.1 15.0.0.1 register
interface Tunnel0/0/0
ip address 192.168.5.3 255.255.255.0
tunnel-protocol gre p2mp
source Serial4/0/0
nhrp network-id 50
nhrp entry 192.168.5.1 15.0.0.1 register
r1,r4进行点到点的GRE
[r1]int t0/0/1
[r1-Tunnel0/0/1]ip add 192.168.6.1 24
[r1-Tunnel0/0/1]tunnel-protocol gre
[r1-Tunnel0/0/1]source 15.0.0.1
[r1-Tunnel0/0/1]destination 45.0.0.1
[r4]int t0/0/1
[r4-Tunnel0/0/1]ip add 192.168.6.2 24
[r4-Tunnel0/0/1]tunnel-protocol gre
[r4-Tunnel0/0/1]source 45.0.0.1
[r4-Tunnel0/0/1]destination 15.0.0.1
整个私有网基于rip全网可达
注意;Mgre环境下是单播传递,rip是组播传递所以要写一个微广播
[r1-Tunnel0/0/0]nhrp entry multicast dynamic
进行rip的配置
[r1]rip 1
[r1-rip-1]v 2
[r1-rip-1]network 192.168.1.0
[r1-rip-1]network 192.168.5.0
[r1-rip-1]network 192.168.6.0
[r2]rip 1
[r2-rip-1]v 2
[r2-rip-1]network 192.168.2.0
[r2-rip-1]network 192.168.5.0
[r3]rip 1
[r3-rip-1]v 2
[r3-rip-1]network 192.168.3.0
[r3-rip-1]network 192.168.5.0
[r4]rip 1
[r4-rip-1]v 2
[r4-rip-1]network 192.168.4.0
[r4-rip-1]network 192.168.6.0
宣告的时候每个网段都要宣告
在网络r2和r3的信息是由r1出的但由于rip得水平分割的原理r2收不到r3的一些路由可以在t0/0/0接口关闭水平分割
undo rip split-horizon
所有的PC都可以访问r5的环回
这个就是私网IP到公网IP的转换可以用nat来抓取私网的流量以此来达到私网访问公网的目的
[r1]acl 2000
[r1-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[r1-acl-basic-2000]q
[r1]int s4/0/0
[r1-Serial4/0/0]nat outbound 2000
r3]acl 2000
[r3-acl-basic-2000]rule permit source 192.168.3.0 0.0.0.255
[r3-acl-basic-2000]int s4/0/0
[r3-Serial4/0/0]nat outbound 2000
[r2]acl 2000
[r2-acl-basic-2000]rule permit source 192.168.2.0 0.0.0.255
[r2-acl-basic-2000]q
[r2]int s4/0/0
[r2-Serial4/0/0]nat outbound 2000
[r4]acl 2000
[r4-acl-basic-2000]rule permit source 192.168.4.0 0.0.0.255
[r4-acl-basic-2000]int g0/0/1
[r4-GigabitEthernet0/0/1]nat outbound 2000