路由器连接公网实现子网设备通信 2021-03-31

 

                                                                                                                     

                                                                                                                    测试目的:使得PC1连通Internet

 

设备端口地址
Interneteth0/0202.100.1.2
R1eth0/0202.100.1.1
 eth0/1192.168.1.1
PC1eth0/0192.168.1.100
Internet的敲入命令:



Router>enable   
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname Internet
Internet(config)#int e0/0
Internet(config-if)#ip address 202.100.1.2 255.255.255.252     //配置Internet的eth0/0地址
Internet(config-if)#no shu
Internet(config-if)#no shutdown 
Internet(config-if)#
Internet#
*Mar 31 18:47:54.787: %SYS-5-CONFIG_I: Configured from console by console
Internet#
*Mar 31 18:47:54.826: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
*Mar 31 18:47:55.829: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
Internet#ping 202.100.1.1                                     //ping通R1(R1的eth0/0)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 202.100.1.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/3 ms


Internet#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Internet(config)#ip route 192.168.1.0 255.255.255.0 e0/0 202.100.1.1
      //全局配置模式下,配置默认路由,即允许接收从202.100.1.1传输过来的192.168.1段的数据包
Internet(config)#
Internet#
R1的敲入命令:



Router>enable
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname R1
R1(config)#int e0/0
R1(config-if)#ip add
R1(config-if)#ip address 202.100.1.1 255.255.255.252       //配置R1的eth0/0地址
R1(config-if)#du
R1(config-if)#duplex f
R1(config-if)#duplex full                                  //双工
R1(config-if)#no shu
R1(config-if)#no shutdown                                  //开启端口
R1(config-if)#
R1#
*Mar 31 18:45:43.184: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
R1#wr
R1#write                                                   //保存设置
Building configuration...
[OK]
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int e0/0
R1(config-if)#exit
R1(config)#ip route 0.0.0.0 0.0.0.0 e0/0 202.100.1.2       //配置R1的eth0/0指向Internet的 
                                                             默认路由    
R1#
R1#enable 
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int
R1(config)#interface e0/1
R1(config-if)#ip add
R1(config-if)#ip address 192.168.1.1 255.255.255.0        //配置R1的eth0/1地址
R1(config-if)#du         
R1(config-if)#duplex f                                    //开启R1的eth0/1的双工模式
R1(config-if)#duplex full 
R1(config-if)#no shu
R1(config-if)#no shutdown                                 //开启端口
R1(config-if)#
R1#show ip
*Mar 31 18:53:08.992: %SYS-5-CONFIG_I: Configured from console by console
R1#show ip int
R1#show ip interface br
R1#show ip interface brief                                //查看设备的端口状态
Interface                  IP-Address      OK? Method Status                Protocol
Ethernet0/0                202.100.1.1     YES manual up                    up      
Ethernet0/1                192.168.1.1     YES manual administratively down down    
Ethernet0/2                unassigned      YES unset  administratively down down    
Ethernet0/3                unassigned      YES unset  administratively down down    
Serial1/0                  unassigned      YES unset  administratively down down    
Serial1/1                  unassigned      YES unset  administratively down down    
Serial1/2                  unassigned      YES unset  administratively down down    
Serial1/3                  unassigned      YES unset  administratively down down    
R1#
*Mar 31 18:53:24.346: %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered on Ethernet0/0 (not half duplex), with Internet Ethernet0/0 (half duplex).
PC1的敲入代码:


PC1(config)#int  
PC1(config)#interface e0/0
PC1(config-if)#ip adde  
PC1(config-if)#ip address 192.168.1.100 255.255.255.0     //配置PC1的地址
PC1(config-if)#du
PC1(config-if)#duplex fu
PC1(config-if)#duplex full 
PC1(config-if)#no shu
PC1(config-if)#no shutdown                        //ctrl+c退回到特权模式
PC1#show ip int
PC1#show ip interface br
PC1#show ip interface brief 
Interface                  IP-Address      OK? Method Status                Protocol
Ethernet0/0                192.168.1.100   YES manual administratively down down    
Ethernet0/1                unassigned      YES unset  administratively down down    
Ethernet0/2                unassigned      YES unset  administratively down down    
Ethernet0/3                unassigned      YES unset  administratively down down    

PC1#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 2/3/6 ms
PC1#conf t          
Enter configuration commands, one per line.  End with CNTL/Z.
PC1(config)#no ip rou
PC1(config)#no ip routing
PC1(config)#ip de
PC1(config)#ip default-g
PC1(config)#ip default-gateway 192.168.1.1       //给PC1设定了默认路由指向R1的eth0/0
PC1#show ip route 
Default gateway is 192.168.1.1

Host               Gateway           Last Use    Total Uses  Interface
ICMP redirect cache is empty



PC1#ping 202.100.1.1                             //R1在eth0/1上指定了默认路由到eth0/0上
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 202.100.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/203/1007 ms
PC1#ping 202.100.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 202.100.1.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)         



PC1#ping 202.100.1.2                           //此时已在Internet上配置了由R1的eth0/0指向 
                                                 的192.168.1.0段的默认路由
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 202.100.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/6 ms

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值