锐捷路由器端口映射设置-如何设置路由器映射端口

小编:迷魂冰 更新时间:2022-08-03

网吧里有服务器采用私网的IP地址,提供WWW、FTP、E-mail等服务,现在想让公网上的电脑也能够访问这台服务器,配置如下:

由于路由器的WAN口采用的是公网的IP地址,如果需要局域网的服务器要提供给公网的电脑访问的话,那么采用端口映射的方式,可以实现。由于每种服务的端口都是不一样的(WWW服务:80端口;FTP服务:21端口),因此将服务器的各种端口与映射到公网的地址相应的端口上,这样公网上的电脑访问路由器的WAN口的地址,即可访问到局域网的服务器,下面一个例子进行说明:


锐捷路由器端口映射设置-如何设置路由器映射端口


为了实现这些功能,需要配置NAT静态映射功能。快速配置功能中不包含该功能的设置,因此需要在第一次启动路由器后使用“no”放弃快速配置然后进入特权用户模式进行高级设置:

!进入特权用户层

Red-Giant>enable

!进入全局配置层

Red-Giant#config terminal Enter configuration commands, one per line. End with CNTL/Z.

!进入WAN口配置层

Red-Giant(config)#interface fastethernet 0

!配置WAN口地址

Red-Giant(config-if)#ip address 218.5.19.2 255.255.255.0

!设置WAN口为共享连接的Internet接入口

Red-Giant(config-if)#ip nat outside

!启用WAN口

Red-Giant(config-if)#no shut

!返回普通用户层

Red-Giant(config-if)#end

Red-Giant#

!这些是系统提示信息,系统提示WAN口链路处于UP状态(可通讯状态).

%UPDOWN: Line protocol on Interface FastEthernet0, changed state to up %UPDOWN: Interface FastEthernet0, changed state to up Red-Giant#config terminal Enter configuration commands, one per line. End with CNTL/Z.

!进入LAN口配置层

Red-Giant(config)#interface fastethernet 1

!配置LAN口地址

Red-Giant(config-if)#ip address 192.168.0.1 255.255.255.0

!设置LAN口为共享连接的Intranet接入口

Red-Giant(config-if)#ip nat inside

!启用LAN口

Red-Giant(config-if)#no shut

Red-Giant(config-if)#end

Red-Giant#

%UPDOWN: Line protocol on Interface FastEthernet1, changed state to up

%UPDOWN: Interface FastEthernet1, changed state to up

Red-Giant#config terminal

Enter configuration commands, one per line. End with CNTL/Z.

!配置默认路由以访问Internet

Red-Giant(config)#ip route 0.0.0.0 0.0.0.0 fastethernet 0 218.5.19.1

!配置NAT快转优化

Red-Giant(config)#ip nat optimize

!配置NAT应用的访问列表

Red-Giant(config)#access-list 1 permit any

!配置连接共享规则

Red-Giant(config)#ip nat inside source list 1 interface fastethernet 0

!配置FTP服务器的静态映射 Red-Giant(config)#ip nat inside source static tcp 192.168.0.2 20 218.5.19.2 20

Red-Giant(config)#ip nat inside source static tcp 192.168.0.2 21 218.5.19.2 21

!配置WEB服务器的静态映射

Red-Giant(config)#ip nat inside source static tcp 192.168.0.3 80 218.5.19.2 80

!配置EMAIL服务器的静态映射

Red-Giant(config)#ip nat inside source static tcp 192.168.0.4 25 218.5.19.2 25

Red-Giant(config)#ip nat inside source static tcp 192.168.0.4 110 218.5.19.2 110

Red-Giant(config)#end

Red-Giant#

Red-Giant#config terminal

Enter configuration commands, one per line. End with CNTL/Z.

!配置远程用户Telnet访问口令

Red-Giant(config)#line vty 0 4

Red-Giant(config-line)#password remoteuser

Red-Giant(config-line)#end

Red-Giant#

Red-Giant#config terminal

Enter configuration commands, one per line. End with CNTL/Z.

Red-Giant(config)#enable secret private

!配置路由器名称

Red-Giant(config)#host NBR

NBR(config)#end

NBR#

!保存配置

NBR#write

Building configuration...

[OK]

NBR#

通过以上配置,公网上的电脑即可通过访问WAN口IP地址来达到访问局域网服务器的目的