小白逆襲!思科基礎命令大全,建議收藏~

思科 基本端口設置命令

no ip routing 二層交換關閉路由功能

configure terminal (conf t) 進入全局模式

interface fastEthernet 1/0 (int f1/0) 進入端口1/0 簡寫int f1/0

speed 100 設置速率為100MB

duplex full 設置端口為雙工 half 半雙工

show interfaces fastEthernet 1/0 在用戶模式下顯示 端口信息

do show interface fastEtherne 1/0 在端口或者全局模式顯示 端口信息

show ip interface brie 顯示所有端口和vlan的IP地址


vlan創建命令

dir 查看設備存儲空間

erase flash: 格式化存儲空間

vlan database 進入vlan數據模式

在數據模式下

vlan 10 name caiwu 創建vlan10,名字為caiwu

abort 退出vlan數據模式

show vlan-switch brief 用戶模式查看vlan 情況

do show vlan-switch brief 在全局模式下查看vlan情況

vlan 20 直接創建vlan 20

vlan 20 name renshi 先進入vlan20 在修改名字為renshi

switchport mode access (sw mo acc) 設置端口為接入模式

switchport access vlan 10 添加端口為vlan10

interface range fastEthernet 1/1 -2 進入連續的多個端口進行設置

switchport mode trunk 設置端口為trunk模式

switchport trunk encapsulation dot1q 給trunk端口封裝協議


默認路由和靜態路由

ip ip address 192.168.10.1 255.255.255.0 給端口配置IP地址

no shutdown 啟動端口 在路由 或者三層交換上面

ip route 0.0.0.0 0.0.0.0 1.1.1.1(下一跳地址) 添加默認路由

ip route 192.168.10.0 255.255.255.0 1.1.1.1(下一跳地址) 添加靜態路由


三層交換

do show interfaces fastEthernet 1/0 switchport 查看端口協議

vlan 10 創建vlan

interface vlan num 進入 vlan

ip address 192.168.100.1 255.255.255.0 創建vlan的網關地址

interface range fastEthernet 1/1 -4 進入連續的多個端口

channel-group 1 mode on 綁定兩個trunk端口增加鏈路,增加帶寬

即使一條鏈路損壞也不影響


RIP路由協議

router rip 啟用rip協議進程

network 192.168.10.0 聲明直聯網段

version 2 啟用rip2版本

no auto-summary 關閉匯聚功能

do show ip route 在全局模式查看路由表


OSPF路由協議

interface loopback 1 進入迴環網口

no shutdown 激活端口

router ospf 1 啟動ospf進程1

router-id 例(1.1.1.1) 設置routerID

network 192.168.10.0 0.0.0.255 area 0 宣告網段在area 0區域,注意反掩碼!!!

show running-config 用戶模式查看所有進程

no router ospf 進程ID 清除OSPF進程

redistribute connected subnets 注入直聯網段

redistribute static subnets 注入靜態路由網段

default-infomation originate 注入外部默認路由

redistribute ospf 1 metric 5 在rip協議中注入ospf協議

redistribute rip subnets 在ospf協議注入rip協議


標準ACL訪問列表 針對源IP地址

access-list 1-99 permit A.B.C.D 0.0.0.0 (反掩碼)

permit host A.B.C.D 允許該IP地址訪問流量

寫允許規則 默認拒絕所有

access-list 1-99 deny A.B.C.D 0.0.0.0(反掩碼)

deny host A.B.C.D 拒絕該IP地址訪問流量

必須要寫 permit any 允許其他IP地址訪問流量

do show access-list 全局模式,查看ACL已寫規則列表

ip access-group 1 in/out 進入端口,作用於端口

no ip access-group 1 in/out 取消應用於端口

no access-list 1 刪除整個ACL列表


擴展ACL訪問列表

(100-19) 源IP地址 目標IP地址 等於 服務名或端口

access-list 100 permit tcp host 192.168.1.2 host 192.168.100.100 eq www(或端口)

允許192.168.1.2訪問http服務

acess-list 100 deny ip host 192.168.1.2 host 192.168.100.100

拒絕192.168.1.2訪問其他服務

access-list 100 permit ip host 192.168.1.2 192.168.2.0 0.0.0.255

允許192.168.1.2訪問目標網段192.168.2.0


命名型ACL訪問控制列表

  • access-list (standard/extended) kgc

寫法跟標準和擴展一樣

刪除條目 no 條目編號

ip access-group kgc out/in 進入端口然後應用端口


靜態NAT

ip nat inside source static 192.168.100.20 12.0.0.20 轉換私網地址為公網地址

ip nat inside/outside 應用於端口

debug ip nat 啟動debug模式監聽NAT狀態

ip nat inside source static tcp 192.168.100.100 80 12.0.0.100 8080 extendable


動態NAT

access-list 1 permit 192.168.100.0 0.0.0.255 允許網段地址

ip nat pool test 12.0.0.10 12.0.0.100 netmask 255.255.255.0 轉換成的地址池名test

ip nat inside source list 1 pool test 把允許網段地址轉換為地址池

ip nat inside/outside 應用於端口

debug ip nat 在用戶模式啟動debug模式


PAT端口多路複用

access-list 1 permit 192.168.100.0 0.0.0.255 添加ACL允許網段

ip nat inside source list 1 interface fastEthernet 0/1 overload 設置網段偽裝成0/1端口IP

ip nat inside/outside 應用於端口


分享到:


相關文章: