糯米文學吧

位置:首頁 > 計算機 > 網絡技術

路由交換命令大全

進入console口進行本地配置用户模式 xx>enable n特權模式 xx#configure terminal全局配置模式 xx(config)#interface [f|s] n/m進入接口配置模式xx(config-if)#,下面是由本站小編為大家整理的路由交換命令大全,喜歡的可以收藏一下!瞭解更多詳情資訊,請關注應屆畢業生考試網!

路由交換命令大全

  「基礎配置」

進入console口進行本地配置用户模式 xx>enable n特權模式 xx#configure terminal全局配置模式 xx(config)#interface [f|s] n/m進入接口配置模式xx(config-if)#

進入(子)接口模式後配置IP(config-if)#ip addr A.B.C.D 子網掩碼激活接口(config-if)#no shutdown配置速度(config-if)#speed {auto|10|100}配置接口工作模式(config-if)#duplex {auto|half|full}配置時鐘(串行口DCE端)

(config-if)#clock rate n反向操作(刪除配置)

no + 命令在換回接口上配多個ip(config-if)#ip addr A.B.C.D 子網掩碼(config-if)#ip addr A.B.C.D 子網掩碼 secondary查看所有配置#show running-config

路由器關閉路由功能充當主機(config)#no ip routing為路由器設置網關(config)#ip default-gateway ip地址

改機器名字(config)#hostname yy控制線路超時(config)#line n(config-line)#exec-timeout 0 0關閉域名解析功能(config)#no ip domain-lookup開啟路由器http功能(config)#ip http server(config)#username xxx password yyy(config)#username xxx secret yyy(config)#enable secret yyy啟用密碼加密服務(config)#service password-encryption yyy開啟路由器https功能(config)#ip http secure-server開啟路由器遠程登錄功能(config)#line vty 0 4(config)#login local或者(config)#no login(config)#enable n登錄時使用命令 telnet A.B.C.D

  「交換機」

查看mac地址表#show mac-address-table綁定靜態mac地址(config)#mac-address-table static H.H.H vlan n interface fx/x #show arp在主機上使用arp -a查看arp信息開啟交換機端口安全(防止連接主機惡意發送隨機mac填滿mac地址表)

(conifg)#switchport port-security(conifg)#switchport ?

#show port-security int fx/x恢復(config)#errdisable recovery

為交換機vlan1配置管理ip(conifg)#int vlan 1(config-if)#ip addr A.B.C.D 子網掩碼(config-if)#no shut

  「交換機vlan」

查看vlan #show vlan-switch或是#show vlan創建vlan #vlan database(vlan)#vlan n將端口加入到vlan中(config-if)#switchport access vlan n給允許多個vlan的接口打trunk(config-if)#switchport mode trunk

  「單臂路由vlan」

路由器上配置子接口實現不同vlan之間通信,先必須激活其父接口,另外IP不允許重複(config)#interface fx/x.x(config-subif)#encapsulation dot1q vlan-id(config-subif)#ip addr A.C.D.E 子網掩碼(config-subif)#no shut

  「使用三層交換機交換虛擬接口」

交換機上配置虛擬交換接口實現不同vlan之間通信,先必須在交換機上添加對應vlan(config)#int vlan n(config-if)#ip addr A.B.C.D 子網掩碼(config-if)#no shut在刪除時,務必先刪除交換虛擬接口,再刪對應vlan

  「VTP」

配置VTP模式#vlan database(vlan)#vtp {server|client|transparent}只有域名和密碼完全一樣的`路由器之間才能同步vlan信息(vlan)#vtp domain <域名>(vlan)#vtp password <密碼>打開VTP裁剪(vlan)#vtp pruning退出激活(vlan)#exit

  「端口聚合」

創建R1(config)#interface port-channel 1(config-if)#switchport trunk encapsulation dot1q(config-if)#switchport mode trunk將指定接口加入聚合組內#int range f x/x-x #channel-group 1 mode on查看聚合接口#show etherchannel summary

  「生成樹協議」

基於vlan的生成樹可防止環路開啟生成樹協議(STP默認是開啟的,可省略)

(config)#spanning-tree vlan n修改生成樹協議優先級(根網橋:mac最小、優先級最小)

(config)#spanning-tree vlan n priority m交換機和主機之間連接的端口開啟portfast,可防止主機發送BPDU偽造數據(config-if)#spanning-tree portfast查看生成樹#show spanning-tree [vlan n]

  「靜態路由」

查看協議#show ip protocols查看路由表#show ip route添加靜態路由(以默認路由舉例)

(config)#ip route {出接口|下一跳ip}浮動靜態路由(備份鏈路,在原鏈路失效後起作用)

(config)#ip route 出接口 AD管理距離靜態黑洞路由(config)#ip route null 0

  「RIP距離矢量路由,動態路由」

配置RIP宣告直連網段(config)#router rip(config-router)#network 網段更改為版本2(config-router)#version {2|1}關閉自動彙總(如果被其他網路隔開時,最好關閉自動彙總)

(config-router)#no auto-summary設置被動接口(只接受更新,不宣告自己)

(config-router)#passive-interface 接口單播更新(只和指定的ip交換路由信息)

(config-router)#neighbor ip地址清除路由表內容#clear ip route *

  「OSPF鏈路狀態路由,動態路由」

配置OSPF宣告直連網路(config)#router ospf <進程號>(config-router)#router-id <任意ip地址>(config-router)#network <ip網段> <反掩碼> area n重啟OSPF進程#clear ip ospf process查看接口的OSPF信息#show ip ospf interface查看鄰居表#show ip ospf neighbor查看鏈路數據表#show ip ospf database <?>

標籤:路由 命令