1. 程式人生 > >華為h3c基礎命令

華為h3c基礎命令

交換機命令

[Quidway]dis cur                                        ;顯示當前配置
[Quidway]display current-configuration                  ;顯示當前配置
[Quidway]display interfaces                             ;顯示介面資訊
[Quidway]display vlan all                               ;顯示路由資訊
[Quidway]display version                                ;顯示版本資訊

[Quidway]super password                                          ;修改特權使用者密碼
[Quidway]sysname                                       ;交換機命名
[Quidway]interface ethernet 0/1                                  ;進入介面檢視
[Quidway]interface vlan x                                   ;進入介面檢視
[Quidway-Vlan-interfacex]ip address 10.65.1.1 255.255.0.0     ;配置VLAN的IP地址

[Quidway]ip route-static 0.0.0.0 0.0.0.0 10.65.1.2            ;預設路由=閘道器
[Quidway]rip                                                  ;三層交換支援
[Quidway]local-user ftp

[Quidway]user-interface vty 0 4                               ;進入虛擬終端
[S3026-ui-vty0-4]authentication-mode password                 ;設定口令模式
[S3026-ui-vty0-4]set authentication-mode password simple 555       設定口令
[S3026-ui-vty0-4]user privilege level 3                          使用者級別

[Quidway]interface ethernet 0/1                                  ;進入埠模式
[Quidway]int e0/1                                             ;進入埠模式
[Quidway-Ethernet0/1]duplex {half|full|auto}                  ;配置埠工作狀態
[Quidway-Ethernet0/1]speed {10|100|auto}                    ;配置埠工作速率
[Quidway-Ethernet0/1]flow-control                           ;配置埠流控
[Quidway-Ethernet0/1]mdi {across|auto|normal}                 ;配置埠平接扭接
[Quidway-Ethernet0/1]port link-type {trunk|access|hybrid}     ;設定埠工作模式
[Quidway-Ethernet0/1]port access vlan 3                      ;當前埠加入到VLAN
[Quidway-Ethernet0/2]port trunk permit vlan {ID|All}        ;設trunk允許的VLAN
[Quidway-Ethernet0/3]port trunk pvid vlan 3                ;設定trunk埠的PVID
[Quidway-Ethernet0/1]undo shutdown                       ;啟用埠
[Quidway-Ethernet0/1]shutdown                                ;關閉埠
[Quidway-Ethernet0/1]quit                                  ;返回

[Quidway]vlan 3                                            ;建立VLAN
[Quidway-vlan3]port ethernet 0/1                 ;在VLAN中增加埠
[Quidway-vlan3]port e0/1                                 ;簡寫方式
[Quidway-vlan3]port ethernet 0/1 to ethernet 0/4         ;在VLAN中增加埠
[Quidway-vlan3]port e0/1 to e0/4                         ;簡寫方式

[Quidway]monitor-port <interface_type interface_num>         ;指定映象埠
[Quidway]port mirror <interface_type interface_num>         ;指定被映象埠
[Quidway]port mirror int_list observing-port int_type int_num ;指定映象和被映象

[Quidway]description string                              ;指定VLAN描述字元
[Quidway]description                                  刪除VLAN描述字元
[Quidway]display vlan [vlan_id]                               ;檢視VLAN設定

[Quidway]stp {enable|disable}                                 ;設定生成樹,預設關閉
[Quidway]stp priority 4096                               ;設定交換機的優先順序
[Quidway]stp root {primary|secondary}                    ;設定為根或根的備份
[Quidway-Ethernet0/1]stp cost 200                        ;設定交換機埠的花費

[Quidway]link-aggregation e0/1 to e0/4 ingress|both           ; 埠的聚合
[Quidway]undo link-aggregation e0/1|all                       ;  始埠為通道號

[SwitchA-vlanx]isolate-user-vlan enable                  ;設定主vlan
[SwitchA]isolate-user-vlan <x> secondary <list>          ;設定主vlan包括的子vlan
[Quidway-Ethernet0/2]port hybrid pvid vlan <id>          ;設定vlan的pvid
[Quidway-Ethernet0/2]port hybrid pvid                    ;刪除vlan的pvid
[Quidway-Ethernet0/2]port hybrid vlan vlan_id_list untagged  ;設定無標識的vlan
如果包的vlan id與PVId一致,則去掉vlan資訊. 預設PVID=1。
所以設定PVID為所屬vlan id, 設定可以互通的vlan為untagged.
----------------------------------------

路由器命令

[Quidway]display version       ;顯示版本資訊
[Quidway]display current-configuration       ;顯示當前配置
[Quidway]display interfaces       ;顯示介面資訊
[Quidway]display ip route       ;顯示路由資訊

[Quidway]sysname aabbcc       ;更改主機名
[Quidway]super passwrod 123456       ;設定口令
[Quidway]interface serial0       ;進入介面
[Quidway-serial0]ip address <ip> <mask|mask_len>       ;配置埠IP地址
[Quidway-serial0]undo shutdown       ;啟用埠
[Quidway]link-protocol hdlc       ;繫結hdlc協議
[Quidway]user-interface vty 0 4
[Quidway-ui-vty0-4]authentication-mode password
[Quidway-ui-vty0-4]set authentication-mode password simple 222
[Quidway-ui-vty0-4]user privilege level 3
[Quidway-ui-vty0-4]quit

[Quidway]debugging hdlc all serial0       ;顯示所有資訊
[Quidway]debugging hdlc event serial0       ;除錯事件資訊
[Quidway]debugging hdlc packet serial0       ;顯示包的資訊

靜態路由:
[Quidway]ip route-static <ip><mask>{interface number|nexthop}[value][reject|blackhole]
例如:
[Quidway]ip route-static 129.1.0.0 16 10.0.0.2
[Quidway]ip route-static 129.1.0.0 255.255.0.0 10.0.0.2
[Quidway]ip route-static 129.1.0.0 16 Serial 2
[Quidway]ip route-static 0.0.0.0 0.0.0.0 10.0.0.2

動態路由:
[Quidway]rip ;設定動態路由
[Quidway]rip work ;設定工作允許
[Quidway]rip input ;設定入口允許
[Quidway]rip output ;設定出口允許
[Quidway-rip]network 1.0.0.0       ;設定交換路由網路
[Quidway-rip]network all ;設定與所有網路交換
[Quidway-rip]peer ip-address ;
[Quidway-rip]summary ;路由聚合
[Quidway]rip version 1 ;設定工作在版本1
[Quidway]rip version 2 multicast ;設版本2,多播方式
[Quidway-Ethernet0]rip split-horizon ;水平分隔

[Quidway]router id A.B.C.D ;配置路由器的ID
[Quidway]ospf enable ;啟動OSPF協議
[Quidway-ospf]import-route direct ;引入直聯路由
[Quidway-Serial0]ospf enable area <area_id> ;配置OSPF區域

標準訪問列表命令格式如下:
acl <acl-number> [match-order config|auto] ;預設前者順序匹配。
rule [normal|special]{permit|deny} [source source-addr source-wildcard|any]
例:
[Quidway]acl 10
[Quidway-acl-10]rule normal permit source 10.0.0.0 0.0.0.255
[Quidway-acl-10]rule normal deny source any

擴充套件訪問控制列表配置命令
配置TCP/UDP協議的擴充套件訪問列表:
rule {normal|special}{permit|deny}{tcp|udp}source {<ip wild>|any}destination <ip wild>|any}
[operate]

配置ICMP協議的擴充套件訪問列表:
rule {normal|special}{permit|deny}icmp source {<ip wild>|any]destination {<ip wild>|any]
[icmp-code] [logging]

擴充套件訪問控制列表操作符的含義
equal portnumber ;等於
greater-than portnumber ;大於
less-than portnumber ;小於
not-equal portnumber ;不等
range portnumber1 portnumber2 ;區間

擴充套件訪問控制列表舉例
[Quidway]acl 101
[Quidway-acl-101]rule deny souce any destination any
[Quidway-acl-101]rule permit icmp source any destination any icmp-type echo
[Quidway-acl-101]rule permit icmp source any destination any icmp-type echo-reply

[Quidway]acl 102
[Quidway-acl-102]rule permit ip source 10.0.0.1 0.0.0.0 destination 202.0.0.1 0.0.0.0
[Quidway-acl-102]rule deny ip source any destination any

[Quidway]acl 103
[Quidway-acl-103]rule permit tcp source any destination 10.0.0.1 0.0.0.0 destination-port equal ftp
[Quidway-acl-103]rule permit tcp source any destination 10.0.0.2 0.0.0.0 destination-port equal www

[Quidway]firewall enable
[Quidway]firewall default permit|deny
[Quidway]int e0
[Quidway-Ethernet0]firewall packet-filter 101 inbound|outbound

地址轉換配置舉例
[Quidway]firewall enable
[Quidway]firewall default permit
[Quidway]acl 101 ;內部指定主機可以進入e0
[Quidway-acl-101]rule deny ip source any destination any
[Quidway-acl-101]rule permit ip source 129.38.1.1 0 destination any
[Quidway-acl-101]rule permit ip source 129.38.1.2 0 destination any
[Quidway-acl-101]rule permit ip source 129.38.1.3 0 destination any
[Quidway-acl-101]rule permit ip source 129.38.1.4 0 destination any
[Quidway-acl-101]quit
[Quidway]int e0
[Quidway-Ethernet0]firewall packet-filter 101 inbound

[Quidway]acl 102 ;外部特定主機和大於1024埠的資料包允許進入S0
[Quidway-acl-102]rule deny ip source any destination any
[Quidway-acl-102]rule permit tcp source 202.39.2.3 0 destination 202.38.160.1 0
[Quidway-acl-102]rule permit tcp source any destination 202.38.160.1 0 destination-port great-than
1024
[Quidway-acl-102]quit
[Quidway]int s0
[Quidway-Serial0]firewall packet-filter 102 inbound ;設202.38.160.1是路由器出口IP。

[Quidway-Serial0]nat outbound 101 interface ;是Easy ip,將acl 101允許的IP從本接口出時變換源地址。

內部伺服器地址轉換配置命令(靜態nat):
nat server global <ip> [port] inside <ip> port [protocol] ;global_port不寫時使用inside_port
[Quidway-Serial0]nat server global 202.38.160.1 inside 129.38.1.1 ftp tcp
[Quidway-Serial0]nat server global 202.38.160.1 inside 129.38.1.2 telnet tcp
[Quidway-Serial0]nat server global 202.38.160.1 inside 129.38.1.3 www tcp

設有公網IP:202.38.160.101~202.38.160.103 可以使用。 ;對外訪問(原例題)
[Quidway]nat address-group 202.38.160.101 202.38.160.103 pool1 ;建立地址池
[Quidway]acl 1
[Quidway-acl-1]rule permit source 10.110.10.0 0.0.0.255 ;指定允許的內部網路
[Quidway-acl-1]rule deny source any
[Quidway-acl-1]int serial 0
[Quidway-Serial0]nat outbound 1 address-group pool1 ;在s0口從地址池取出IP對外訪問

[Quidway-Serial0]nat server global 202.38.160.101 inside 10.110.10.1 ftp tcp
[Quidway-Serial0]nat server global 202.38.160.102 inside 10.110.10.2 www tcp
[Quidway-Serial0]nat server global 202.38.160.102 8080 inside 10.110.10.3 www tcp
[Quidway-Serial0]nat server global 202.38.160.103 inside 10.110.10.4 smtp udp

PPP設定:
[Quidway-s0]link-protocol ppp ;預設的協議

PPP驗證:
主驗方:pap|chap
[Quidway]local-user q2 password {simple|cipher} hello ;路由器1
[Quidway]interface serial 0
[Quidway-serial0]ppp authentication-mode {pap|chap}
[Quidway-serial0]ppp chap user q1 ;pap時,沒有此句

pap被驗方:
[Quidway]interface serial 0 ;路由器2
[Quidway-serial0]ppp pap local-user q2 password {simple|cipher} hello

chap被驗方:
[Quidway]interface serial 0 ;路由器2
[Quidway-serial0]ppp chap user q2 ;自己路由器名
[Quidway-serial0]local-user q1 password {simple|cipher} hello ;對方路由器名

幀中繼frame-relay (二分冊6-61)
[q1]fr switching
[q1]int s1
[q1-Serial1]ip address 192.168.34.51 255.255.255.0
[q1-Serial1]link-protocol fr ;封裝幀中繼協議
[q1-Serial1]fr interface-type dce
[q1-Serial1]fr dlci 100
[q1-Serial1]fr inarp
[q1-Serial1]fr map ip 192.168.34.52 dlci 100

[q2]int s1
[q2-Serial1]ip address 192.168.34.52 255.255.255.0
[q2-Serial1]link-protocol fr
[q2-Serial1]fr interface-type dte
[q2-Serial1]fr dlci 100
[q2-Serial1]fr inarp
[q2-Serial1]fr map ip 192.168.34.51 dlci 100

幀中繼監測
[q1]display fr lmi-info[]interface type number]
[q1]display fr map
[q1]display fr pvc-info[serial interface-number][dlci dlci-number]
[q1]display fr dlci-switch
[q1]display fr interface
[q1]reset fr inarp-info
[q1]debugging fr all[interface type number]
[q1]debugging fr arp[interface type number]
[q1]debugging fr event[interface type number]
[q1]debugging fr lmi[interface type number]

啟動ftp服務:
[Quidway]local-user ftp password {simple|cipher} aaa service-type ftp
[Quidway]ftp server enable

----------------------------------------
使用4臺PC(pc多和少,華為路由器交換機原理是一樣的,所以這裡我只用了4臺pc),華為路由器(R2621)、交換機(S3026e)各一臺,組建一VLAN,實現虛擬網和物理網之間的連線。實現防火牆策略,和訪問控制(ACL)。

華為路由器交換機VLAN配置方案說明:四臺PC的IP地址、掩碼如下列表:
P1 192.168.1.1 255.255.255.0閘道器IP為192.168.1.5
P2 192.168.1.2 255.255.255.0閘道器IP為192.168.1.5
P3 192.168.1.3 255.255.255.0閘道器IP為192.168.1.6
P4 192.168.1.4 255.255.255.0閘道器IP為192.168.1.6
路由器上Ethernet0的IP為192.168.1.5
Ethernet1的IP為192.168.1.6
firewall設定預設為deny

華為路由器交換機VLAN配置實施命令列表:
交換機上設定,劃分VLAN:
sys
//切換到系統檢視
[Quidway]vlanenable
[Quidway]vlan2
[Quidway-vlan2]port e0/1toe0/8
[Quidway-vlan2]quit
//預設所有埠都屬於VLAN1,指定交換機的e0/1到e0/8八個埠屬於VLAN2
[Quidway]vlan3
[Quidway-vlan3]port e0/9toe0/16
[Quidway-vlan3]quit
//指定交換機的e0/9到e0/16八個埠屬於VLAN3
[Quidway]disvlanall
[Quidway]discu

華為路由器交換機VLAN設定,實現訪問控制:
[Router]interface ethernet0
[Router-Ethernet0]ip address 192.168.1.5 255.255.255.0
[Router-Ethernet0]quit
//指定ethernet0的ip
[Router]interface ethernet1
[Router-Ethernet1]ip address192.168.1.6 255.255.255.0
[Router-Ethernet1]quit
//開啟firewall,並將預設華為路由器交換機設定為deny
[Router]fireenable
[Router]firedefaultdeny
//允許192.168.1.1訪問192.168.1.3
//firewall策略可根據需要再進行新增
[Router]acl101
[Router-acl-101]rulepermitipsource192.168.1.1255.255.255.0destination192.168.1.3255.255.255.0
[Router-acl-101]quit
//啟用101規則