用戶模式 Router>
特權模式 Router#
全局模式 Router(config)#
接口模式 Router(config-if)#
子接口模式 Router(config-subif)#
行模式 Router(config-line)#
進入特權模式:enable
進入全局模式:config terminal
進入接口模式:interface serial 0/0
進入子接口模式:interface serial 0/0.1
進入虛擬接口模式:line vty 0 4
進入console模式:line console 0
退出模式:End , Exit
幫助:?
打開數據包顯示:debug ip packet
關閉數據包顯示:no debug ip packet
重新啓動路由器:reload
檢查路由器平臺信息:show version
檢查系統版本:show protocols
查看flash文件:show flash
備份flash系統:copy flash: tftp: (1.輸入文件名稱,2.輸入tftp主機IP,3.輸入備份到主機的文件名,如c2600.bin)
刪除flash文件:delete flash:c2600.bin
升級還原flash系統:copy tftp: flash: (1.tftp主機IP 2.主機文件 3.主機文件名到flash的名稱 4.清空flash 5.確定清空)
備份startup-config:copy startup-config tftp
NAT端口映射,如:做FTP映射:↓(20,21端口一個是數據一個是指令)
ip nat inside source static tcp 192.168.1.1 20 interface s0/0 20
ip nat inside source static tcp 192.168.1.1 21 interface s0/0 21
然後在外網的接口上配置:ip nat outside (只能有一個出接口)
然後在內網的接口上配置:ip nat inside (可以有多個進接口)
PAT單個外網地址共內網上網:
首先定義允許內網出去的網段: access-list 1 permit 192.168.1.0 0.0.0.255
再定義內網允許訪問的控制列表到外網接口:ip nat inside source list 1 interface serial0/0 overload
最後指定出去的接口和進來的接口:
進入外網接口輸入:ip nat outside
進入內網接口輸入:ip nat inside
PAT多個外網地址共內網上網:
首先定義允許內網出去的網段: access-list 1 permit 192.168.1.0 0.0.0.255
再定義公網地址池: ip nat pool www 123.123.123.123 123.123.123.125 netmask 255.255.255.0 (這裏指定了3個外網地址)
綁定內網允許訪問的控制列表到外網地址池:ip nat inside source list 1 pool www overload
最後指定出去的接口和進來的接口:
進入外網接口輸入:ip nat outside
進入內網接口輸入:ip nat inside
telnet方式訪問設備:(配完之後ping,然後再telnet到ip)
Router(config)#line vty 0 4
Router(config-line)#password 123456
Router(config-line)#login
Router(config-line)#exit
路由和路由之間用serial口連接,S口DCE方一定要設置速率進入S口:clock rate 128000
查看路由表:show ip route
關閉自動彙總:no auto-summary
查看路由用的協議:show ip protocol
添加靜態路由表:ip route 192.168.1.0 255.255.255.0 192.168.10.1 (192.168.10.1 是下一跳)
添加靜態路由表:ip route 0.0.0.0 0.0.0.0 192.168.10.1 (0.0.0.0表示所有)
配置RIP路由協議:
開啓RIP路由協議:route rip
把本地的網段發出去:network 192.168.1.0
刪除RIP:no router rip
配置IGRP路由協議:
自制系統編號:router igrp 100 "後面的100是自制系統編號,自制系統編號要一樣才能通訊"
網絡號:network 192.168.1.0
刪除IGRP:no router igrp
配置EIGRP路由協議:
啓用EIGRP:router eigrp 1 "後面的1是自制系統編號,號碼不一致會導致不能正常通訊"
加入EIGRP的網段:network 192.168.1.0 0.0.0.255
刪除EIGRP:no router EIGRP
no auto-summary關閉自動彙總
查看加入eigrp的接口:show ip eigrp interfaces
查看eigrp鄰居關係:show ip eigrp neighbors
查看eigrp拓撲表:show ip eigrp topology
variance 9 (最佳路徑=9倍的都可以放進路由表)
實現鏈路負載均衡:
interface f0/1 (進入接口)
bandwidth 10000 (10000=10M 修改鏈路度量值)
配置OSPF路由:
啓用OSPF路由:router ospf 100 "後面是本地進程號,不一樣也可以通訊" 參與OSPF的網絡段:network 192.168.1.0 0.0.0.255 area 0
翻譯:network 網段 通配符 area 區域0
開啓所有的接口並且加入區域0:network 0.0.0.0 0.0.0.0 aera 0
查看鄰居信息:show ip ospf neighbor
查看區域ID和鏈接信息:show ip ospf interface
監控ospf信息:debug ip ospf events , debug ip ospf packet
更改OSPF開銷:ip ospf cost 5 (進入接口之後)
修改router-id : router ospf 1
router-id 1.1.1.1
清除重啓ospf表:clear ip ospf process
配置ACL訪問控制列表:
讓192.168.1.0的網段不能訪問到我當前的路由器:
R1(config)#access-list 1 deny 192.168.1.0 0.0.0.255 (創建訪問控制列表)
R1(config)#access-list 1 permit any (除了192.168.1.0網段deny,其他全部permit)
R1(config)#interface fastethernet 0/1 (進入接口)
R1(config-if)#ip access-group 1 in (綁定進來的控制列表)
常用端口:
http: tcp 80
https: tcp 443
pop3: tcp 110
smtp: tcp 25
dns: udp 53
ftp: tcp 21 20
telnet: tcp 23
ssh: tcp 22
ping icmp echo
刪除ACL訪問控制列表: R1(config)#:no access-list 1
查看訪問控制列表:R1#:show access-list
查看協議版本:show ip protocols
查看路由表信息:show ip route
查看OSPF接口信息:show ip ospf interface
查看OSPF鄰居信息:show ip ospf neighbor
show interface 查看雙工模式和其他功能
show running-config 查看當前配置
show spanning-tree 查看vlan端口當前配置
show interface sataus 查看所有端口狀態和所屬Vlan和雙工速率
show ip interface bruief 查看端口當前狀態
清除命令:erase ?
查看當前路由器配置:show running-config
保存當前配置:copy running-config startup-config , write
刪除配置及重新加載路由器:erase startup-config 。 reload
使用do命令:do 可以在任何模式下使用命令 “do ping 192.168.1.1”
更改名字:hostname “R1”
取消更改名字:no hostname
給console加密碼:password 123456 。 login
給vty加密碼:password 123456 。 login
給特權模式加明文密碼:enable pssword 123456
給特權模式加密文密碼:enable secret 123456
取消密碼:no enable pssword 。 no enable secret
超時時間設置:exec-timeout 0 0
防止域名解析:no ip domain-lookup
查看路由表:show ip route
查看接口彙總信息:show ip interface brief
查看接口一層二層的狀態:show interface
查看接口三層的信息:show ip interface
查看接口協議信息:show protocols
查看物理接口自身的信息:show controllers
查看單個端口信息:show interfaces s0/0
設置端口IP並激活端口:ip address 192.168.1.1 255.255.255.0 no shutdown
創建 vlan
switch# vlan database
switch(vlan)# vlan 2 name zjh
switch(vlan)# exit
真實交換機上直接在全局配置模式下直接打vlan後面跟上名字
多個端口刪除
switch(config)# interface range f1/0 -5
switch(config-if)# no switchport access vlan 2
刪除 vlan “刪除vlan首先要把vlan2裏的端口全部NO掉 到vlan1裏” ↑
switch# vlan database
switch(vlan)# no vlan 2
switch(vlan)# exit
將端口加入到 vlan 中
switch(config)# interface f1/1
switch(config-if)# switchport access vlan 2
將多個端口加入到 vlan 中
switch(config)# interface range f1/0 -5
switch(config-if)# switchport access vlan 2
Vlan-Trunk交換機與交換機互聯協議:
先查看交換機用什麼中繼協議然後封裝協議:
SW1(config-if)# switchport trunk encapsulation dot1q
然後把端口改成trunk:
SW1(config-if)# switchport mode trunk
查看端口狀態:show ip interface f0/0 swichprot
查看接口trunk:show interface trunk
然後再查看一下vlan中是否存在該端口:
SW1# show vlan
不在就表示該端口已變爲trunk模式了
VTP配置:
創建VTP:Switch(config)# vtp domain a
修改VTP權限:Switch(config)# vtp mode server
設置VTP密碼:Switch(config)# vtp password 123
切換vtp版本:Switch(config)# vtp version 2
設置帶寬半雙工或全雙工或自動協商:
必須要先配置接口速率再配置接口模式
PC1(config)#interface f0/1
PC1(config-if)#speed ?
10(10兆)
100(100兆)
auto(自動協商)
PC1(config-if)#speed 100
PC1(config-if)#duplex ?
auto(自動協商)
full(全雙工)
half(半雙工)
PC1(config)#duplex full
遠程連接交換機進行配置:
創建Vlan並設置Vlan IP
SW(config)#interface vlan 1
SW(config-if)#ip add 192.168.1.88 255.255.255.0
SW(config-if)#no shutdown
SW#show ip interface brief
必須設置VTY密碼之後才能遠程連接
SW(config)#line vty 0 4
SW(config-line)#password 123456 設置遠程鏈接密碼
SW(config-line)#login 設置退出後生效
SW(config-line)#exit 退出
設置網關:
SW(config)#ip default-gateway 192.168.1.1
SW(config)#end
設置快速端口:
SW(config-if)#spanning-tree portfast
查看MAC地址表:
SW#show mac-address-table
清除MAC地址表:
SW#clear mac-address-table
加密驗證
conf t
key chain 名字
key
key - string 密碼
exit
int
ip rip authenticatiok key - chain 名字
ip rip aut mode
clear ip route
路由協議EIGRP
EIGRP是思科的私有協議
一種增強型距離矢量路由協議
思科的組播地地:224.0.0.10
自制系統和進程ID
router eigrp (autonomous - system) ID號
全局模式下:router eigrp 進程ID (全網ID相同)
network 地址
show ip eigrp neighbors 檢驗EIGRP
show ip protcols
metric weights 命令更改"K"值
show inter aces 接口 檢查度量值
band width 配製帶寬 (接口模式)
EIGRP子網分割
DHCP配置
service dhcp
network 地址
default - router 默認網關
domain - name 域名
ipdhcp ex
中繼配製
ip helper - add 目標地址,中繼地址,端口
service DHCP
ippool
network 192.168.3.0 255.255.255.0
default - router 192.168.2.2
domain name jxxh.com
dhcp eocludoa - address 192.168.3.1 255.255.255.0
OSPF
192.168.2.11 192.168.2.12 192.168.2.13
① ② ③
R1 conf t
en router ospf 100
conf t net work 192.168.2.0
no ip domain-lookup 0.0.0.255 area 0
host R1 ``````
(tne cons) end
exel-time out 0 show ip inter brief
logg s
exit
intfolo
ip add 192.168.2.11 255.255.255.0
no shut
inter lo 0
ip add `````
no shut
ospf驗證
conf t
router ospf lo 0
area authentication Imessage - digest 密文
ip ospf message - digest - key mds 12355 密碼
明文加密
conf t
router ospf 100
area authentication 啓用明文驗證
inter s'10 進入接口 (區域號)
ip ospf authentiation-key 1 123456
級別 密碼
密文加密
conf t
router ospf 100area 1 authentication nlessage-digest 啓用區域密文驗證
inter 1 進入接口 (加密驗證接口)
ip ospf message - digest - key , md5 , 12345
三層交換drlcp
service dhcp
ip dhcp pool 名稱
net work +網段
default - router +dns地地
lease infinint 植的 domain-name
ip dhcp cluded
開啓vlan ,再開IP,vlan地址作爲網關