Cisco常用配置命令

一.交换机的基本配置

C2950#

config terminal 进入全局配置模式

show interface fastethernet0/1 查看端口0/1的配置结果

show interface fastethernet0/1 status 查看端口0/1的状态

show mac-address-table 查看整个MAC地址表

clear mac-address-table restricted static 清除限定性地址

C2950(config)#

hostname 2950A / 设置主机名为2950A

interface f0/23 / 进入端口23的配置模式

enable password cisco / 设置enable password为cisco

enable secret cisco1 / 设置enable secret为cisco1

ip address 192.168.1.1 255.255.255.0 / 设置交换机IP地址

ip default-gateway 192.168.1.254 / 设置默认网关

ip domain-name cisco.com / 设置域名

ip name-server 200.0.0.1 / 设置域名服务器

配置查看MAC地址表

mac-address-table ?

mac-address-table aging-time 100 / 设置超时是时间为100s

mac-address-table permanent 0000.0c01.cc /f0/3 加入永久地址

mac-address-table restricted static 0000.0c02.bbcc / f0/6 f0/7 加入静态地址

end

show mac-address-table /查看整个Mac地址表

clear mac-address-table restricted static

C2950(config-if)#

interface fastethernet0/1 /进入接口F0/1子配置模式

interface Ethernet0 /进入以太网口0子配置模式

no shutdown /激活接口

speed ? /查看speed命令的子命令

speed 100 /设置该端口速率为100Mb/s

dulplex full/half/auto /设置该端口为全双工

description TO_PC1 /设置该端口描述为TO_PC1

show interface fastethernet 0/1 /查看端口0/1的配置结果

show interface fastethernet 0/1 status /查看端口0/1的状态

配置VTP和STP

一. 配置VTP

2950A #vlan database /进入VLAN配置子模式

show vtp status /查看VTP设置信息

show vlan /查看VLAN配置信息

copy running-config startup-config /保存配置文件

2950A(vlan)#vtp server/client /设置本交换机为server/client模式

vtp pruning /启动修剪功能

vtp domain vtpserver /设置域名为vtpserver

vlan 2 /创建VLAN2,系统将自动命名

vlan 3 name vlan3 /创建VLAN3,并命名为vlan3

Switch(config-if)#

switchport mode trunk /设置当前端口为Trunk模式

switchport trunk allowed vlan all /设置允许从该端×××换数据的VLAN

switchport trunk vlan remote vlan6 /设置允许交换数据的Vlan(除vlan6外)

switchport mode access /设置端口为静态VLAN访问模式

switchport access vlan2 /将端口9分配给相信的VLAN2

show vlan

生成树协议配置(负载均衡)

Switch#

spanning-tree vlan 1 port-priority 10 /设置VLAN 1的端口的权值为10 (默认值为128)

spanning-tree vlan 1 cost 19 /设置VLAN 1生成树路径值为19

专题三 配置路由协议

Router# enable

Router#config terminal

Router(conf)#hostname R1

show session /查看终端服务器的会话

show line 1 /查看线路1的状态

clear line 2 /清除线路2

A. 静态路由

格式:ip route ip-addr subnet-mask gateway 加入静态路由

R1(conf)#ip route 192.168.1.0 255.255.255.0 10.1.1.1

ip routing /启动IP路由

B. 动态路由

(1)配置RIP协议

no logging console 防止大量的端口状态变化信息和报警信息对配置过程的影响

[no] ip routing 允许/不允许路由选择协议

router ri p 进入RIP协议配置模式

network 192.168.1.0 声明192.168.1.0与路由器R1直接邻接

version 2 设置RIP协议的版本为2

neighbor ip-addr 说明邻接路由器,以使它们能够自动更新路由

passive interface 接口 阻止在指定的接口发送路由更新协议

show ip route 查看路由表信息

show ip route rip/igrp/ospf 查看RIP/IGRP/OSPF协议路由信息

(2)配置IGRP协议

no keepalive /不监测keepalive信号,即不连接设备时可激活该接口

bandwidth x /设置带宽为x(Kb/s)

clockrate x /设置时钟频率为x(HZ)

timer basic /更新时间 到期时间 抑制与否清除时间 设置自定义的路由更新时间……

no metric holddown /禁止抑制功能,路由信息删除后可立即接受新的

metric maximum-hop 50 /当信息包穿过50个路由器时,删除信息包

router igrp/eigrp autonomous-system /进入IGRP协议配置子模式

(3)配置OSPF协议

router ospf 1 /指定使用ospf选择协议,并运行在1号进程中

network 网络地址 掩码反码 area 区域号 /说明与区域1的172.16.4.6邻接

area 区域号 stub /将区域x转化为根区

show ip ospf neighbor /列出与本路由器是“邻接”关系的路由器

no ospf auto-cost-determination /使OSPF不自动根据每个接口的带宽,计算出其cost

ip ospf cost /手动设置接口的cost

area 1 range 172.16.4.0 255.255.255.0 /说明区域一的范围是子网172.16.4.0/24

(4)配置EIGRP协议

no auto-summary 关闭EIGRP协议的路由自动汇总功能

network network-addr 掩码反码

广域网接入

一.配置ISDN

isdn switch-type switch-type /设置交换机类型为 switch-type

interface bri 0 /进入ISDN的BRI接口配置模式

encapsulation ppp /设置封装协议为ppp

ppp multilink /启动ppp多连接

dialer string 80000002 /设置拨号串,R2的ISDN号码为80000002

dialer-group 1 /设置拨号组号为1,把BRI 0接口与拨号列表1相关联

dialer-list 1 protocol ip permit /设置拨号列表1,即当有IP包时将引起拨号

dialer load-threshold load /设置达到load后,启动第二个B通道.

logging console /在终端上显示监测信息

debug dialer /监测dialer信息

undebug all /关闭所有调试信息

二. 配置PPP和DDR

ppp authentication chap /设置PPP认证方式为CHAP

clockrate speed /设置DCE端线路速度为speed

dialer idle-timeout 120 /设置拨号空闲时间为120s

no cdp enable /禁止通过此接口传递CDP控制数据

dialer map ip 192.168.1.2 name R2 broadcast 800000002

/设置拨号串,将IP地址与ISDN的SPID对应起来.

usename R2 password secret

/设置用户名和口令,即设置拨号链路对端路由器名为R2,口令为secret.

三. 配置帧中继

frame-relay lmi-type cisco /设置帧中继的LMI类型为cisco

no frame-relay inverse-arp /关闭帧中继逆向ARP

no ip address /只在数据链路层工作,无需IP地址

frame-relay interface-dlci dlci

interface serial 2 /进入串行口2端口配置模式

frame-relay route 303 interface Serial 1 302 在串行口2的DLCI 303与串行口1的DLCI 302之间建立关联

show frame route /显示完整的路由信息

frame-relay map ip 192.168.1.2 302 broadcast /将IP地址192.168.1.2与帧中继的DLCI 302关联起来

interface s 0.1 划分子接口,对其进行逻辑划分

interface s 0.1 point-to-point 划分子接口,并设置为点对点模式

×××配置

一 L2TP的配置与测试

A:命令模式:特权用户模式Quidway#

(1)show l2tp session 显示当前的L2TP会话的信息

举例:Quidway#show l2tp session

(2) show l2tp tunnel 显示当前的L2TP通道的信息

举例:Quidway#show l2tp tunnel

(3)clear vpdn tunnel l2tp remote-name 断开通道对端名称为X的通道连接

举例:Quidway#clear vpdn tunnel l2tp A8010

B:命令模式:全局配置模式Quidway(config)#

(4) [no] vpdn-group group-nunmber 创建/删除组号为x的VPDN组

举例:Quidway(config)#vpdn-group 2

默认情况:系统默认没有创建VPDN组

(5)[no] interface vitual-template vitual-template-number 创建/删除虚接口模块

举例:Quidway(config)#interface virtual-template 1

默认配置:系统默认没有创建虚接口模块

C:命令模式:VPDN组配置模式Quidway(config-vpdn1)#

(6) [no]lcp renegotiation 允许/不允许LCP再次协商

举例:Quidway(config-vpdn1)#lcp renegotiation

扩展:lcp renegotiation always 一直允许进行LCP协商

默认情况:系统默认不重新进行LCP协商

(7)local name name 指定通道本端的名称为name

no local name 将通道本端的名称恢复成默认名称

举例:Quidway(config-vpdn1)#local name itsme

默认情况:系统默认的本端名称为路由器名

(8) [no] l2tp tunnel authentication 启用/关闭L2TP通道验证功能

举例:Quidway(config-vpdn1)#no l2tp tunnel authentication

默认情况:系统默认对L2TP通道进行验证

(9) l2tp tunnel password password 设置L2TP通道验证的密码为password

no l2tp tunnel password 将L2TP通道验证的密码还原为默认值

举例:Quidway(config-vpdn1)#l2tp tunnel password yougotit

默认情况:系统默认的通道验证密码为路由器名

(10) [no] force-local-chap 强制/禁止LNS与Client之间重新进行CHAP验证

举例:Quidway(config-vpdn1)#force-local-chap

默认情况:系统默认不进行CHAP的重新验证

(11)accept-dialin l2tp virtual-template virtual-template-number remote

remote-peer-name 接受名称为remote-peer-name的对端发起的L2TP通道连接请求,并根据vitual-template virtual-template-number 创建virtual-access接口

no accept dialin 删除此设置

举例: Quidway(config-vpdn1)#accept-dialin l2tp virtual-template 1 remote A8010

, 默认情况:系统默认为禁止接受呼入

二 IPSec的配置

Crypto isakmp policy1 /配置IKE策略1

Authentication pre-share /IKE策略1的验证方法设为pre-share

Group 2;1024-bit Diffie-Hellman /加密算法未设置则取默认值:DES

Crypto isakmp key test123 address 202.96.1.2 /设置Pre-share密钥为test123,此值两端需一致

crypto ipsec transform-set ×××tag ah-md5-hmac esp-des

/设置AH散列算法为md5,ESP加密算法为DES.

crypto map ×××demo 10 ipsec-isakmp /定义crypto map

set peer 202.96.1.2 /设置隧道对端IP地址

set transform-set ×××tag /设置隧道AH及ESP

match address 101

interface Tunnel0 /定义隧道接口

ipaddress 192.168.1.1 255.255.255.0 /隧道端口IP地址

no ip directed-broadcast

tunnel source 202.96.1.1 /隧道源端地址

tunnel destination 202.96.1.2 /隧道目的端地址

crypto map ×××demo /应用×××demo于此接口

其他的略

NAT——网络地址转换

(1)静态地址转换

ip nat inside source static 内部地址 合法地址 (全局配置模式)

举例: ip nat inside source static 10.1.1.2 192.1.1.2

在内部地址X和合法地址Y之间建立静态转换

ip nat inside /说明该端口是内网接口

ip nat outside /说明该端口是外网接口

(2)动态地址转换

ip nat pool 地址池名称 起始IP地址 终止IP地址 netmask 子网掩码 (全局配置模式)

举例:ip nat pool poolA 192.1.1.2 192.1.1.10 netmask 255.255.255.0

/设置合法地址池,名为PoolA, 地址范围为192.1.1.2~192.1.1.10,子网掩码为255.255.255.0

access-list 标号 permit 源地址 通配符(其中标号为1~99间的整数)

举例:access-list 1 permit 10.1.1.0 0.0.0.255

定义标准访问列表1,指出10.1.1.0/24的本地地址进行NAT转换

ip nat inside source list 访问列表标号 pool 地址池名称

举例:ip nat inside source list 1 pool poolA

设置:对访问列表1中设置的本地地址,应用PoolA池进行动态地址转换

(3)复用动态地址转换

ip nat inside source list 访问列表标号 pool 地址池名称 overload

举例:ip nat inside source list 1 pool poolA overload

设置:对访问列表1中设置的本地地址,应用PoolA池进行复用动态地址转换