一、华为交换机基本配置命令
华为交换机基本配置命令大全
学习华为认证,一定要先记住华为交换机配置命令,下面我就为大家提供交换机的配置命令,希望对大家有所帮助!
一、单交换机VLAN划分
命令命令解释
system 进入系统视图
system-view 进入系统视图
quit 退到系统视图
undo vlan 20 删除vlan 20
sysname 交换机命名
disp vlan 显示vlan
vlan 20 创建vlan(也可进入vlan 20)
port e1/0/1 to e1/0/5 把端口1-5放入VLAN 20 中
disp vlan 20 显示vlan里的端口20
int e1/0/24 进入端口24
port access vlan 20 把当前端口放入vlan 20
undo port e1/0/10 表示删除当前VLAN端口10
disp curr 显示当前配置
二、配置交换机支持TELNET
system 进入系统视图
sysname 交换机命名
int vlan 1 进入VLAN 1
ip address 192.168.3.100 255.255.255.0 配置IP地址
user-int vty 0 4 进入虚拟终端
authentication-mode password (aut password) 设置口令模式
set authentication password simple 222 (set aut pass sim 222) 设置口令
user privilege level 3(use priv lev 3) 配置用户级别
disp current-configuration (disp cur) 查看当前配置
disp ip int 查看交换机VLAN IP配置
删除配置必须退到用户模式
reset saved-configuration(reset saved) 删除配置
reboot 重启交换机
三、跨交换机VLAN的通讯
在sw1上:
vlan 10 建立VLAN 10
int e1/0/5 进入端口5
port access vlan 10 把端口5加入vlan 10
vlan 20 建立VLAN 20
int e1/0/15 进入端口15
port access vlan 20 把端口15加入VLAN 20
int e1/0/24 进入端口24
port link-type trunk 把24端口设为TRUNK端口
port trunk permit vlan all 同上
在SW2上:
vlan 10 建立VLAN 10
int e1/0/20 进入端口20
port access vlan 10 把端口20放入VLAN 10
int e1/0/24 进入端口24
port link-type trunk 把24端口设为TRUNK端口
port trunk permit vlan all (port trunk permit vlan 10 只能为vlan 10使用)24端口为所有VLAN使用
disp int e1/0/24 查看端口24是否为TRUNK
undo port trunk permit vlan all 删除该句
四、路由的配置命令
system 进入系统模式
sysname 命名
int e1/0 进入端口
ip address 192.168.3.100 255.255.255.0 设置IP
undo shutdown 打开端口
disp ip int e1/0 查看IP接口情况
disp ip int brief 查看IP接口情况
user-int vty 0 4 进入口令模式
authentication-mode password(auth pass) 进入口令模式
set authentication password simple 222 37 设置口令
user privilege level 3 进入3级特权
save 保存配置
reset saved-configuration 删除配置(用户模式下运行)
undo shutdown 配置远程登陆密码
int e1/4
ip route 192.168.3.0(目标网段) 255.255.255.0 192.168.12.1(下一跳:下一路由器的接口) 静态路由
ip route 0.0.0.0 0.0.0.0 192.168.12.1 默认路由
disp ip rout 显示路由列表
华3C AR-18
E1/0(lan1-lan4)
E2/0(wan0)
E3/0(WAN1)
路由器连接使用直通线。wan0接wan0或wan1接wan1
计算机的网关应设为路由器的.接口地址。
五、三层交换机配置VLAN-VLAN通讯
sw1(三层交换机):
system 进入视图
sysname 命名
vlan 10 建立VLAN 10
vlan 20 建立VLAN 20
int e1/0/20 进入端口20
port access vlan 10 把端口20放入VLAN 10
int e1/0/24 进入24端口
port link-type trunk 把24端口设为TRUNK端口
port trunk permit vlan all (port trunk permit vlan 10 只能为vlan 10使用)24端口为所有VLAN使用
sw2:
vlan 10
int e1/0/5
port access vlan 10
int e1/0/24
port link-type trunk 把24端口设为TRUNK端口
port trunk permit vlan all (port trunk permit vlan 10 只能为vlan 10使用)24端口为所有VLAN使用
sw1(三层交换机):
int vlan 10 创建虚拟接口VLAN 10
ip address 192.168.10.254 255.255.255.0 设置虚拟接口VLAN 10的地址
int vlan 20 创建虚拟接口VLAN 20
ip address 192.168.20.254 255.255.255.0 设置虚拟接口IP VLAN 20的地址
注意:vlan 10里的计算机的网关设为 192.168.10.254
vlan 20里的计算机的网关设为 192.168.20.254
六、动态路由RIP
R1:
int e1/0 进入e1/0端口
ip address 192.168.3.1 255.255.255.0 设置IP
int e2/0 进入e2/0端口
ip adress 192.168.5.1 255.255.255.0 设置IP
rip 设置动态路由
二、交换机的基本命令
交换机的基本命令有以下四种:
一、模式命令:
1. 用户模式:Switch>
2. 特权模式:Switch>enable
Switch#
3. 全局配置模式:Switch#config terminal
Switch(config)#
4. 接口配置模式:Switch(config)#interface fastethernet0/1
Switch(config-if)#
5. Line模式:Switch(config)#line console 0
Switch(config-line)#
二、特权模式下的命令:
1. 查看机MAC地址:Switch#show mac-address-table
2. 发现(CDP):
Switch#show cdp
Switch#show cdp interface fastethernet0/1
Switch#show cdp neighbors
Switch#show cdp neighbors detail
Switch#show cdp entry
3. 保存机配置:
Switch#copy running-config startup-config或者Switch#write
4. 恢复交换机出厂值:
Switch#erase startup-config
Switch#reload
三、全局配置模式下的命令:
1. 配置主机名:Switch(config)#hostname Sw1
Sw1(config)#
2、 设置登陆台密码:Switch(config)#line console 0
Switch(config-line)#password 密码
Switch(config-line)#login
3. 使能口令:Switch(config)#enable Password 密码
4. 加密保存的使能口令:Switch(config)#enable secret 密码
5. 配置IP地址:
Switch(config)#interface vlan 1
Switch(config-if)#ip address IP地址 网关
Switch(config-if)#no shutdown
6. 配置交换机网关:Switch(config)#ip default-gateway 网关
四、VLAN配置命令:
1. 创建vlan命令:
a) 全局配置模式下:
Switch(config)#vlan 2
Switch(config)#name v2
Switch(config)#mtu 数值
Switch(config)#end
b) Vlan数据库下:
Switch#vlan database
Switch#vlan 2 name v2
Switch#vlan 2 mut 数值
Switch#exit
2. 删除vlan命令:
a) 全局配置模式下:
Switch(config)#no vlan 2
Switch(config)#end
b) Vlan数据库下:
Switch#no vlan 2 name v2
Switch#exit
3. 在vlan中添加端口:
Switch#config terminal
Switch(config)#interface f0/1(端口)
Switch(config-if)#Switchport mode access
Switch(config-if)#switchport access vlan 2
Switch(config-if)#end
一次将多个端口添加到vlan中:
Switch#config terminal
Switch(config)#interface range f0/1 - 5(端口)
Switch(config-if)#switchport access vlan 2
Switch(config-if)#end
注:switch#show vlan biref(查看vlan信息)
4. 配置vlan trunk:
1. 配置接口为trunk命令:
Switch(config)# interface f0/1(端口)
Switch(config-if)#Switchport mode trunk
2. 配置接口为动态协商模式的命令:
Switch(config)# interface f0/1(端口)
Switch(config-if)#switchport mode dynamic desirable/auto
3. 从trunk中删除vlan:
Switch(config)# interface f0/1(端口)
Switch(config-if)#Switchport trunk allowed vlan remove 2
4. 在trunk中添加vlan:
Switch(config)# interface f0/1(端口)
Switch(config-if)#Switchport trunk allowed vlan add 2
三、交换机配置命令
1、交换机配置命令,英文名Switchboard Command,是一种计算机语言,用来控制交换机的语言。
2、交换机的配置方式
(1)使用控制(console)端口,使用超级终端配置交换机
console是一个用来连接配置终端的异步串行接口,其接口标准是RJ-45。
(2)使用telnet配置交换机
用远程登陆telnet对交换机进行配置,是一种远程管理设备的常用方式。
(3)使用浏览器配置交换机
该方式可以对交换机进行配置,也可以修改交换机的参数,以便对交换机进行管理,还可以查看交换机的运行状态。
3、显示交换表命令的使用方法
(1)大中型交换机
在交换机超级用户模式下输入命令:Cisco-4000# show cam dynamic。
(2)小型交换机
在交换机超级用户模式下输入命令: Cisco-3548# show mac-address-table。
四、华为交换机的基本配置命令
华为交换机的常用命令:
进入系统视图——sy
交换机命名——sysname huawei
返回上一级——quit(q)
直接返回视图——return(ret)
保存配置——save(sa)
重启设备——reboot
查看配置——display current-configuration(dis cur)
查看VLAN——dis vlan
查看端口——dis int g0/0/1
新建VLAN——vlan 100
删除vlan——undo vlan 100
进入vlan——int vlan 100
将端口放入vlan——port g0/0/1
删除vlan中的端口——undo port g0/0/1
配置vlan管理地址——ip address
进入端口——int g0/0/1
设置端口为access模式——port link-type access
将端口放入vlan中——port default vlan 100
设置端口为trunk模式——port link-type trunk
删除端口配置——undo port link-type
擦除旧的配置文件——reset saved-configuration
配置telnet远程(其中一种)aaa
开启telnet服务——telnet server enable
限制用户数量登陆——user-interface vty 0 4(0.1.2.3.4共五个用户)
设置认证模式——authenticatioon-mode aaa
quit
进入aaa认证模式——aaa
设置登陆用户和密码——local-user admin pass simple huawei123(telnet名称admin,密码huawei123)
设置远程用户服务类型——local-user admin service-type telnet
设置远程用户级别——local-user admin privilege level 3
quit
save
五、交换机基本配置命令
一、单交换机VLAN划分
命令 命令解释
system 进入系统视图
system-view 进入系统视图
quit 退到系统视图
undo vlan 20 删除vlan 20
sysname 交换机命名
disp vlan 显示vlan
vlan 20 创建vlan(也可进入vlan 20)
port e1/0/1 to e1/0/5 把端口1-5放入VLAN 20 中
disp vlan 20 显示vlan里的端口20
int e1/0/24 进入端口24
port access vlan 20 把当前端口放入vlan 20
undo port e1/0/10 表示删除当前VLAN端口10
disp curr 显示当前配置
二、配置交换机支持TELNET
system 进入系统视图
sysname 交换机命名
int vlan 1 进入VLAN 1
ip address 192.168.3.100 255.255.255.0 配置IP地址
user-int vty 0 4 进入虚拟终端
authentication-mode password (aut password) 设置口令模式
set authentication password simple 222 (set aut pass sim 222) 设置口令
user privilege level 3(use priv lev 3) 配置用户级别
disp current-configuration (disp cur) 查看当前配置
disp ip int 查看交换机VLAN IP配置
删除配置必须退到用户模式
reset saved-configuration(reset saved) 删除配置
reboot 重启交换机
三、跨交换机VLAN的通讯
在sw1上:
vlan 10 建立VLAN 10
int e1/0/5 进入端口5
port access vlan 10 把端口5加入vlan 10
vlan 20 建立VLAN 20
int e1/0/15 进入端口15
port access vlan 20 把端口15加入VLAN 20
int e1/0/24 进入端口24
port link-type trunk 把24端口设为TRUNK端口
port trunk permit vlan all 同上
在SW2上:
vlan 10 建立VLAN 10
int e1/0/20 进入端口20
port access vlan 10 把端口20放入VLAN 10
int e1/0/24 进入端口24
port link-type trunk 把24端口设为TRUNK端口
port trunk permit vlan all (port trunk permit vlan 10 只能为vlan
10使用)24端口为所有VLAN使用
disp int e1/0/24 查看端口24是否为TRUNK
undo port trunk permit vlan all 删除该句
四、路由的配置命令
system 进入系统模式
sysname 命名
int e1/0 进入端口
ip address 192.168.3.100 255.255.255.0 设置IP
undo shutdown 打开端口
disp ip int e1/0 查看IP接口情况
disp ip int brief 查看IP接口情况
user-int vty 0 4 进入口令模式
authentication-mode password(auth pass) 进入口令模式
set authentication password simple 222 37 设置口令
user privilege level 3 进入3级特权
save 保存配置
reset saved-configuration 删除配置(用户模式下运行)
undo shutdown 配置远程登陆密码
int e1/4
ip route 192.168.3.0(目标网段) 255.255.255.0 192.168.12.1(下一跳:下一路由器的接口) 静态路由
ip route 0.0.0.0 0.0.0.0 192.168.12.1 默认路由
disp ip rout 显示路由列表
华3C AR-18
E1/0(lan1-lan4)
E2/0(wan0)
E3/0(WAN1)
路由器连接使用直通线。wan0接wan0或wan1接wan1
计算机的网关应设为路由器的接口地址。
五、三层交换机配置VLAN-VLAN通讯
sw1(三层交换机):
system 进入视图
sysname 命名
vlan 10 建立VLAN 10
vlan 20 建立VLAN 20
int e1/0/20 进入端口20
port access vlan 10 把端口20放入VLAN 10
int e1/0/24 进入24端口
port link-type trunk 把24端口设为TRUNK端口
port trunk permit vlan all (port trunk permit vlan 10 只能为vlan
10使用)24端口为所有VLAN使用
sw2:
vlan 10
int e1/0/5
port access vlan 10
int e1/0/24
port link-type trunk 把24端口设为TRUNK端口
port trunk permit vlan all (port trunk permit vlan 10 只能为vlan
10使用)24端口为所有VLAN使用
sw1(三层交换机):
int vlan 10 创建虚拟接口VLAN 10
ip address 192.168.10.254 255.255.255.0 设置虚拟接口VLAN 10的地址
int vlan 20 创建虚拟接口VLAN 20
ip address 192.168.20.254 255.255.255.0 设置虚拟接口IP VLAN 20的地址
注意:vlan 10里的计算机的网关设为 192.168.10.254
vlan 20里的计算机的网关设为 192.168.20.254
六、动态路由RIP
R1:
int e1/0 进入e1/0端口
ip address 192.168.3.1 255.255.255.0 设置IP
int e2/0 进入e2/0端口
ip adress 192.168.5.1 255.255.255.0 设置IP
rip 设置动态路由
network 192.168.5.0 定义IP
network 192.168.3.0 定义IP
disp ip rout 查看路由接口
R2:
int e1/0 进入e1/0端口
ip address 192.168.4.1 255.255.255.0 设置IP
int e2/0 进入e2/0端口
ip adress 192.168.5.2 255.255.255.0 设置IP
rip 设置动态路由
network 192.168.5.0 定义IP
network 192.168.4.0 定义IP
disp ip rout 查看路由接口
(注意:两台PC机的网关设置PC1 IP:192.168.3.1 PC2 IP:192.168.4.1)
七、IP访问列表
int e1/0
ip address 192.168.3.1 255.255.255.0
int e2/0
ip address 192.168.1.1 255.255.255.0
int e3/0
ip address 192.168.2.1 255.255.255.0
acl number 2001 (2001-2999属于基本的访问列表)
rule 1 deny source 192.168.1.0 0.0.0.255 (拒绝地址192.168.1.0网段的数据通过)
rule 2 permit source 192.168.3.0 0.0.0.255(允许地址192.168.3.0网段的数据通过)
以下是把访问控制列表在接口下应用:
firewall enable
firewall default permit
int e3/0
firewall packet-filter 2001 outbound
disp acl 2001 显示信息
undo acl number 2001 删除2001控制列表
扩展访问控制列表
acl number 3001
rule deny tcp source 192.168.3.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
destination-port eq ftp
必须在r-acl-adv-3001下才能执行
rule permit ip source an destination any (rule permit ip)
int e3/0
firewall enable 开启防火墙
firewall packet-filter 3001 inbound
必须在端口E3/0下才能执行
八、命令的标准访问IP列表(三层交换机):
允许A组机器访问服务器内资料,不允许访问B组机器(服务器没有限制)
sys
vlan 10
name server
vlan 20
name teacher
vlan 30
name student
int e1/0/5
port access vlan 10
int e1/0/10
port access vlan 20
int e1/0/15
port access vlan 30
int vlan 10
ip address 192.168.10.1 255.255.255.0
undo sh
int vlan 20
ip address 192.168.20.1 255.255.255.0
int vlan 30
ip address 192.168.30.1 255.255.255.0
acl number 2001
rule 1 deny source 192.168.30.0 0.0.0.255
rule 2 permit source any
disp acl 2001 查看2001列表
int e1/0/10
port access vlan 20
packet-filter outbound ip-group 2001 rule 1
出口
九、允许A机器访问B机器的FTP但不允许访问WWW,C机器没有任何限制。
vlan 10
vlan 20
vlan 30
int e1/0/5
port access vlan 10
int e1/0/10
port access vlan 20
int e1/0/15
port access vlan 30
int vlan 10
ip address 192.168.10.1 255.255.255.0
undo sh
int vlan 20
ip address 192.168.20.1 255.255.255.0
int vlan 30
ip address 192.168.30.1 255.255.255.0
acl number 3001
rule 1 deny tcp source 192.168.30.0 0.0.0.255 destination 192.168.10.0
0.0.0.255 destination-port eq www
int e1/0/15
packet-filter inbound ip-group 3001 rule 1
进口
十、NAT地址转换(单一静态一对一地址转换)
R1:
sys
sysname R1
int e1/0
ip address 192.168.3.1 255.255.255.0
int e2/0
ip address 192.1.1.1 255.255.255.0
R2:
sys
sysname R2
int e2/0
ip address 192.1.1.2 255.255.255.0
int e1/0
ip address 10.80.1.1 255.255.255.0
回到R1:
nat static 192.168.3.1 192.1.1.1
int e2/0
nat outbound static
ip route 0.0.0.0 0.0.0.0 192.1.1.2
十一、NAT内部整网段地址转换
R1:
sys
sysname R1
int e1/0
ip address 192.168.3.1 255.255.255.0
int e2/0
ip address 192.1.1.1 255.255.255.0
acl number 2008
rule 0 permit source 192.168.3.0 0.0.0.255
rule 1 deny
quit
int e2/0
nat outbound 2008
quit
ip route-static 0.0.0.0 0.0.0.0 192.1.1.2 preference 60