Cisco常用命令第一~四学期总结
小知识点
一,IP地址分类:
类型 十进制范围 每个网络可容纳主机数
A 0~127 2^24-2
B 128~191 2^16-2
C 192~223 2^8-2 二,私有IP地址(其余皆为公网地址) 类型 地址范围
A 10.0.0.0~10.255.255.255
B 172.16.0.0~172.31.255.255
C 192.168.0.0~192.168.255.255
Cisco基本配置命令
(以下命令凡带有*号,皆为举例) (凡带有^号,一般为次方)
(部分涉及CCNA内容)
一,设置时间(特权模式)
clock set 22:45:00 28 june 2011
clock timezone GMT+8
二,交换机同时打开多端口(全局模式)
int range *f0/1-15
no shut
三,RIP(路由信息协议)配置(特别注意:合理利用clear ip route *?<两面性>清空路由表,以便显示更新信息 企业中维护切勿使用该命令进行更新,否则会导致企业网瘫痪、BUG。)
1,基本配置RIPv1/2(全局模式)
router rip
Version(版本)1/2
no ip domain-lookup(IP域名解析)
no auto-summary(关闭自动总结)
network *172.31.0.0(RIP更新)
passive-interface *f0/0(被动接口)(禁用更新)
neighbor *172.16.1.3(配置单播更新)
2, 静态路由重分布
route rip
redistribute static
no net *192.168.0.0
3,注入默认路由
ip default network *192.168.34.0
四,EIGRP(增强型内部网关路由协议)(全局模式)
1, 基本配置
route eigrp 1(ID值)
(no)default-information out(允许发送默认路由) no auto-summary
① , network *172.31.0.0
② , network *192.168.10.128/24 0.0.0.255
redistribute static
passive-interface *f0/0(被动接口)(禁用更新) 2,注入默认路由
ip default-network *192.168.34.0
3, 带宽
int *s0/0/0(一条链路两端需配置)
(no)bandwidth *64
4,时间间隔(一条链路两端需设置及路由器串口) int *s0/0/0
ip hello-interval eigrp 1 *60
ip hold-interval eigrp 1 *180
5, 手动总结
int *s0/0/0
ip summary-address eigrp 1 *192.168.0.0 255.255.252.0 int *s0/0/1
ip summary-address eigrp 1 *192.168.0.0 255.255.252.0
五,OSPF(开放最短链路优先)(全局模式) 1,基本配置
route ospf 1
no auto-summary
passive-interface *f0/0
route id *1.1.1.1(最优先的OSPF制定 route ID) network *10.1.0.0 0.0.0.255 area 0
default-information originate
2,修改开销(cost=10^8/bandswidth)(一条链路两端) int *s0/0/0
ip ospf cost *1562
3, 修改hello间隔,dead间隔(一条链路两端) int *s0/0/0
ip ospf hello-interval *5
ip ospf dead-interval *20
4,选举DR/BDR
Int *f0/0
Ip ospf priority 1-255(0不参与选举,默认为1) 5, OSPF验证
①,简单验证
route ospf 1
area 0 authentication
int *s0/0/0
ip ospf authentication-key *cisco123
②, 配置OSPD MD5身份验证
route ospf 1
area 0 authentication message-digest
int *s0/0/0
ip ospf message-digest-key 1 md5 *cisco123
6, 使用TFTP服务器升级Cisco IOS映像
copy tftp flash
Address or name of remote host []? *192.168.20.254
Source filename []? *c1841-ipbasek9-mz.124-12.bin
7,配置 boot system 命令
boot system flash *c1841-ipbasek9-mz.124-12.bin
六,配置端口安全性(全局模式)
switchport port-security(启用端口安全性)
switchport port-security maxnum *15(最大数量)
switchport port-security violation shutdown(违规关闭)
mac-address-table static MAC *vlan 99 int *f0/15(静态MAC地址,将端口-MAC地址绑定)
switchport port-security mac-address sticky(粘滞获取MAC地址) 七,显示历史记录(全局模式)
history size *50(配置历史记录大小)
no history size(默认10条命令行)
no history(禁用)
八,duplex和speed命令(全局模式)
int f0/0
duplex *auto
speed *auto
九,hdlc和ppp封装(全局模式)
1, hdlc、ppp封装
int s/0/0/0
encapsulation hdlc/ppp
2,PAP、CHAP验证(全局模式)
①, PPP PAP 身份验证(串行链路间配置,另 to 另:R1,R2) R1#username *R1 password cisco
int *s0/0/0
encapsulation ppp
ppp authentication pap
ppp pap sent-username R1 password cisco
另:R2#username *R1 password cisco
int *s0/0/0
encapsulation ppp
ppp authentication pap
②, PPP CHAP 身份验证(串行链路间配置,另 to 另:R1,R2)
R1#username R2 password cisco
int s0/0/1
encapsulation ppp
ppp authentication chap
R2#username R1 password cisco
encapsulation ppp
ppp authentication chap
十,帧中继配置(全局模式)
1,配置帧中继
int *s0/0/0
encapsulation frame-relay
no shut
2, 配置静态帧中继映射
frame-relay map ip *10.10.10.2 102 broadcast frame-relay map ip *10.10.10.3 201 broadcast 3, 配置帧中继LMI类型
int *s0/0/0
frame-relay lmi-type *ansi
十一,ACL基本配置(全局模式)
(1~99:标准ACL;100~199:扩展ACL) 1,标准ACL配置
ip access-list standard *std-1
deny *192.168.11.0 0.0.0.255
permit any
①, 控制vty 线路访问
line vty *0 15
access-class *std-1 in/out
②, 应用ACL
int *s/0/0/0
ip access-group *std-1 in/out
2,扩展ACL配置
ip access-list extended *extend-1
deny ip *host 192.168.10.0 host 192.168.20.0
(192.168.10.0 0.0.0.255 192.168.20.0 0.0.0.255) (192.168.10.0 0.0.0.0 192.168.20.0 0.0.0.0) permit ip any any
int *s/0/0/0
ip access-group *extend-1 in/out
3,数字编号的标准 ACL
access-list *10 deny *192.168.10.0 0.0.0.255
access-list 10 permit any
int f0/0
ip access-group 10 in/out
数字编号的扩展 ACL
①, access-list *110 deny *tcp *192.168.10.0 0.0.0.255 any eq *telnet ②, access-list *110 deny *udp *host 192.168.10.0 host 192.168.20.254 eq *tftp
③, access-list *110 permit *tcp *192.168.30.128 0.0.0.127 any eq *www
④, access-list *110 permit *icmp *192.168.30.128 0.0.0.127 any
⑤, access-list *110 permit ip *192.168.20.0 0.0.0.255 192.168.10.0 0.0.0.255
Access-list *110 permit ip any any
int f0/0
ip access-group 110 in/out
ACL特殊注意五类:
1.阻止 *10.1.10.0 网络访问 *10.1.40.0 网络。允许对 *10.1.40.0 的所有其它访问。在 HQ 上使用 ACL 编号 10 配置 ACL。 使用标准 ACL 还是扩展 ACL?
将 ACL 应用到哪个接口?
将 ACL 应用于哪个方向
access-list *10 deny *10.1.10.0 0.0.0.255
access-list *10 permit any
int *f0/1
ip access-group *10 out
2.拒绝主机 10.1.10.5 访问主机 10.1.50.7。允许所有其它主机访问
10.1.50.7。在 B1 上使用 ACL 编号 115 配置 ACL。
使用标准 ACL 还是扩展 ACL?
将 ACL 应用到哪个接口?
将 ACL 应用于哪个方向?
access-list *115 deny ip *host 10.1.10.5 host 10.1.50.7
(access-list *115 deny ip *10.1.10.5 0.0.0.0 10.1.50.7 0.0.0.0) access-list *115 permit ip any *host 10.1.50.7
HQ:int *f0/0
ip access-group *115 in
B1:
access-list *115 deny ip *host 10.1.10.5 host 10.1.50.7
(access-list *115 deny ip *10.1.10.5 0.0.0.0 10.1.50.7 0.0.0.0) access-list *115 permit ip any any
int f0/0
ip access-group *115 in
3.拒绝从 10.1.50.1 到 10.1.50.63 的主机通过 Web 访问地址为 10.1.80.16 的内部网服务器。允许所有其它访问。在适当的路由器上使用 ACL 编号 101 配置 ACL。
使用标准 ACL 还是扩展 ACL?00000001-0011111111 10.1.50.0/26 255.255.255-192=63
在哪台路由器上配置该 ACL?
将 ACL 应用到哪个接口?
将 ACL 应用于哪个方向?
access-list *101 deny tcp *10.1.50.0 0.0.0.63 host 10.1.80.16 eq www access-list *101 permit ip any any
HQ:int *f0/0
ip access-group *101 in
4.使用名称 NO_FTP 配置命名 ACL,阻止 10.1.70.0/24 网络访问文件服务器 (10.1.10.2) 上的 FTP 服务(端口 21)。所有其它访问都应允许。
注意:名称区分大小写。
使用标准 ACL 还是扩展 ACL?
在哪台路由器上配置该 ACL?
将 ACL 应用到哪个接口?
将 ACL 应用于哪个方向?
ip access-list extended *NO_FTP
deny tcp *10.1.70.0 0.0.0.255 host 10.1.10.2 eq ftp(21)
permit ip any any
B2:int *f0/1
ip access-group *NO_FTP in
5.由于 ISP 代表与 Internet 之间的连通性,因此请按照下列顺序配置名为 FIREWALL 的命名 ACL:
仅允许来自 ISP 和来自 ISP 之外任何源地址的入站 ping 应答。 仅允许来自 ISP 和来自 ISP 之外任何源地址的已建立 TCP 会话。
明确阻止来自 ISP 和来自 ISP 之外任何源地址的所有其它入站访问
使用标准 ACL 还是扩展 ACL?
在哪台路由器上配置该 ACL?
将 ACL 应用到哪个接口?
将 ACL 应用于哪个方向?
ip access-list extended *FIREWALL
permit icmp any any *echo-replay(ping 应答)
permit tcp any any *established(TCP 会话)
deny ip any any
HQ:int *s0/1/0
ip access-group *FIREWALL in
十二,基本DHCP与NAT配置(全局模式)
1,配置DHCP
①,排除静态分配的地址
ip dhcp excluded-address *192.168.10.1 192.168.10.10
②,配置地址池
ip dhcp pool *R1Fa0
network *192.168.11.0 255.255.255.0
dns-server *192.168.11.5
default-router *192.168.11.1
2,配置静态 NAT
①,静态映射公有 IP 地址到私有 IP 地址
ip nat inside source static 192.168.20.254 209.165.200.254
②,指定内部和外部 NAT 接口
int s0/0/1
ip nat inside/outside
3, 利用地址池配置动态 NAT
①, 定义全局地址池
ip nat pool *MY-NAT-POOL *209.165.200.241 209.165.200.246 netmask *255.255.255.248
②, 创建标准访问控制列表,以便确定需要转换的内部地址 ip access-list extended *NAT
permit ip *192.168.10.0 0.0.0.255 any
permit ip *192.168.11.0 0.0.0.255 any
③,将地址池与访问控制列表绑定,建立动态源地址转换 ip nat inside source list *NAT pool *MY-NAT-POOL
④,指定内部和外部 NAT 接口
int s0/0/0
ip nat inside/outside
4, 配置 NAT 过载
①, 删除 NAT 地址池和映射语句
no ip nat pool *MY-NAT-POOL *209.165.200.241 209.165.200.246 netmask *255.255.255.248
no ip nat inside source list *NAT pool *MY-NAT-POOL
②, 使用 serial 0/0/1 接口公有 IP 地址在路由器上配置 PAT ip nat inside source list NAT interface S0/0/1 overload
十三,配置vtp
vtp domain *cisco1(配置域名)
vtp version 1(配置版本)
vtp password *cisco(配置口令)
vtp domain server/client(配置域名)
十四,STP配置
spanning-tree vlan *20 root primary(强制交换机成为主根桥) spanning-tree vlan *10 root secondary(强制交换机成为次根桥) spanning-tree vlan n priority *4096(配置优先级)