如果大家住集体宿舍,看看自己的IP地址是不是192.168.*.*?一般情况下我们只是老实的通过网络室路由器或服务器进行NAT地址转换畅游Internet的。如果想在自己宿舍组建一个小网吧,岂不妙哉?(实验可以做,如果真的这样在实际中做了,小心领导雷哦~)
今天,我们就来在自己的宿舍做做网管们在空调机房干的事情吧~
拓扑图:
在四个路由器上的配置信息(大家主要看R0和R1吧,因为这个实验主要还是PAT的应用。同时路由器R1与公网相连的接口也通过DHCP得到IP地址的。):
路由器R0上的配置:
R0#sh run
Building configuration...
路由器R0上的配置:
R0#sh run
Building configuration...
Current configuration : 645 bytes
!
version 12.4
no service password-encryption
!
hostname R0
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
ip address dhcp (自动获取IP)
ip nat outside
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.2.254 255.255.255.0
ip nat inside
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip nat inside source list 2 interface FastEthernet0/0 overload
ip classless
ip route 0.0.0.0 0.0.0.0 FastEthernet0/0
!
!
access-list 2 permit 192.168.2.0 0.0.0.255
!
!
ip dhcp pool tiger
network 192.168.2.0 255.255.255.0
default-router 192.168.2.254
dns-server 200.1.3.1
!
line con 0
line vty 0 4
login
!
!
end
!
version 12.4
no service password-encryption
!
hostname R0
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
ip address dhcp (自动获取IP)
ip nat outside
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.2.254 255.255.255.0
ip nat inside
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip nat inside source list 2 interface FastEthernet0/0 overload
ip classless
ip route 0.0.0.0 0.0.0.0 FastEthernet0/0
!
!
access-list 2 permit 192.168.2.0 0.0.0.255
!
!
ip dhcp pool tiger
network 192.168.2.0 255.255.255.0
default-router 192.168.2.254
dns-server 200.1.3.1
!
line con 0
line vty 0 4
login
!
!
end
路由器R1上的配置:
R1#sh run
Building configuration...
R1#sh run
Building configuration...
Current configuration : 661 bytes
!
version 12.4
no service password-encryption
!
hostname R1
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
ip address 200.1.1.2 255.255.255.0
ip nat outside
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.1.254 255.255.255.0
ip nat inside
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip nat inside source list 1 interface FastEthernet0/0 overload
ip classless
ip route 0.0.0.0 0.0.0.0 FastEthernet0/0
!
!
access-list 1 permit 192.168.1.0 0.0.0.255
!
!
ip dhcp pool R1
network 192.168.1.0 255.255.255.0
default-router 192.168.1.254
dns-server 200.1.3.1
!
line con 0
line vty 0 4
login
!
!
end
!
version 12.4
no service password-encryption
!
hostname R1
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
ip address 200.1.1.2 255.255.255.0
ip nat outside
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.1.254 255.255.255.0
ip nat inside
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip nat inside source list 1 interface FastEthernet0/0 overload
ip classless
ip route 0.0.0.0 0.0.0.0 FastEthernet0/0
!
!
access-list 1 permit 192.168.1.0 0.0.0.255
!
!
ip dhcp pool R1
network 192.168.1.0 255.255.255.0
default-router 192.168.1.254
dns-server 200.1.3.1
!
line con 0
line vty 0 4
login
!
!
end
路由器R2上的设置(动态路由RIPv2的建立,及建立一个公网的DHCP地址池,供R1获取IP):
R2#sh run
Building configuration...
R2#sh run
Building configuration...
Current configuration : 454 bytes
!
version 12.4
no service password-encryption
!
hostname R2
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
ip address 200.1.2.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 200.1.1.1 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
version 2
network 200.1.1.0
network 200.1.2.0
no auto-summary
!
ip classless
!
!
line con 0
line vty 0 4
login
!
!
end
!
version 12.4
no service password-encryption
!
hostname R2
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
ip address 200.1.2.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 200.1.1.1 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
version 2
network 200.1.1.0
network 200.1.2.0
no auto-summary
!
ip classless
!
!
line con 0
line vty 0 4
login
!
!
end
路由器R3的配置(就当复习RIPv2吧~):
R3#sh run
Building configuration...
R3#sh run
Building configuration...
Current configuration : 456 bytes
!
version 12.4
no service password-encryption
!
hostname R3
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
ip address 200.1.2.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 200.1.3.254 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
version 2
network 200.1.2.0
network 200.1.3.0
no auto-summary
!
ip classless
!
!
line con 0
line vty 0 4
login
!
!
end
服务器在这个实验中充当着HTTP服务器和DNS服务器的双重任务。
看一下在DNS上的配置吧:
!
version 12.4
no service password-encryption
!
hostname R3
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
ip address 200.1.2.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 200.1.3.254 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
version 2
network 200.1.2.0
network 200.1.3.0
no auto-summary
!
ip classless
!
!
line con 0
line vty 0 4
login
!
!
end
服务器在这个实验中充当着HTTP服务器和DNS服务器的双重任务。
看一下在DNS上的配置吧:
实验中的主机都是通过DHCP来获得自己的IP地址、网关地址、DNS服务器地址的,看看吧~
在原来局域网中主机的IP:
在原来局域网中主机的IP:
在宿舍局域网中的主机IP:
在局域网192.168.2.0/24找一台主机PC3打开
[url]www.cisco.com[/url]的网页:
成功!(从此以后你就是宿舍网吧的老板了!)
现在在路由器R1和R0使用命令sh ip nat translation来看看PAT的过程吧~
R1上的结果:
R1# sh ip nat translations
Pro Inside global Inside local Outside local Outside global
udp 200.1.1.2:1025 192.168.1.1:1025 200.1.3.1:53 200.1.3.1:53
udp 200.1.1.2:1026 192.168.1.1:1026 200.1.3.1:53 200.1.3.1:53
udp 200.1.1.2:1027 192.168.1.1:1027 200.1.3.1:53 200.1.3.1:53
udp 200.1.1.2:1028 192.168.1.1:1028 200.1.3.1:53 200.1.3.1:53
udp 200.1.1.2:1035 192.168.1.2:1035 200.1.3.1:53 200.1.3.1:53
tcp 200.1.1.2:1024 192.168.1.1:1024 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1024 192.168.1.1:1025 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1027 192.168.1.1:1026 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1027 192.168.1.1:1027 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1029 192.168.1.1:1028 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1029 192.168.1.1:1029 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1031 192.168.1.1:1030 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1031 192.168.1.1:1031 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1030 192.168.1.2:1025 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1025 192.168.1.4:1025 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1026 192.168.1.4:1026 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1028 192.168.1.4:1027 200.1.3.1:80 200.1.3.1:80
R0上的结果:
R0# sh ip nat translations
Pro Inside global Inside local Outside local Outside global
udp 192.168.1.1:1025 192.168.2.1:1025 200.1.3.1:53 200.1.3.1:53
udp 192.168.1.1:1026 192.168.2.1:1026 200.1.3.1:53 200.1.3.1:53
udp 192.168.1.1:1027 192.168.2.1:1027 200.1.3.1:53 200.1.3.1:53
udp 192.168.1.1:1028 192.168.2.1:1028 200.1.3.1:53 200.1.3.1:53
tcp 192.168.1.1:1024 192.168.2.1:1025 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1029 192.168.2.1:1026 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1030 192.168.2.1:1027 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1031 192.168.2.1:1028 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1025 192.168.2.3:1025 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1026 192.168.2.3:1026 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1027 192.168.2.3:1027 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1028 192.168.2.3:1028 200.1.3.1:80 200.1.3.1:80
R1上的结果:
R1# sh ip nat translations
Pro Inside global Inside local Outside local Outside global
udp 200.1.1.2:1025 192.168.1.1:1025 200.1.3.1:53 200.1.3.1:53
udp 200.1.1.2:1026 192.168.1.1:1026 200.1.3.1:53 200.1.3.1:53
udp 200.1.1.2:1027 192.168.1.1:1027 200.1.3.1:53 200.1.3.1:53
udp 200.1.1.2:1028 192.168.1.1:1028 200.1.3.1:53 200.1.3.1:53
udp 200.1.1.2:1035 192.168.1.2:1035 200.1.3.1:53 200.1.3.1:53
tcp 200.1.1.2:1024 192.168.1.1:1024 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1024 192.168.1.1:1025 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1027 192.168.1.1:1026 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1027 192.168.1.1:1027 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1029 192.168.1.1:1028 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1029 192.168.1.1:1029 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1031 192.168.1.1:1030 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1031 192.168.1.1:1031 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1030 192.168.1.2:1025 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1025 192.168.1.4:1025 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1026 192.168.1.4:1026 200.1.3.1:80 200.1.3.1:80
tcp 200.1.1.2:1028 192.168.1.4:1027 200.1.3.1:80 200.1.3.1:80
R0上的结果:
R0# sh ip nat translations
Pro Inside global Inside local Outside local Outside global
udp 192.168.1.1:1025 192.168.2.1:1025 200.1.3.1:53 200.1.3.1:53
udp 192.168.1.1:1026 192.168.2.1:1026 200.1.3.1:53 200.1.3.1:53
udp 192.168.1.1:1027 192.168.2.1:1027 200.1.3.1:53 200.1.3.1:53
udp 192.168.1.1:1028 192.168.2.1:1028 200.1.3.1:53 200.1.3.1:53
tcp 192.168.1.1:1024 192.168.2.1:1025 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1029 192.168.2.1:1026 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1030 192.168.2.1:1027 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1031 192.168.2.1:1028 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1025 192.168.2.3:1025 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1026 192.168.2.3:1026 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1027 192.168.2.3:1027 200.1.3.1:80 200.1.3.1:80
tcp 192.168.1.1:1028 192.168.2.3:1028 200.1.3.1:80 200.1.3.1:80
如果偶尔网页打不开就重新获取一下IP吧~
其他的乐趣大家慢慢挖掘吧~玩的开心!
其他的乐趣大家慢慢挖掘吧~玩的开心!
本文转自 tiger506 51CTO博客,原文链接:http://blog.51cto.com/tiger506/113984,如需转载请自行联系原作者