初次学习路由器的配置,使用的是Packet Tracer 5.0的模拟器。
1、 设置路由器特权模式密码,若不设将telnet无法进入特权模式;
Router1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#enable secret 123456
Router1(config)#^Z
%SYS-5-CONFIG_I: Configured from console by console
2、 设置路由器的Loopback地址和路由
Router1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#int loopback 0
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router1(config-if)#ip addr 10.1.1.1 255.255.255.0//设置路由器登陆的地址为10.1.1.1,子网掩码255.255.255.0
Router1(config-if)#no shut
Router1(config-if)#no shutdown
Router1(config-if)#end
%SYS-5-CONFIG_I: Configured from console by console
Router1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#router rip //配置rip路由协议
Router1(config-router)#network 10.1.1.0
Router1(config-router)#end
%SYS-5-CONFIG_I: Configured from console by console
3、上面设置完以后,可通过show ip route看到当前的路由信息。
Router1#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O -OSPF,IA- OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet4/0
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, FastEthernet5/0
R 23.0.0.0/8 [120/1] via 13.1.1.3, 00:00:26, FastEthernet5/0
[120/1] via 12.1.1.2, 00:00:06, FastEthernet4/0
R 33.0.0.0/8 [120/1] via 13.1.1.3, 00:00:26, FastEthernet5/0
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.1.0 is directly connected, FastEthernet0/0
R 220.1.1.0/24 [120/1] via 12.1.1.2, 00:00:06, FastEthernet4/0
4、设置路由器的访问链表和vty登陆密码;
Router1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#access-list 1 permit any //允许任何主机访问该路由器
Router1(config)#line vty 0 4 //路由器上有5个VTY口,分别0、1、2、3、4,如果想同时配置这5口,就line vty 0 4
Router1(config-line)#login
% Login disabled on line 66, until 'password' is set
% Login disabled on line 67, until 'password' is set
% Login disabled on line 68, until 'password' is set
% Login disabled on line 69, until 'password' is set
% Login disabled on line 70, until 'password' is set
Router1(config-line)#password 123456
Router1(config-line)#access-class 1 in
Router1(config-line)#^Z
%SYS-5-CONFIG_I: Configured from console by console
5、大功告成,通过telnet可以进行测试。
PC>telnet 10.1.1.1
Trying 10.1.1.1 ...
User Access Verification
Password:
Router1>en
Password:
Router1#