日常我们配置家用路由器的时候,习惯用WEB页面。Web的背后是命令行,今天我们用命令行实现配置,揭露web背后的故事。
本次实验用两台路由器,一台为PPPOE客户端,另外一台为PPPOE服务端,在服务端配置一个环回口,模拟公网。
一、拓扑

二、配置
2.1 基本配置
2.1.1客户端
system-view

[Huawei]sysname Client

[Client]
2.1.2服务器端
system-view

[Huawei]sysname Server

[Server]
给服务器端配置一个环回接口,来模拟公网地址,具体环回接口在我发的微头条中有介绍。
[Server]interface LoopBack 0

[Server-LoopBack0]ip address 100.100.100.100 32

[Server-LoopBack0]
查看路由表
disp ip routing-table

2.2 PPPOE服务器端配置

2.2.1创建地址池
地址池类似于DHCP,是服务器给远程用户分配"pppoe"地址池中的IP地址所需,
[Server]ip pool pppoe
给客户端分配的ip地址的范围是200.1.1.1到200.1.1.254
[Server-ip-pool-pppoe]network 200.1.1.0 mask 24

给客户端分配网关
[Server-ip-pool-pppoe]gateway-list 200.1.1.1

给客户端分配的dns地址
[Server-ip-pool-pppoe]dns-list 218.30.19.40 61.134.1.4

2.2.2 配置虚拟模板
以太网接口上不能配置地址,因为现在的以太网物理接口已经默认封装了以太网协议,无法再封装其他的广域网协议,所以才需要Virtual-Template来模拟一个(WAN)ppp接口,然后封装其他协议如ppp,最后再把虚拟模板(Virtual-Template)绑定到物理接口,实现ppp和以太网协议的嵌套。Virtual-Template模板就是为了让一条链路上可以封装多种同层协议的虚拟接口。
创建虚拟模板接口编号,随意,这里是1
[Server]interface Virtual-Template 1

配置ppp采用chap方式认证(具有加密功能)
[Server-Virtual-Template1]ppp authentication-mode chap

配置本端Virtual-Template接口的ip地址为200.1.1.1
[Server-Virtual-Template1]ip address 200.1.1.1 24

为远程pppoe客户端分配ip池"pppoe"中的ip地址(刚才创建的地址池叫pppoe)
[Server-Virtual-Template1]remote address pool pppoe

查看
[Server-Virtual-Template1]dis th

2.2.3配置aaa认证用户
进入aaa本地用户数据库
[Server]aaa

定义ppp认证的用户名"huawei"和123456(相当于运营商给的pppoe的账号和密码)
[Server-aaa]local-user huawei password cipher 123456

定义用户"huawei"的用途是做ppp认证
[Server-aaa]local-user huawei service-type ppp

2.2.4物理接口调用虚拟接口,实现pppoe协议的封装
[Server]interface g0/0/0

将GE0/0/0接口与虚拟接口1进行绑定
[Server-GigabitEthernet0/0/0]pppoe-server bind virtual-template 1

2.3PPPOE客户端配置
配置拨号规则
客户端
由于PPPOE是靠拨号完成,需要创建虚拟拨号接口(dialer)并配置,在这个接口下配置封装协议、ppp认证、ip地址自动获得、dialer接口拨号使用的用户名、pppoe连接建立的等待时间、dialer所属的组、指定dialer接口的编号(这个编号是用来和物理接口绑定时候用到的编号)、nat地址转换等等的配置,所以该拨号虚拟接口功能强大,承载任务重。
2.3.1 配置拨号规则dialer-rule
进入dialer-rule视图,用来匹配允许pppoe拨号连接的流量
[Client]dialer-rule

只要有ip流量就进行拨号
[Client-dialer-rule]dialer-rule 1 ip permit

2.3.2配置拨号虚拟接口
创建拨号dialer 0虚拟接口
[Client]interface Dialer 0

创建一个用户名(非拨号用户名), 该用户名不用于认证,是标识作用以及和dialer绑定
[Client-Dialer0]dialer user hcna

dialer接口加入dialer-group组中(每个dialer只能加入一个组)
[Client-Dialer0]dialer-group 1

绑定拨号组号1,用于和物理接口绑定
[Client-Dialer0]dialer bundle 1

配置拨号失败时将dialer接口状态转换为Down

上面这条配置是个坑,如果不配置这条,有可能PPP协议不能启动,在物理接口g0/0/0上是down的状态,dialer0也不会获得IP地址。
2.3.3配置ppp协议
封装ppp协议
[Client-Dialer0]link-protocol ppp

配置ppp的chap认证,用户名为huawei(对应在服务器端配置)
[Client-Dialer0]ppp chap user huawei

[Client-Dialer0]ppp chap password simple 123456

设置pppoe客户端自动获取ip地址
[Client-Dialer0]ip address ppp-negotiate

查看
[Client-Dialer0]dis th

2.3.4物理接口与dialer接口绑定
[Client]interface g0/0/0
[Client-GigabitEthernet0/0/0]

物理接口与dialer0接口进行绑定, on-demand参数用于指定该pppoe拨号连接是按需拨号连接(需要第2步中的dialer-rule来定义按需允许的流量)
[Client-GigabitEthernet0/0/0]pppoe-client dial-bundle-number 1 on-demand

查看
[Client-GigabitEthernet0/0/0]dis th

查看IP接口
[Client]dis ip int b

由上图知悉,dialer口已经拨号成功,并且获得到一个IP地址200.1.1.254/24
2.3.5配置默认路由
为了让路由器可以与其背后的loopback接口通信,相当于连接互联网,在客户端做一条默认路由,
[Client]ip route-static 0.0.0.0 0.0.0.0 Dialer 0

三、验证
[Client]disp ip routing-table

[Client]ping 100.100.100.100

配置完成,验证成功。
关键词:SHOW华为企业路由器完成拨号到公网(华为企业路由器如何设置拨号上网)