实验室交换机:配置记录


网络配置操作指南:VLAN 添加与防火墙配置

一、VLAN 配置流程

1. 创建 VLAN

1
2
3
4
# 在实验室交换机 awifi_lab_sw6 上创建 VLAN 700
<awifi_lab_sw6> system-view
[awifi_lab_sw6] vlan 700
[awifi_lab_sw6-vlan700] quit

2. 配置核心交换机 VLAN 接口

1
2
3
4
5
# 在核心交换机 2F-CORE 上配置 VLAN 700 接口
<2F-CORE> system-view
[2F-CORE] interface Vlan-interface 700
[2F-CORE-Vlan-interface700] ip address 192.168.166.254 24
[2F-CORE-Vlan-interface700] quit

3. 修改接入端口配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 在实验室汇聚交换机 Awifi_lab_sw_4 上查找目标 MAC 地址
<Awifi_lab_sw_4> display mac-address | include 0b08

# 修改端口配置(以 GE1/0/17 为例)
<Awifi_lab_sw_4> system-view
[Awifi_lab_sw_4] interface GigabitEthernet1/0/17
[Awifi_lab_sw_4-GigabitEthernet1/0/17]d th
#
interface GigabitEthernet1/0/17
description To_kolla_compute02_wangka1_38.23
port access vlan 303
#
return

[Awifi_lab_sw_4-GigabitEthernet1/0/17] port access vlan 700
[Awifi_lab_sw_4-GigabitEthernet1/0/17] description 192.168.166.254_gateway
[Awifi_lab_sw_4-GigabitEthernet1/0/17] quit

4. 验证端口配置

1
2
3
4
5
6
7
8
9
# 检查端口配置是否生效
[Awifi_lab_sw_4-GigabitEthernet1/0/17]d th
interface GigabitEthernet1/0/17
description To_kolla_compute02_wangka1_38.23
port access vlan 700
#
return

[Awifi_lab_sw_4] display current-configuration interface GigabitEthernet1/0/17

5、服务器配置IP 改路由

1. CentOS 系统配置

1
2
3
4
5
6
7
8
9
10
11
12
13
# 编辑网络配置文件
vi /etc/sysconfig/network-scripts/ifcfg-eth0

# 配置示例
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.166.100
NETMASK=255.255.255.0
GATEWAY=192.168.166.254
ONBOOT=yes

# 重启网络服务
systemctl restart network

2. Ubuntu 系统配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 编辑 Netplan 配置文件
vi /etc/netplan/01-netcfg.yaml

# 配置示例
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.166.100/24
routes:
- to: default
via: 192.168.166.254
nameservers:
addresses: [8.8.8.8, 8.8.4.4]

# 应用配置
netplan apply

3. 验证网络连接

1
2
3
4
5
# 查看路由表
ip route show

# 测试网关连通性
ping 192.168.166.254

6、防火墙配置

1. 登录防火墙

1
2
3
4
5
6
7
8
9
10
11
12
# 从核心交换机登录防火墙
<2F-CORE> telnet 192.168.254.254 4033
[Aiwifi-FW]dis cu | in static
#输出内容
ip route-static 0.0.0.0 0 220.191.185.241
ip route-static 10.20.1.0 24 192.168.254.253 description To_openstack_manage_ip
ip route-static 10.50.51.0 24 192.168.254.253 description To_alpha_cn2
ip route-static 10.50.60.15 32 192.168.254.253 description To_alpha_cn2
ip route-static 10.100.10.0 24 192.168.254.253
ip route-static 172.10.10.0 24 192.168.254.253
ip route-static 172.10.127.0 24 192.168.254.253 description TO_AP_test_linshi
ip route-static 172.16.129.11 32 192.168.254.253 description to_guwenliang

2. 添加静态路由

1
2
3
4
5
6
7
8
# 进入系统视图
<Aiwifi-FW> system-view

# 添加新 VLAN 路由
[Aiwifi-FW] ip route-static 192.168.166.0 24 192.168.254.253 description To_new_vlan700

# 添加其他相关路由(如需要)
[Aiwifi-FW] ip route-static 192.168.10.0 24 192.168.254.253 description To_existing_network

3. 验证防火墙配置

1
2
3
4
5
# 查看当前路由配置
[Aiwifi-FW] display current-configuration | include route-static

# 查看路由表
[Aiwifi-FW] display ip routing-table

二、配置验证与测试

1. 网络连通性测试

1
2
3
4
5
6
7
8
# 从服务器测试网关
ping 192.168.166.254

# 从网关测试服务器
ping 192.168.166.100

# 跨 VLAN 测试
ping 192.168.10.100

2. 防火墙策略验证

1
2
3
4
5
# 测试防火墙路由功能
traceroute 192.168.166.100

# 检查防火墙日志
display logbuffer

三、配置备份与恢复

1. 备份交换机配置

1
2
3
4
5
# 保存当前配置
save

# 导出配置文件
display current-configuration > config.txt

2. 备份防火墙配置

1
2
3
4
5
# 保存防火墙配置
save

# 导出配置文件
display current-configuration > fw-config.txt

3. 恢复配置

1
2
3
# 通过 TFTP 恢复配置
tftp 192.168.1.100 get config.txt
startup saved-configuration config.txt

四、网络拓扑示意图

1
2
3
4
5
6
7
8
9
10
11
graph TD
A[服务器] -->|GE1/0/17| B(Awifi_lab_sw_4)
B -->|Trunk| C(2F-CORE)
C -->|VLAN 700| D[Aiwifi-FW]
D -->|静态路由| E[其他网络]

style A fill:#9f9,stroke:#333
style B fill:#f96,stroke:#333
style C fill:#69f,stroke:#333
style D fill:#f9f,stroke:#333
style E fill:#9ff,stroke:#333

五、最佳实践建议

  1. VLAN 规划原则

    • 管理 VLAN:VLAN 1
    • 服务器 VLAN:VLAN 100-199
    • 用户 VLAN:VLAN 200-299
    • 特殊应用 VLAN:VLAN 300-399
  2. 防火墙策略优化

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # 创建地址组
    address-set vlan700 type object
    address-set vlan700 address 192.168.166.0 24

    # 创建安全策略
    security-policy rule name allow_vlan700
    source-zone trust
    destination-zone untrust
    source-address address-set vlan700
    action permit
  3. 监控与告警

    1
    2
    3
    4
    5
    # 配置 SNMP 监控
    snmp-agent
    snmp-agent community read public
    snmp-agent sys-info version v2c
    snmp-agent target-host trap address udp-domain 192.168.100.100 params securityname public

六、故障排查指南

问题现象 排查步骤
VLAN 不通 1. 检查 VLAN 配置
2. 验证端口 VLAN 成员关系
3. 检查 Trunk 配置
防火墙阻断 1. 检查路由表
2. 验证安全策略
3. 查看会话日志
服务器无法上网 1. 验证 IP 配置
2. 检查默认网关
3. 测试 DNS 解析
配置丢失 1. 检查配置保存状态
2. 验证启动配置文件
3. 恢复备份配置