路由器和交换机基本配置命令(一)

华盟原创文章投稿奖励计划

大家好,我是Alex。近期几篇文章分享大家一些有关CISCO的基本配置命令...

Hostname姓名            改系统名
2900系列以上交换机设置IP地址

[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]

(config)#banner motd  #   (定义启动显示文本)
例:

[sourcecode language="plain"]
(config)# bannermotd #
Enter TEXTmessage. End with the character '#'.
********************
* *
* xxxx *
* *
********************
#
(config)#
[/sourcecode]

Router上的指令
#show controller [串行接口编号]
(查看该接口连接的是DTE线缆还是DCE线缆)
例:

[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]

#show interface [接口号]
Serial0/0is up, line protocol is up
       (代表该接口可以正常使用)
Serial0/0is up, line protocol is down
       (两端协议不匹配)   HDLC---------- PPP
       (串行DCE接口没有设置时钟)
Serial0/0is down, line protocol is down
       (线缆故障)
       (对端设备接口没有打开,或对端设备关闭电源)
Serial0/0 is administratively down, line protocolis down
       (人为将接口关闭,通过指令可以打开)
#show running-config                   (查看正在运行的配置文件)
#show startup-config                    (查看启动配置文件)
# erase startup-config                   (清空配置文件)
#reload                                            (重新启动)
例:

[sourcecode language="plain"]
#erasestartup-config
Erasingthe nvram filesystem will remove all files! Continue? [confirm]
[OK]
Eraseof nvram: complete
#
#reload
[/sourcecode]

(config)#no ip domain-lookup                                        (关闭域名解析)
(config)#ip host [主机名] [主机IP地址]                              (建立静态映射)

[sourcecode language="plain"]
Switch#conf t
(config)#ip host pc1 192.168.1.249
(config)#exit
[/sourcecode]

MAC地址表
初始为空,当有数据帧到达时:首先,将数据帧中的源MAC地址与接收该数据帧的端口建立对应的关系,并将这种关系放置的MAC地址表中。其次,判断数据帧中的目标MAC地址在交换机的MAC地址表中是否存在与端口的对应关系,如果存在,则从该端口转发数据帧;如果不存在,将采用泛洪的方式进行转发。(泛洪:除去入端口之外的所有端口转发数据帧的方式。)
 
交换机对于未知的单播数据帧、广播数据帧、组播数据帧都是以泛洪的方式进行转发。
#show mac-address-table             (查看MAC地址表)
 
 
waiting......
*本文为华盟网原创文章,作者:Alex,如需转载请保证文章未删减并注明出处:华盟网*
本文原创,作者:AlexFrankly,其版权均为华盟网所有。如需转载,请注明出处:https://www.77169.net/html/197552.html

发表评论