toc hostname 默认路由 out png mina 实验目的 自动 bug
今天初次接触到 NAT,了解不是特别全面,在学习的同时我也查阅了一些对应资料,接下来我就为大家简单说一下我对 NAT 的理解及应用,有什么欠缺请大家及时指正.
NAT 英文全称是 "Network Address Translation",中文意思是 "网络地址转换", 它是一种把内部私有网络地址解释为合法网络 IP 地址的技术,所以在一定程度可以解决 ip 地址不够用的问题.同时 NAT 分为三种类型:静态 NAT,动态 NAT,网络地址端口转换 NAPT,今天我主要通过一个小实验为大家讲解一下 NAT 三种类型中的静态 NAT.
实验名称:配置静态 NAT 实现内外网通信
实验拓扑:
如图所示,现有一台 PC 机,想要访问到 ISP 的服务,该如何操做呢?
实验目的:使内网 PC 机可以访问到 ISP 服务
实验步骤:
配置内外网设备的 IP 地址
PC 机:
配置网关设备上的默认路由
Gw:
Router>en
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname gw
gw(config)#interface fastEthernet 0/0
gw(config-if)#no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
ip ad
gw(config-if)#ip address 192.168.10.254 255.255.255.0
gw(config-if)#exit
gw(config)#interface fastEthernet 0/1
gw(config-if)#no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
gw(config-if)#ip address 100.1.1.1 255.255.255.0
gw(config-if)#exit
gw(config)#
SLP-1:
Router>EN
Router#CONFigure
Configuring from terminal, memory, or network [terminal]
Enter configuration commands, one per line. End with CNTL/Z.
Router SLP-1 (config)#hostname SLP-1
SLP-1 (config)#interface fastEthernet 0/0
SLP-1 (config-if)#no shutdown
SLP-1 (config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
SLP-1 (config-if)#ip address 100.1.1.2 255.255.255.0
SLP-1 (config-if)#exit
SLP-1 (config)#interface fastEthernet 0/1
SLP-1 (config-if)#no shutdown
SLP-1 (config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
SLP-1 (config-if)#ip address 200.1.1.1 255.255.255.0
SLP-1 (config)#exit
SLP-1#
SLP-2:
Router>EN
Router#CONFigure
Configuring from terminal, memory, or network [terminal]
Enter configuration commands, one per line. End with CNTL/Z.
Router SLP-1 (config)#hostname SLP-2
SLP-2 (config)#interface fastEthernet 0/0
SLP-2 (config-if)#no shutdown
SLP-2 (config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
SLP-2 (config-if)#ip address 200.1.1.2 255.255.255.0
SLP-2 (config-if)#exit
配置 ISP 边的网络(启用 IGP-RIP)
gw(config)#ip route 0.0.0.0 0.0.0.0 100.1.1.2
gw(config)#exit
gw#
%SYS-5-CONFIG_I: Configured from console by console
在网关设备上配置 NAT 边界
SLP-1:
SLP-1(config)#router rip \ 开启 rip
SLP-1(config-router)#version 2 \ 选择 rip 版本 2
SLP-1(config-router)#no auto-summary \ 关闭自动汇总
SLP-1(config-router)#passive-interface fastEthernet 0/0
SLP-1(config-router)#network 100.1.1.0
SLP-1(config-router)#network 200.1.1.0
SLP-1(config-router)#exit
SLP-1(config)#
SLP-2:
SLP-2(config)#router rip \ 开启 rip
SLP-2(config-router)#version 2 \ 选择 rip 版本 2
SLP-2(config-router)#no auto-summary \ 关闭自动汇总
SLP-2(config-router)#network 200.1.1.0
SLP-2(config-router)#exit
SLP-2(config)#
配置 NAT 转换条目
Gw:
gw(config)#interface fastEthernet 0/0
gw(config-if)#ip nat inside \ 标记此为 NAT 的内部端口
gw(config-if)#exit
gw(config)#interface fastEthernet 0/1
gw(config-if)#ip nat outside \ 标记此为 NAT 的外部端口
gw(config-if)#exit
gw(config)#
验证,测试,保存
Gw:
gw(config)#ip nat inside source static 192.168.10.1 100.1.1.1
gw(config)#exit
gw#
Gw: show ip nat translation:
debug ip nat :
PC-1:
ping 200.1.1.2
Gw:
根据此图可以看出,NAT 将一个私有地址转换为公有地址,从而实现了访问的服务.
今天就暂时先简单说这些,关于 NAT 的其他类型会在后面为大家呈现,请大家多多关注!!!!!
配置静态 NAT 实现内外网通信
来源: http://www.bubuko.com/infodetail-2459459.html