计算机网络实验,NAT实验

  • 实验拓扑图

 

  • 实验设备

实验使用四台PC,三个router,两个switch

  • 实验内容和要求

根据上面面的拓扑图,自行完成拓扑结构的连接,IP 地址分配,

最后,实现全网能相互 PING 通。

  • 实验步骤(文字说明+运行截图)

先接好拓扑图,

然后进行基础配置,先以PC0为例,如图进行配置IP地址:

 

再对交换机进行基础配置,以S0为例如图:

 

操作如下:

Switch#conf t

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

Switch(config)#hostname S0

S0(config)#enable password 123456

S0(config)#no ip domain-lookup

S0(config)#line console 0

S0(config-line)#no exec-timeout

S0(config-line)#logging synchronous

S0(config-line)#exit

S0(config)#line vty 0 4

S0(config-line)#pas 123456

S0(config-line)#login

S0(config-line)#exit

S0(config)#int vlan 1

S0(config-if)#ip add 192.168.1.8 255.255.255.0

S0(config-if)#no shutdown

交换机1也是类似操作。

再对路由器进行基础配置,以R0为例如图所示:

 

Router>enable //或者缩写 en

Router#configure terminal //或者 conf t

Router(config)#hostname R0 //重命名

R0(config)#enable password 123456 //设置特权模式密码 ,后面 telnet 登录

时,由命令模式切换到特权模式时需要输入

R0(config)#no ip domain-lookup //关闭域名查找

R0(config)#line console 0 //指定控制台

R0(config-line)#no exec-timeout //关闭执行会话时间

R0(config-line)#logging synchronous //设置输入同步

然后对路由器根据拓扑图进行接口IP配置,以R0为例如图所示:

操作码如下:

R0(config)#int f0/0

R0(config-if)#ip add 192.168.1.5 255.255.255.0

R0(config-if)#no shutdown

R0(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

R0(config-if)#exit

R0(config)#int f0/1

R0(config-if)#ip add 162.168.1.254 255.255.255.0

R0(config-if)#no shutdown

R0(config-if)#

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

R0(config-if)#exit

R0(config)#int s0/0/0

R0(config-if)#ip add 172.168.1.1 255.255.255.0

R0(config-if)#no shutdown

其他路由器R1,R2也是类似配置。

配置R1的loopback口,如图所示:

R1(config)#interface loopback 1

R1(config-if)#

%LINK-5-CHANGED: Interface Loopback1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to up

R1(config-if)#ip add 2.2.2.2 255.255.255.0

R1(config-if)#exit

对R0配置NAT 内部接口:

 

操作如下:

R0(config)#int s0/0/0    配置NAT 内部接口

R0(config-if)#ip nat outside

R0(config-if)#exit

R0(config)#router rip 配置NAT 外部接口

R0(config-router)#version 2

R0(config-router)#no auto-summary

R0(config-router)#network 172.168.1.0

R0(config-router)#network 192.168.1.0

R0(config-router)#network 162.168.1.0

R0(config-router)#network 2.2.2.0

R0(config-router)#network 182.168.1.0

R0(config-router)#network 4.4.4.0

R0(config-router)#exit

在配置路由器R1 :

R1(config)#router rip

R1(config-router)#version 2

R1(config-router)#network 172.168.1.0

R1(config-router)#network 192.168.1.0

R1(config-router)#network 4.4.4.0

R1(config-router)#network 162.168.1.0

R1(config-router)#network 182.168.1.0

R1(config-router)#network 2.2.2.0

再对R2进行配置nat接口和rip配置,如图所示:

 操作如下:

R2(config)#int f0/0

R2(config-if)#ip nat outside

R2(config-if)#router rip

R2(config-router)#version 2

R2(config-router)#network 182.168.1.0

R2(config-router)#network 4.4.4.0

R2(config-router)#network 192.168.1.0

R2(config-router)#network 172.168.1.0

R2(config-router)#network 162.168.1.0

R2(config-router)#exit

然后再配置路由器R0 提供NAT 服务,如图所示:

 

R0(config)#ip nat pool NAT 172.168.1.3 172.168.1.100 netmask 255.255.255.0

R0(config)#ip nat inside source list 1 pool NAT

R0(config)#access-list 1 permit 192.168.1.0 0.0.0.255

R0(config)#access-list 1 permit 162.168.1.0 0.0.0.255

R0(config)#int f0/0

R0(config-if)#ip nat inside

R0(config-if)#int f0/1

R0(config-if)#ip nat inside

R0(config-if)#int s0/0/0

R0(config-if)#ip nat outside

R0(config-if)#

然后再配置路由器R2 提供NAT 服务,如图所示:

 R2(config)#ip nat pool NAT 182.168.1.3 182.168.1.100 netmask 255.255.255.0

R2(config)#ip nat inside source list 1 pool NAT

R2(config)#access-list 1 permit 4.4.4.0 0.0.0.255

R2(config)#int f0/0

R2(config-if)#ip nat inside

R2(config-if)#int f0/1

R2(config-if)#ip nat outside

R2(config-if)#

然后进行ping操作,以PC4为例:

 PC4可以ping通PC1,PC0,PC2,PC3以及2.2.2.2这个IP地址。

PC2也可以ping通PC0,PC1,以及2.2.2.2这个IP地址,如图:

 

 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿哲-哲学的哲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值