路由器和交换机基本配置命令(一)
大家好,我是Alex。近期几篇文章分享大家一些有关CISCO的基本配置命令...
[sourcecode language="plain"]
(config)#interface vlan 1 (进入VLAN 1 接口)
(config-if)#ip address [IP地址] [掩码] (设置IP地址)
(config-if)#no shutdown (打开该接口)
(config-if)#exit (返回到全局模式)
(config)#
[/sourcecode]
例:
[sourcecode language="plain"]
(config)#interface vlan 1
(config-if)# ipaddress 192.168.1.253 255.255.255.0
(config-if)# noshutdown
(config-if)#exit
[/sourcecode]
Router设置IP地址
[sourcecode language="plain"]
(config)#interface [接口名] (进入接口)
(config-if)#ip address [IP地址] [掩码] (设置IP地址)
(config-if)#no shutdown (打开该接口)
(config-if)#exit (返回到全局模式)
(config)#
[/sourcecode]
例:
[sourcecode language="plain"]
(config)#interface f0/0
(config-if)# ipaddress 192.168.1.254 255.255.255.0
(config-if)# noshutdown
(config-if)#exit
(config)#
[/sourcecode]
定义从用户模式进入特权模式的口令:
[sourcecode language="plain"]
(config)#enable password [口令] (设置明文口令)
(config)#enable secret [口令] (设置密文口令)
[/sourcecode]
例:
[sourcecode language="plain"]
(config)#enablepassword 12345
(config)#enablesecret cisco
[/sourcecode]
定义Console接口的口令
[sourcecode language="plain"]
(config)#line con 0 (进入控制接口)
(config-line)#password [口令] (设置口令)
(config-line)#login (设置口令生效)
(config-line)#exit (返回到特权模式)
(config)#
[/sourcecode]
例:
[sourcecode language="plain"]
User AccessVerification
Password:___________ (Console接口的口令)
s1>enable
Password:___________ (从用户模式进入特权模式的口令)
s1#
[/sourcecode]
定义Telnet用户接口的口令
[sourcecode language="plain"]
(config)# line vty 0 4 (进入vty接口)
(config-line)# password [口令] (设置口令)
(config-line)#login (设置口令生效)
(config-line)# exit (返回到特权模式)
(config)#
[/sourcecode]
[04] 是指最多允许5位用户对设备进行Telnet登陆)
给设备定义时间、日期、年份:
[sourcecode language="plain"]
(config)# clock timezone [时区名称] [时区范围] (设置时区)
#clock set [时间] [日期] [月份(英文表示)] [年份] (设置时间)
[/sourcecode]
例:
[sourcecode language="plain"]
(config)# clocktimezone beijing+8
(config)# exit
# clock set19:30:00 24 may 2006
#
#show clock
19:31:17.059beijing Wed May24 2006
[/sourcecode]
[sourcecode language="plain"]
(config)# bannermotd #
Enter TEXTmessage. End with the character '#'.
********************
* *
* xxxx *
* *
********************
#
(config)#
[/sourcecode]
[sourcecode language="plain"]
#show controller serial 0/0
...............
......................V.35DTE cable
...............
#show controller serial 0/0
...............
......................V.35DCE cable
...............
[/sourcecode]
如果串行接口连接的是DCE线缆,则需要定义时钟
[sourcecode language="plain"]
>enable
#conf t
(config)#interface [串行接口编号] (进入串行接口)
(config-if)#clock rate 64000 (定义时钟频率)
(config-if)#exit (返回到全局模式)
(config)#
[/sourcecode]
例:
[sourcecode language="plain"]
(config)#interface serial 0/0
(config-if)#clock rate 64000
(config-if)#exit
(config)#
[/sourcecode]
[sourcecode language="plain"]
#erasestartup-config
Erasingthe nvram filesystem will remove all files! Continue? [confirm]
[OK]
Eraseof nvram: complete
#
#reload
[/sourcecode]
[sourcecode language="plain"]
Switch#conf t
(config)#ip host pc1 192.168.1.249
(config)#exit
[/sourcecode]