4.1 NAT-地址转换
4.1.1 用出接口地址做Easy nat
【Router】
当前路由器提示视图 |
依次输入的配置命令,重要的命令红色突出显示 |
简单说明 |
|
! |
适用版本vrp1.74及1.44 |
[Router] |
acl 2000 match-order auto |
|
[Router-acl2000] |
rule normal permit source 10.0.0.0 0.0.0.255 |
|
[Router-acl2000] |
rule deny ip source any |
配置允许进行NAT转换的内网地址段 |
|
! |
|
[Router] |
interface Ethernet0 |
|
[Router-Ethernet0] |
ip address 10.0.0.1 255.255.255.0 |
|
|
! |
|
[Router] |
interface Ethernet1 |
|
[Router-Ethernet1] |
ip address 202.1.1.1 255.255.255.0 |
|
[Router-Ethernet1] |
nat outbound 2000 interface |
在出接口上进行NAT转换 |
|
! |
|
[Router] |
ip route-static 0.0.0.0 0.0.0.0 202.1.1.2 preference 60 |
|
[Router] |
! |
|
[Router] |
return |
|
4.1.2 地址池方式做nat
【Router】
当前路由器提示视图 |
依次输入的配置命令,重要的命令红色突出显示 |
简单说明 |
|
! |
适用版本vrp1.74及1.44 |
[Router] |
nat address-group 1 202.1.1.1 202.1.1.6 pool1 |
|
|
! |
|
[Router] |
acl 2000 match-order auto |
|
[Router-acl2000] |
rule normal permit source 10.0.0.0 0.0.0.255 |
|
[Router-acl2000] |
rule deny ip source any |
配置允许进行NAT转换的内网地址段 |
|
! |
|
[Router] |
interface Ethernet0 |
|
[Router-Ethernet0] |
ip address 10.0.0.1 255.255.255.0 |
|
|
! |
|
[Router] |
interface Ethernet1 |
|
[Router-Ethernet1] |
ip address 202.1.1.1 255.255.255.0 |
|
[Router-Ethernet1] |
nat outbound 2000 pool pool1 |
在出接口上进行NAT转换 |
|
! |
|
[Router] |
ip route-static 0.0.0.0 0.0.0.0 202.1.1.2 preference 60 |
|
|
! |
|
|
return |
|
4.1.3 ISDN拨号做nat上网
【Router】
当前路由器提示视图 |
依次输入的配置命令,重要的命令红色突出显示 |
简单说明 |
|
! |
适用版本vrp1.74及1.44 |
[Router] |
dialer-rule 1 ip permit |
|
[Router] |
! |
|
|
acl 2000 match-order auto |
|
[Router-acl2000] |
rule normal permit source 10.0.0.0 0.0.0.255 |
|
[Router-acl2000] |
rule deny ip source any |
|
|
! |
|
内网的以太口地址根据实际情况来配置 |
||
[Router] |
interface Ethernet0 |
|
[Router-Ethernet0] |
ip address 10.0.0.1 255.255.255.0 |
|
[Router-Ethernet0] |
! |
|
[Router-Serial0] |
interface Bri0 |
|
[Router-Bri0] |
link-protocol ppp |
|
[Router-Bri0] |
ppp mp |
使能128K两B拨号 |
[Router-Bri0] |
ppp pap local-user 16900 password simple 16900 |
|
[Router-Bri0] |
ip address ppp-negotiate |
|
[Router-Bri0] |
dialer enable-circular |
ISDN拔号不用配置dialer enable-legacy,如果是灵活DDR拔号,还应配置undo dialer enable-legacy |
[Router-Bri0] |
dialer-group 1 |
|
[Router-Bri0] |
dialer number 16900 |
|
[Router-Bri0] |
nat outbound 2000 interface |
在出接口上进行NAT转换 |
|
! |
|
[Router] |
ip route-static 0.0.0.0 0.0.0.0 bri 0 preference 60 |
使用isdn-bri拨号 |
[Router] |
! |
|
[Router] |
return |
|
4.1.4 一个以太口也做nat转换
【Router】
当前路由器提示视图 |
依次输入的配置命令,重要的命令红色突出显示 |
简单说明 |
|
! |
适用版本vrp1.74及1.44 |
[Router] |
acl 3000 match-order auto |
|
[Router-acl3000] |
rule normal deny ip source 10.0.0.0 0.0.0.255 destination 10.0.0.1 0.0.0.0 |
|
[Router-acl3000] |
rule normal permit source 10.0.0.0 0.0.0.255 |
|
[Router-acl3000] |
rule deny ip source any |
|
|
! |
|
[Router] |
interface Ethernet0 |
|
[Router-Ethernet0] |
ip address 202.1.1.1 255.255.255.0 |
|
[Router-Ethernet0] |
ip address 10.0.0.1 255.255.255.0 sub |
|
[Router-Ethernet0] |
nat outbound 3000 interface |
|
|
! |
|
[Router] |
ip route-static 0.0.0.0 0.0.0.0 202.1.1.2 preference 60 |
|
[Router] |
! |
|
[Router] |
return |
|
说明:上例不推荐使用。
4.1.5 对外提供ftp,www等服务
以www服务为例,除了3.1.1和3.1.2的配置,公网接口需要增加如下配置:
[Router-Ethernet1]nat server global 202.1.1.2 www inside 10.0.0.2 www tcp
注意:如果需要其他用户可以ping通内部对外提供服务的服务器,必须增加如下配置:
[Router-Ethernet1]nat server global 202.1.1.2 any inside 10.0.0.2 any icmp
注意:内部用户不能使用公网地址来访问内部服务器,必须使用内网地址访问.
如上例子:10.0.0.0/24网段的用户,不能访问http://202.1.1.2,而只能访问http://10.0.0.2