一、设备初始化
1. 连接路由器
Console 串口连接
使用 SecureCRT、PuTTY 或 Xshell 连接串口
串口参数:
复制编辑
波特率:9600 数据位:8 停止位:1 校验位:无
SSH 远程登录(如果已配置 IP)
shell
复制编辑
ssh 用户名@路由器IP
进入系统视图
shell
复制编辑
system-view
说明:华为设备默认在
>
用户模式,执行system-view
进入#
系统模式。
二、基础配置
1. 设置设备名称
shell
复制编辑
system-view sysname Huawei-Router
解释:
sysname Huawei-Router
:设置路由器名称。
2. 配置管理 IP
shell
复制编辑
interface GigabitEthernet 0/0/0 ip address 192.168.1.1 255.255.255.0 undo shutdown quit
解释:
interface GigabitEthernet 0/0/0
:进入 GE0/0/0 端口(根据实际情况修改)。
ip address 192.168.1.1 255.255.255.0
:配置 IP 地址。
undo shutdown
:开启接口(华为默认接口关闭)。
3. 配置默认路由
shell
复制编辑
ip route-static 0.0.0.0 0.0.0.0 192.168.1.254
解释:
ip route-static
:配置静态路由。
0.0.0.0 0.0.0.0 192.168.1.254
:默认流量走192.168.1.254
(网关)。
三、远程管理配置
1. 启用 Telnet
shell
复制编辑
user-interface vty 0 4 authentication-mode password set authentication password cipher Huawei@123 protocol inbound telnet quit
解释:
user-interface vty 0 4
:进入远程管理会话(支持 5 个会话)。
set authentication password cipher Huawei@123
:设置 Telnet 密码。
protocol inbound telnet
:允许 Telnet 连接。
2. 启用 SSH
shell
复制编辑
sysname Huawei rsa local-key-pair create user-interface vty 0 4 authentication-mode aaa protocol inbound ssh quit aaa local-user admin password cipher Huawei@123 local-user admin privilege level 15 local-user admin service-type ssh quit
解释:
rsa local-key-pair create
:生成 SSH 密钥。
authentication-mode aaa
:使用 AAA 认证。
local-user admin
:创建 SSH 用户admin
。
local-user admin privilege level 15
:设置管理权限。
四、WAN 口配置(PPPoE 拨号)
shell
复制编辑
interface GigabitEthernet 0/0/0 pppoe-client dial-bundle 1 quit dialer bundle 1 ppp chap user huawei ppp chap password cipher Huawei@123 dialer number *99# quit
解释:
pppoe-client dial-bundle 1
:配置 PPPoE 拨号。
ppp chap user huawei
:设置认证用户名。
ppp chap password cipher Huawei@123
:设置认证密码。
五、NAT 配置(用于上网)
1. 配置 NAT
shell
复制编辑
interface GigabitEthernet 0/0/0 nat outbound 3000 quit acl number 3000 rule 5 permit source 192.168.1.0 0.0.0.255 quit
解释:
nat outbound 3000
:在外网口上启用 NAT 规则。
acl number 3000
:创建 ACL 3000。
rule 5 permit source 192.168.1.0 0.0.0.255
:允许 192.168.1.0/24 源地址出网。
六、VLAN & 路由配置
1. 配置 VLAN
shell
复制编辑
vlan batch 10 20 30 interface GigabitEthernet 0/0/1 port link-type access port default vlan 10 quit
解释:
vlan batch 10 20 30
:创建 VLAN 10、20、30。
port link-type access
:设置端口为 Access 模式。
port default vlan 10
:加入 VLAN 10。
2. 配置 VLAN 之间的三层路由
shell
复制编辑
interface Vlanif10 ip address 192.168.10.1 255.255.255.0 quit interface Vlanif20 ip address 192.168.20.1 255.255.255.0 quit
解释:
Vlanif10
/Vlanif20
:在路由器上启用 VLAN 10 和 VLAN 20 的三层路由。
七、ACL 访问控制
1. 阻止特定 IP 访问外网
shell
复制编辑
acl number 3001 rule 10 deny ip source 192.168.1.100 0 rule 20 permit ip quit interface GigabitEthernet 0/0/0 traffic-filter outbound acl 3001 quit
解释:
rule 10 deny ip source 192.168.1.100 0
:禁止192.168.1.100
访问外网。
rule 20 permit ip
:其他流量允许。
traffic-filter outbound acl 3001
:应用 ACL 3001。
八、时间同步(NTP)
shell
复制编辑
ntp-service enable ntp-service unicast-server 192.168.1.100 clock timezone Beijing add 08:00:00
解释:
ntp-service enable
:开启 NTP 服务。
ntp-service unicast-server
:指定 NTP 服务器。
clock timezone
:设置北京时间。
九、保存配置
shell
复制编辑
save
解释:保存当前配置,防止重启丢失。
总结
华为路由器的基础配置包括:
设备初始化
接口 & IP 配置
远程管理(Telnet / SSH)
WAN 口 & NAT
VLAN 配置
ACL 访问控制
NTP 时间同步
配置保存