GNS基本命令配置

                  GNS基本配置句         
 
pc配置:
#網關配置
pc(config)#ip default-gateway [address]

 

路由器配置:
#靜態路由
router(config)#ip route [ip] [mask] [下一跳ip] 或 router(config)#ip route [ip] [mask] [送出接口] #刪除靜態路由 router(config)#no ip route [network] [network-mask]
 
#動態路由配置
router(config)#ip router [ip] [mask] [下一跳ip] [管理距離] 例:#假若有R3和R5有兩條相連的鏈路,想要其中一條變成備份的 R3(config)#ip route 0.0.0.0 0.0.0.0 10.1.20.2 25 R5(config)#ip route 0.0.0.0 0.0.0.0 10.1.20.1 25
 
#環回配置
router(config)#interface loopback 1 router(config-if)#ip address [ip] [mask]

 

#被動端口
router(config)#router rip router(config-router)#passive-int [type][slot/number]

 

#路由器配置邏輯子端口
router(config)#int fa0/0.1(標識子接口號) router(config-subif)#encapsulation dot1q 1(標識承載哪一個vlan流量,爲vlan ID,此時承載vlan 1的流量) router(config-subif)#ip address 172.16.1.254 255.255.255.0

 

交換機端口vlan:
#添加vlan
vlan database vlan 13    

 

#修改端口類型
switchport mode access/trunk 
 
#端口添加vlan
switchport access vlan [vlan ID]  

 

#vrrp配置
router(config)#int f0/0 router(config-if)#vrrp 2 ip 192.168.13.254 vrrp 2 priority 20 vrrp 2 preempt vrrp 12 ip 192.168.13.100 vrrp 12 priority 10 vrrp 12 preempt #vrrp定時器
 
#vlan的SVI配置
sw(config)#int vlan 13 sw(config-if)#ip add 192.168.13.100 255.255.255.0
 
#修改sw的鏈路cost
sw(config)#spanning-tree vlan 13 priority ?
 
#交換機端口直接進入轉發狀態
sw(config-if)#fa0/4 sw(config-if)#spanning-tree portfast
 
 
 
鏈路聚合etherchannel:
#在兩個switch上配置
sw(config)#interface port-channel 1 sw(config-if)#ex sw(config)#int range fa0/23,fa0/24 sw(config-if-range)#channel-group 1 mode on

 

 
遠程管理交換機:
#容許三個用戶同時遠程登陸交換機
line vty 0 2
 
#telnet配置遠程登錄密碼
router(config)#hostname R router(config)#line vty 0 4 router(config-line)#password [遠程登錄密碼] router(config-line)#login #telnet配置進入特權模式的密碼 router(config)#enable secret [密碼]
 
 
 
修改當前系統時間:
router#clock set 9:00:00 2 jan 2010

 

 
 
按時間段遠程訪問:
#建立並定義time-range接口 R5(config)#time-range time1 R5(config-time-range)#absolute start 8:00 1 jan 1998 end 17:00 30 dec 2020 R5(config-time-range)#periodic daily 00:01 to 17:59 R5(config)#time-range time2 R5(config-time-range)#absolute start 8:00 1 jan 1998 end 17:00 30 dec 2020 R5(config-time-range)#periodic daily 19:01 to 23:59 #定義基於時間的ACL R5(config)#ip access-list extend net_list1 R5(config-ext-nacl)#permit tcp any host 5.5.5.5 R5(config-ext-nacl)#deny ip any host 5.5.5.5 time-range time1 R5(config-ext-nacl)#deny ip any host 5.5.5.5 time-range time2 R5(config-ext-nacl)#permit ip any any R5(config-ext-nacl)#end #將訪問列表規則應用在網絡接口上 R5(config)#int s0/0 R5(config-if)#ip access-group net_list1 in R5(config-if)#end

 

 
rip協議配置:
router(config)#router rip router(config-router)#version [1/2] router(config-router)#network [主網號] router(config-if)#no auto-summary(ripv2) router(config-if)#ip rip receive v 1 2(接收ripv1和ripv2的數據包)

 

 
密文認證:
#設置鑰匙鏈和鑰匙 router(config)#int [type][slot/number] router(config-if)#key chain [keychain name] router(config-keychain)#key [編號] router(config-keychain-key)#key-string [password] #在端口上放置鑰匙鏈 router(config)#int [type][slot/number] router(config-if)#ip rip authentication key-chain [keychain name] router(config-if)#ip rip authentication mode md5(密文認證)

 

 
ppp協議配置:
router(config-if)#encapsulation ppp

 

 
ospf協議配置:
#基本配置
router(config)#router ospf 1 router(config-router)#router-id [loopback-ip] router(config)#network [主網地址] [反掩碼] area [area-id]

 

#選舉優先級配置
#修改ospf的優先級選舉DR和BDR
router(config)#ip ospf priority [level]
 
#重分佈配置
#直連路由分佈到ospf域 router(config)#router ospf 1 router(config-router)#redistribute connected subnets [metric] [number] [metric-type] [number] #rip分佈到ospf域 router(config-router)#redistribute rip subnets
 
#末梢區域配置
#區域1配置成末梢區域 router(config-router)#area 1 stub #區域2配置成徹底末梢區域(只需在ABR上配置本參數,stub中的其餘仍是配置成末梢區域) router(config-router)#area 2 stub no-summary #nssa區域(nssa內的每一個router都要敲上) router(config-router)#area 1 nssa
 
#修改ospf接口優先級
router(config-if)#ip ospf priority [level]
 
#修改鏈路帶寬
router(config-if)#bandwidth [帶寬]
 
#修改hello和dead間隔
router(config-if)#ip ospf hello-interval seconds router(config-if)#ip ospf dead-interval seconds
 
#手工彙總
#配置區域內路由彙總(abr上) router(config)router ospf 1 router(config-router)#area 1 range [主網地址] [網絡掩碼] #配置外部自治系統路由彙總(asbr上) router(config-router)#summary-address [主網地址] [網絡掩碼]

 

 
bgp協議配置:
#基本配置
router(config)#router bgp 100 router(config-router)#no synchronization(關閉同步) router(config-router)#no auto-summary(關閉自動彙總) router(config-router)#bgp router-id [loopback ip](配置BGP路由器ID) router(config-router)#neighbor [ip] remote-as 100(指定鄰居路由器及所在的AS) router(config-router)#neighbor [ip] update-source loopback0(制定更新源) router(config-router)#network [ip] mask [掩碼]

#配置下一跳,對EBGP鄰居傳入的路由,通告給IBGP鄰居的同時配置以下
router(config)#router bgp 100
router(config-router)#no synchronization
router(config-router)#bgp router-id [ip]
router(config-router)#neighbor [ip] remote-as 100
router(config-router)#neighbor [ip] update0source loopback0
router(config-router)#neighbor [ip] next-hop-self

 

#清除
#將BGP表中的路由條目聚合彙總,並通告進BGP進程 Router(config-router)#aggregate-address + [聚合IP地址(summary-only)] #硬啓動BGP進程,從新啓動和其餘全部路由器的BGP鄰居關係 Router# clear ip bgp * #軟啓動BGP進程,當配置了策略路由後,更新傳遞給特定BGP鄰居的路由條目 Router# clear ip bgp + BGP鄰居IP + soft + in/out
 
#bgp地址聚合
router(config-router)#aggregate-address [聚合後的網絡號] [聚合後的網絡掩碼] 例: router(config-router)#aggregate-address 1.1.0.0 255.255.252.0 #bgp的as-set參數 router(config-router)#aggregate-address [聚合後的網絡號] [聚合後的網絡掩碼] as-set 例: router(config-router)#aggregate-address 1.1.0.0 255.255.252.0 as-set #summary-only參數(只想看到彙總路由,沒有明細路由) router(config-router)#aggregate-address 1.1.0.0 255.255.252.0 as-set summary-only

 

 
幀中繼配置:
#幀中繼交換機router表
FR(config)#frame-relay switching FR (config)#interface [type] [slot/number] FR (config-if)#no ip address FR (config-if)#no shut down FR (config-if)#encapsulation frame-relay ietf FR (config-if)#frame-relay intf-type DCE FR (config-if)#frame-relay lmi-type ansi FR (config-if)#frame-relay route [dlci_1] interface [interface] [dlci_2] FR (config-if)#exit
 
#路由器映射表和ip地址
router(config)#int [type][slot/number] router(config-if)#encapsulation frame ietf router(config-if)#frame map ip [address] [dlci] broadcast #幀中繼支持廣播,幀中繼網絡中router端口配置爲支持廣播 router(config-if)#ip ospf network broadcast
 
 
vtp配置:
#定義vtp模式 router(config)#vtp mode {server|client|transparent} #定義vtp域名 router(config)#vtp domain {domain-name} #設置vtp域密碼 router(config)#vtp password {password}

 

 
生成樹STP配置:
#配置生成樹協議的類型 switch(config)#spanning-tree mode stp/rstp #配置交換機優先級 switch(config)#spanning-tree vlan [vlan-id] priority <0-61440> #配置交換機端口優先級 switch(config-if)#spanning-tree vlan [vlan-id] port-priority <0-240> #交換機調爲主根或次根 switch(config)#spanning-tree vlan [vlan-id] root primary/secondary

 

 
 
                                     查看命令:                  
查看設備相關: show running-config show startup-config(啓動配置) show mac-address-table(當前MAC地址表信息) 查看接口狀態信息: show interface [type slot/port] 查看vlan: show vlan 查看路由表: router#show ip route 查看rip配置: show ip protocols 查看ospf的鄰居關係: router#show ip ospf neighbor 查看ospf的LSA概要: router#show ip ospf database 查看ospf的LSA詳細參數: router#show ip ospf database router 從新加載ospf進程: clear ip ospf process 查看tcp鏈接信息摘要: show ip tcp brief 查看鄰居的TCP和BGP鏈接的詳細信息: show ip bgp neighbor 34.34.34.4 查看BGP鏈接的摘要信息: show ip bgp summary 查看bgp表的信息: show ip bgp 查看ACL: show access-list 查看time-range接口: show time-range 查看vtp狀態: show vtp status 查看交換機生成樹狀態: show spanning-tree (vlan + vlan-id) 查看交換機接口狀態: show spanning-tree interface fa 0/1 清除ip路由表: clear ip route {network[mask]*} 顯示系統和網絡統計量: #顯示ip路由表當前狀態的摘要,在特權模式下輸入命令 show ip route summary #顯示rip路由信息,在特權模式下輸入命令 show ip route rip

 

 
 
VRRP配置:
 
配置要求:
1.pc0和pc1出外網的數據流量由R0轉發,pc2和pc3出外網的數據流量由
R1轉發。
2.當R0或R1中有一個down機時,全部的數據流量均切換到另一個未down機
的路由器轉發。
3.聯通全網絡。
 
(1)PC0、PC一、PC二、PC3配置IP地址
PC0:
ip    address    192.168.13.2    255.255.255.0
ip    default-gateway    192.168.13.254
PC1:
ip    address    192.168.24.3    255.255.255.0
ip    default-gateway    192.168.24.100
PC2:
ip    address    192.168.13.4    255.255.255.0
ip    default-gateway    192.168.13.254
PC3:
ip    address    192.168.24.5 255.255.255.0
ip    default-gateway    192.168.24.100
 
(2)sw1和sw2配置
和pc相連的改成access端口,f0/4改成trunk端口,和路由器接口改成trunk
 
(3)爲router0的f0/0和f0/1端口分配ip地址
#int fa0/0
ip address 192.168.13.254 255.255.255.0
vrrp 2 ip 192.168.13.254
vrrp 2 priority 20 
vrrp 12 ip 192.168.13.100
vrrp 12 priority 10
 
#int fa1/0
ip address 192.168.24.253 255.255.255.0
vrrp 3 ip 192.168.24.254
vrrp 3 priority 10
vrrp 13 ip 192.168.24.100
vrrp 13 priority 20
 
 
(4)爲router1的f0/0和f0/1端口分配ip地址
#int fa0/0
ip address 192.168.13.253 255.255.255.0
vrrp 2 ip 192.168.13.254
vrrp 2 priority 10
vrrp 12 ip 192.168.13.100
vrrp 12 priority 20
 
#int fa1/0
ip address 192.168.24.254 255.255.255.0
vrrp 3 ip 192.168.24.254
vrrp 3 priority 20
vrrp 13 ip 192.168.24.100
vrrp 13 priority 10
相關文章
相關標籤/搜索