基本操作指令及示例
基本配置
enable 口令
UJN(config)#enable secret cisco
telnet指令
UJN(config)#line vty 0 15
UJN(config-line)#password class
UJN(config-line)#login
console指令
UJN(config)#line console 0
UJN(config-line)#password 123456
UJN(config-line)#login
明文加密口令
UJN(config)#service password-encryption
路由器接口和IP配置
UJN(config)#interface GigabitEthernet 0/0
UJN(config-if)#ip address 192.168.1.1 255.255.255.0
UJN(config-if)#no shutdown
Banner标签
UJN(config)#banner motd #Use of the device is specifically for authorized personnel#
远程SSH管理交换机
设置访问信息,用户名/口令为:admin/cisco,域名为 ujn.edu.cn,rsa 加密长度为 1024。
SW(config)#username admin password cisco
SW(config)#ip domain-name ujn.edu.cn
SW(config)#crypto key generate rsa
SW(config)#line vty 0 15
SW(config-line)#transport input ssh
SW(config-line)#login local
设备信息保存与清空
UJN#copy running-config startup-config
Destination filename [startup-config]?
//此处按回车键
Building configuration...
[OK]
UJN#erase startup-config
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm] //此处按回车键
UJN#reload
Proceed with reload? [confirm] //此处按回车键
%SYS-5-RELOAD: Reload requested by console. Reload Reason: Reload Command.……
valn组网配置与管理
这里其他两种比较简单,这里只介绍MS多层交换机
MS(config-vlan)#interface fastEthernet 0/1
MS(config-if)#switchport mode access
MS(config-if)#switchport access vlan 50
MS(config-if)#exit
MS(config)#ip routing
MS(config)#interface vlan 50
MS(config-if)#ip address 192.168.5.251 255.255.255.0
生成树协议
Switch(config)#spanning-tree vlan VLAN-ID priority priority
Switch(config)#spanning-tree vlan VLAN-ID root primary
Switch(config)#spanning-tree vlan VLAN-ID root secondary
Switch(config)#spanning-tree mode rapid-pvst
静态路由
ip route network-address subnet-mask {ip-address | exit-inerface} [distance]
Router1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
Router1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2
Router1(config)#ip route 192.168.5.0 255.255.255.0 192.168.2.2
默认路由
ip route 0.0.0.0 0.0.0.0 {ip-address | exit-inerface};
Router1(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2
RIP
Router(config)#route rip
Router(config)#version 2
Router(config-router)#network classful-network-address
【JINAN 配置示例】
JINAN(config)#router rip
JINAN(config-router)#network 172.16.0.0
配置默认路由并公告
QINGDAO(config)#ip route 0.0.0.0 0.0.0.0 loopback 0
QINGDAO(config)#router rip
QINGDAO(config-router)#default-information originate
OSPF
Router(config)#route ospf process-id
Router(config-router)#router-id rid
Router(config-router)#network network-address wildcard-mask area area-id
Router(config-router)#passive-interface type number
【JINAN 配置示例】
JINAN(config)#router ospf 1
JINAN(config-router)#router-id 1.1.1.1
JINAN(config-router)#network 172.16.1.0 0.0.0.255 area 0
JINAN(config-router)#network 172.16.2.0 0.0.0.3 area 0
JINAN(config-router)#network 172.16.6.0 0.0.0.3 area 0
JINAN(config-router)#passive-interface gigabitethernet 0/0
网络冗余配置
EtherChannel协议
Switch(config)# port-channel load-balance method
Switch(config)# lacp system-priority priority
Switch(config-if)# channel-protocol {pagp | lacp}
Switch(config-if)# channel-group group mode {on | desirable | auto | active | passive}
Switch(config-if)# lacp port-priority priority
MS1(config)#interface range fastethernet 0/1-2
MS1(config-if-range)#channel-protocol pagp
MS1(config-if-range)#channel-group 1 mode on
HSRP
Router(config-if)# standby group ip ip-address
Router(config-if)# standby group priority priority
Router(config-if)# standby group preempt
R1(config)#interface gigabitethernet 0/0
R1(config-if)#standby 1 ip 192.168.13.254
R1(config-if)#standby 1 priority 110
R1(config-if)#standby 1 preempt
DHCP
Router(config)#ip dhcp excluded-address low-address [high-address]
Router(config)#ip dhcp pool pool-name
Router(dhcp-config)# network network-number [mask | /prefix-length]
Router(dhcp-config)# default-router address
Router(dhcp-config)# dns-server address [addr2 … addr8]
Router(dhcp-config)# domain-name words
Router(dhcp-config)# lease {day [hour] [minite] | infinite}
【JINAN 配置示例】
JINAN(config)# ip dhcp excluded-address 172.16.1.1 172.16.1.100
JINAN(config)# ip dhcp pool LAN-172-16-1-0
JINAN(dhcp-config)# network 172.16.1.0 255.255.255.0
JINAN(dhcp-config)# default-router 172.16.1.1
JINAN(dhcp-config)# dns-server 202.194.64.1
DHCP中继
Router(dhcp-config)#ip helper-address address
【JINAN 配置示例】
JINAN(config)# no ip dhcp excluded-address 172.16.1.1 172.16.1.100
JINAN(config)# no ip dhcp pool LAN-172-16-1-0
JINAN(config)# interface gigabitEthernet 0/0
JINAN(config-if)# ip helper-address 192.168.1.2
【ZIBO 配置示例】
ZIBO(config)#no ip dhcp excluded-address 172.16.3.1 172.16.3.10
ZIBO(config)#no ip dhcp pool LAN-172-16-3-0
ZIBO(config)# interface gigabitEthernet 0/0
ZIBO(config-if)# ip helper-address 192.168.1.2
【TAIAN 配置示例】
TAIAN(config)# ip dhcp excluded-address 172.16.1.1 172.16.1.200
TAIAN(config)# ip dhcp pool LAN-172-16-1-0
TAIAN(dhcp-config)# network 172.16.1.0 255.255.255.0
TAIAN(dhcp-config)# default-router 172.16.1.1
TAIAN(dhcp-config)# dns-server 202.194.64.1
TAIAN(dhcp-config)# exit
TAIAN(config)# ip dhcp excluded-address 172.16.3.1 172.16.3.200
TAIAN(config)# ip dhcp pool LAN-172-16-3-0
TAIAN(dhcp-config)# network 172.16.3.0 255.255.255.0
TAIAN(dhcp-config)# default-router 172.16.3.1
TAIAN(dhcp-config)# dns-server 202.194.64.1
ACL
Router(config)# access-list access-list-number {deny | permit } source [source-wildcard]
Router(config-line)#access-class access-list-number in
在 JINAN 路由器设置不允许 PC2 远程管理设备(使用基于编号的标准 ACL)。JINAN
路由器参考指令如下。
JINAN(config)#access-list 1 deny host 172.16.3.2
JINAN(config)#access-list 1 permit any
JINAN(config)#line vty 0 15
JINAN(config-line)#access-class 1 in
禁止 172.16.3.0/24 网段内的主机对 Server 发出 ping 请求,但是主机 Server 可以向
172.16.3.0/24 网络发起 ping 测试。参考配置如下。
ZIBO(config)#ip access-list extended DENY_PING_Server
ZIBO(config-ext-nacl)# deny icmp 172.16.3.0 0.0.0.255 host 192.168.2.2 echo
ZIBO(config-ext-nacl)# permit ip any any
ZIBO(config-ext-nacl)# exit
ZIBO(config)#interface gigabitethernet 0/0
ZIBO(config-if)#ip access-group DENY_PING_Server in
禁止 PC1 访问 Server 上的 FTP 服务。参考配置如下。
TAIAN(config)#ip access-list extended SECURITY _FTP
TAIAN(config-ext-nacl)# deny tcp host 172.16.1.2 host 192.168.2.2 eq 20
TAIAN(config-ext-nacl)# deny tcp host 172.16.1.2 host 192.168.2.2 eq 21
TAIAN(config-ext-nacl)# permit ip any any
TAIAN (config-ext-nacl)# exit
TAIAN (config)#interface serial 0/0/1
TAIAN (config-if)#ip access-group SECURITY _FTP in
NAT
静态NAT
R2(config)# ip nat inside source static 192.168.2.251 211.64.95.3
R2(config)#interface gigabitethernet 0/0
R2(config-if)# ip nat inside
R2(config-if)#interface serial 0/0/0
R2(config-if)# ip nat outside
配置PAT
R2(config)# ip nat pool ujnise 211.64.95.4 211.64.95.6 netmask 255.255.255.248
R2(config)#access-list 1 permit 192.168.1.0 0.0.0.255
R2(config)#access-list 1 permit 192.168.2.0 0.0.0.255
R2(config)#ip nat inside source list 1 pool ujnise overload
R2(config)#interface gigabitethernet 0/1
R2(config-if)# ip nat inside
查看配置指令
检查vlan配置信息show vlan brief
使用 show interface gigabitethernet 0/1 switchport、show interface fastethernet 0/1 switchport查看端口状态
交换机使用 show vlan brief 查看 VLAN 信息。
路由器使用 show ip route 查看路由表信息。
show spanning-tree查看生成树的状态
使用 show etherchannel 相关指令查看以太信道配置及负载均衡方法。
使用 show standby brief 和 show standby 查看它们的 HSRP 情况
使用命令 show ip dhcp binding 检查动态地址分配绑定情况。
show access-list查看acl分配情况
使用 show ip nat translations 检查静态 NAT 映射