一、物理层(Physical Layer)
1. 接口基本配置
interface GigabitEthernet 0/0/1
speed {10 | 100 | 1000 | auto}
duplex {half | full | auto}
flow-control
port link-type {access | trunk}
undo shutdown
description TO_CORE_SWITCH
negotiation auto
mtu 9216
loopback {internal | remote}
2. 物理状态查看
display interface GigabitEthernet 0/0/1
display interface brief
display transceiver interface GigabitEthernet 0/0/1
display counters interface GigabitEthernet 0/0/1
display interface status
display interface description
3. 接口高级配置
interface GigabitEthernet 0/0/1
port-security enable
port-security max-mac-count 5
port-security protect-action {shutdown | restrict | protect}
port-security mac-address sticky
storm-control broadcast pps 1000
storm-control multicast pps 500
storm-control unknown-unicast pps 300
4. 接口诊断命令
reset counters interface GigabitEthernet 0/0/1
test transceiver loopback GigabitEthernet 0/0/1
display error-down interface GigabitEthernet 0/0/1
display interface trap log GigabitEthernet 0/0/1
二、数据链路层(Data Link Layer)
1. VLAN配置
vlan batch 10 20 30
interface GigabitEthernet 0/0/1
port link-type access
port default vlan 10
interface GigabitEthernet 0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20 30
port trunk pvid vlan 10
interface GigabitEthernet 0/0/3
port link-type hybrid
port hybrid tagged vlan 10 20
port hybrid untagged vlan 30
2. QinQ配置
基本QinQ
vlan batch 100 200
interface GigabitEthernet 0/0/1
port link-type dot1q-tunnel
port default vlan 100
interface GigabitEthernet 0/0/2
port link-type trunk
port trunk allow-pass vlan 100 200
灵活QinQ
qinq vlan-translation enable
interface GigabitEthernet 0/0/1
port link-type hybrid
port hybrid tagged vlan 10 20
port hybrid untagged vlan 100
qinq vlan-translation enable
qinq vlan 10 translate-to vlan 100
3. 生成树协议(STP/RSTP/MSTP)
stp mode mstp
stp region-configuration
region-name ENSP
instance 1 vlan 10
instance 2 vlan 20
active region-configuration
interface GigabitEthernet 0/0/1
stp edged-port enable
stp bpdu-protection
stp root-protection
stp loop-protection
stp tc-protection
stp port-priority 64
stp cost 100
4. 链路层协议(PPP/HDLC)
interface Serial 0/0/0
link-protocol ppp
ppp authentication-mode chap
ppp chap user admin
ppp chap password cipher Admin@123
ppp pap local-user admin password cipher Admin@123
ppp ipcp dns request
ppp ipcp address accept
5. LACP动态聚合
interface Eth-Trunk 1
mode lacp-static
max active-linknumber 4
min active-linknumber 2
lacp preempt enable
lacp period fast
interface GigabitEthernet 0/0/1
eth-trunk 1
lacp priority 100
display eth-trunk brief
display lacp statistics interface Eth-Trunk 1
三、网络层(Network Layer)
1. IP地址配置
interface GigabitEthernet 0/0/1
ip address 192.168.1.1 255.255.255.0
ipv6 enable
ipv6 address 2001:db8:1::1/64
ipv6 address auto-config
ip dhcp-snooping trust
2. 静态路由
ip route-static 10.0.0.0 255.0.0.0 192.168.1.254
ip route-static 0.0.0.0 0.0.0.0 192.168.1.254
ip route-static 10.0.0.0 255.0.0.0 192.168.2.1 preference 100
ip route-static 10.0.0.0 255.0.0.0 192.168.1.254
ip route-static 10.0.0.0 255.0.0.0 192.168.2.254
route-policy STATIC-POLICY permit node 10
if-match ip-prefix STATIC-ROUTE
apply preference 80
ip route-static 10.0.0.0 255.0.0.0 192.168.1.254 route-policy STATIC-POLICY
3. 动态路由协议
OSPFv3配置
ipv6 router ospf 1
router-id 1.1.1.1
area 0.0.0.0
network 2001:db8:1::0/64
authentication-mode md5 1 cipher OSPFv3@123
ospf 1
silent-interface GigabitEthernet 0/0/1
default-route-advertise always metric 100
ase-filter 10.0.0.0 255.0.0.0 export deny
RIPng配置
ipv6 router rip RIPNG
network 2001:db8:1::0/64
timer update 30 expire 180 garbage-collect 120
authentication-mode simple text RIPNG@123
BGP配置
bgp 65001
router-id 1.1.1.1
peer 10.0.0.2 as-number 65002
peer-group EBGP
as-number 65002
connect-interface LoopBack0
peer 10.0.0.2 inherit peer-group EBGP
ipv4-family unicast
peer 10.0.0.2 enable
import-route ospf 1
route-policy BGP-POLICY export peer 10.0.0.2
route-policy BGP-POLICY permit node 10
if-match ip-prefix CUSTOM-ROUTES
apply community 100:100 additive
4. MPLS基础配置
mpls lsr-id 1.1.1.1
mpls
mpls ldp
interface GigabitEthernet 0/0/1
mpls
mpls ldp
mpls ldp
timer hold 90
timer hello 10
advertise-route-id-extension
5. IPv6静态路由
ipv6 route-static 2001:db8:2::/64 2001:db8:1::2
ipv6 route-static ::/0 2001:db8:1::1
ipv6 route-static 2001:db8:3::/64 Null0
四、传输层(Transport Layer)
1. TCP/UDP过滤
acl number 3000
rule 10 permit tcp source 192.168.1.0 0.0.0.255 destination 10.0.0.0 0.0.0.255 destination-port eq 80
rule 20 permit udp source 192.168.1.0 0.0.0.255 destination 10.0.0.0 0.0.0.255 destination-port eq 53
rule 30 deny ip source any destination any
interface GigabitEthernet 0/0/1
traffic-filter inbound acl 3000
2. 端口镜像
observe-port 1 interface GigabitEthernet 0/0/2
interface GigabitEthernet 0/0/1
mirror to observe-port 1 both
traffic-mirror session 1
mirror-source interface GigabitEthernet 0/0/1 both
mirror-destination interface GigabitEthernet 0/0/2
3. 流镜像配置
acl number 3000
rule 10 permit ip source 192.168.1.0 0.0.0.255 destination 10.0.0.0 0.0.0.255
observe-port 1 interface GigabitEthernet 0/0/2
interface GigabitEthernet 0/0/1
traffic-mirror inbound acl 3000 observe-port 1
4. 会话管理
display tcp status
display udp statistics
display session table all
reset session all
五、会话层(Session Layer)
1. Telnet/SSH配置
stelnet server enable
rsa local-key-pair create
user-interface vty 0 4
authentication-mode aaa
protocol inbound ssh
idle-timeout 30 0
history-command max-size 50
2. GRE隧道配置
interface Tunnel0/0/0
ip address 10.0.0.1 255.255.255.0
tunnel-protocol gre
source GigabitEthernet 0/0/1
destination 192.168.2.1
gre key 12345
keepalive
ipsec policy GRE-IPSEC 10 isakmp
security acl 3001
proposal PROPOSAL1
sa duration time-based 3600
interface Tunnel0/0/0
ipsec policy GRE-IPSEC
六、表示层(Presentation Layer)
1. 数据加密
ssl enable
ssl profile default
server-certificate default
authentication-mode aaa
gateway-interface GigabitEthernet 0/0/1
client-ip-pool 192.168.200.0 255.255.255.0
dns-server 8.8.8.8 114.114.114.114
2. 文件传输
tftp-server enable
tftp-server directory flash:/tftp/
tftp-server timeout 5
tftp-server max-thread 10
scp server enable
user-interface vty 0 4
protocol inbound scp
3. SSL证书配置
ssl certificate create self-signed
common-name ENSP-SW
organization-unit Network
organization Huawei
locality Shenzhen
state Guangdong
country CN
validity 365
ssl certificate import pem certificate-file cert.pem private-key-file key.pem
七、应用层(Application Layer)
1. DHCP服务
dhcp enable
ip pool VLAN10
network 192.168.1.0 mask 255.255.255.0
gateway-list 192.168.1.1
dns-list 8.8.8.8 114.114.114.114
lease day 3
excluded-ip-address 192.168.1.1 192.168.1.10
option 43 sub-option 3 ip-address 192.168.1.1
interface GigabitEthernet 0/0/1
dhcp select global
2. DNS服务
dns resolve
dns server 8.8.8.8
dns server 114.114.114.114
ip host www.example.com 192.168.1.100
ip host ftp.example.com 192.168.1.101
dns cache-size 1000
dns timeout 5
3. SNMP配置
snmp-agent
snmp-agent sys-info version v3
snmp-agent sys-info contact [email protected]
snmp-agent sys-info location DataCenter
snmp-agent group v3 network-group privacy read-view network-view write-view network-view notify-view network-view
snmp-agent usm-user v3 admin network-group authentication-mode sha authentication-password Admin@123 privacy-mode aes128 privacy-password Privacy@123
snmp-agent view network-view included .1.3.6.1
4. HTTP服务
http server enable
http secure-server enable
http server port 8080
http server timeout 120
http server max-connections 1000
八、高级特性
1. ACL与QoS
time-range work-time
periodic weekdays 09:00 to 18:00
acl number 3000
rule 10 permit tcp source 192.168.1.0 0.0.0.255 destination 10.0.0.0 0.0.0.255 time-range work-time
traffic classifier VIDEO
if-match acl 3000
if-match packet-length greater-than 1000
traffic behavior VIDEO
bandwidth cir 102400
remark dscp ef
car cir 80000 pir 100000
qos policy VIDEO-POLICY
classifier VIDEO behavior VIDEO
2. NAT配置
nat static global 202.100.1.1 inside 192.168.1.10
acl number 2000
rule 10 permit source 192.168.1.0 0.0.0.255
nat address-group 1
address 202.100.1.100 202.100.1.110
interface GigabitEthernet 0/0/2
nat outbound 2000 address-group 1
interface GigabitEthernet 0/0/2
nat outbound 2000 address-group 1 no-pat
3. 冗余协议(VRRP)
interface Vlanif 10
ip address 192.168.1.254 255.255.255.0
vrrp vrid 1 virtual-ip 192.168.1.254
vrrp vrid 1 priority 200
vrrp vrid 1 preempt-mode timer delay 60
vrrp vrid 1 track interface GigabitEthernet 0/0/1 reduced 30
4. 防火墙配置
firewall zone trust
add interface GigabitEthernet 0/0/1
firewall zone untrust
add interface GigabitEthernet 0/0/2
firewall zone dmz
add interface GigabitEthernet 0/0/3
security-policy
rule name trust-to-untrust
source-zone trust
destination-zone untrust
source-address 192.168.1.0 0.0.0.255
service icmp
service tcp destination-port 80 443
action permit
rule name untrust-to-dmz
source-zone untrust
destination-zone dmz
service tcp destination-port 80 443 22
action permit
九、故障排除命令
1. 连通性测试
ping 192.168.1.1
ping -c 100 -s 1472 192.168.1.1
tracert 192.168.1.1
traceroute 192.168.1.1 verbose
telnet 192.168.1.1 23
ssh 192.168.1.1
2. 路由表查看
display ip routing-table
display ip routing-table protocol ospf
display bgp routing-table
display route-policy
display ip prefix-list
3. ARP表查看
display arp
display arp interface GigabitEthernet 0/0/1
display arp all
reset arp all
4. 协议状态查看
display ospf peer
display bgp peer
display pppoe-client session
display mpls ldp session
display vlan brief
display stp brief
十、综合应用示例
企业网络典型配置
sysname CORE_SWITCH
vlan batch 10 20 30
interface GigabitEthernet 0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20 30
ospf 1 router-id 10.1.1.1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
network 192.168.10.0 0.0.0.255
interface Vlanif 10
ip address 192.168.10.1 255.255.255.0
interface Vlanif 20
ip address 192.168.20.1 255.255.255.0
acl number 3000
rule 10 permit ip source 192.168.10.0 0.0.0.255 destination 10.0.0.0 0.0.0.255
interface GigabitEthernet 0/0/1
firewall packet-filter 3000 inbound
广域网接入配置
interface Dialer0
link-protocol ppp
ppp chap user broadband
ppp chap password cipher Broad@123
ip address ppp-negotiate
dialer user broadband
dialer-group 1
ip route-static 0.0.0.0 0.0.0.0 Dialer0
acl number 2000
rule 10 permit source 192.168.1.0 0.0.0.255
interface Dialer0
nat outbound 2000
无线控制器配置
interface Vlanif 100
ip address 192.168.100.1 255.255.255.0
capwap source interface Vlanif 100
wlan ac
reg-zone cn
ap-group default
radio 0
channel 1 6 11
max-power 20
radio 1
channel 36 40 44 48
max-power 20
wlan service-template 1 crypto
ssid WLAN-TEST
security wpa2-psk aes pass-phrase Password@123
service-template enable