案例拓扑
这是之前我发在华为企业社区的帖子,转过来的
实现:
1、192.168.1.0/24内网动态分配IP地址并且保留HTTP服务器地址
2、实现PPPOE拨号并且内网能NAT共享一个IP地址上网
2.公网的PPP服务器配置脚本
#
ip pool pppoe
network 123.4.5.0 mask 255.255.255.0
dns-list 123.4.5.1
#
interface Virtual-Template1
remote address pool pppoe
ip address unnumbered interface GigabitEthernet0/0/0
#
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user a password cipher %$%$Hp#3II:wXB=]T#TJu%u%<U&*%$%$ //此处定义PPPOE账号a,密码a
local-user a service-type ppp
#
interface GigabitEthernet0/0/0
pppoe-server bind Virtual-Template 1
ip address 123.4.5.1 255.255.255.0
3.在R1路由器上配置
(1)定义拨号规则
[R1]dialer-rule
[R1-dialer-rule]dialer-rule 1 ip permit
//这里就是定义的拨号规则,允许所有的IPV4流量通过。
(2)拨号接口
[R1]interface Dialer 1
[R1-Dialer1]dialer user a
[R1-Dialer1]dialer-group 1 //关联的拨号接口
[R1-Dialer1]dialer bundle 1 //定义一个bundle,后面在接口调用
[R1-Dialer1]ppp chap user a
[R1-Dialer1]ppp chap password simple a
[R1-Dialer1]ip address ppp-negotiate
(3)接口下调用
[R1-GigabitEthernet0/0/0]pppoe-client dial-bundle-number 1
(4)取得地址,PPP协商成功
如果PPPOE上网出现网页打不开的情况,建议MTU在1492即可,因为PPPOE会多出8字节的头部,而MSS在1200~1452之间。
[R1]interface Dialer 1
[R1-Dialer1]mtu 1492
[R1-Dialer1]tcp adjust-mss 1452
###########################
interface Dialer1
link-protocol ppp
ppp chap user a
ppp chap password simple a
mtu 1492
tcp adjust-mss 1452
ip address ppp-negotiate
dialer user a
dialer bundle 1
dialer-group 1
nat outbound 2000
###############################
4.配置NAT,默认路由
(1)默认路由配置
[R1]ip route-static 0.0.0.0 0 Dialer 1
(2)NAT配置
[R1]acl number 2000
[R1-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R1]interface Dialer 1
[R1-Dialer1]nat outbound 2000
4.内网DHCP配置
#开启DHCP服务
dhcp enable
# //定义一个内网ip地址池
ip pool lan
gateway-list 192.168.1.1
network 192.168.1.0 mask 255.255.255.0
lease day 7 hour 0 minute 0
dns-list 8.8.8.8
excluded-ip-address 192.168.1.6 //排除IP
#在接口下应用DHCP池
[R1-GigabitEthernet0/0/1]ip add 192.168.1.1 24
[R1-GigabitEthernet0/0/1]dhcp select global
我们可以看到内网主机成功获取IP地址,并且连上外网。
5.映射80端口出局(WWW也可以是其他端口)
[R1-Dialer1]nat server protocol tcp global current-interface www inside 192.168.1.6 www
我们可以看到外网可以成功访问内网的HTTP服务器