V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
yiluqingshen
V2EX  ›  宽带症候群

华三交换机 VLAN 批量配置,请赐教。

  •  
  •   yiluqingshen · 138 天前 · 991 次点击
    这是一个创建于 138 天前的主题,其中的信息可能已经有所发展或是发生改变。

    请教大佬: 1 、设备:华三 s5024PV3-EI

    2 、需求: CLI 调试命令 将 1-24 口批量配置 VLAN 101 、102 、103....110 、111 、112------124 ( access 口),IP 地址分别配置成 192.168.101.1-----192.168.124.1 ,子网掩码:255.255.255.0 ;

    28 口( sfp )设置成 Trunk 与 1-24 口通信。

    批量太难了,不会弄。

    谢谢各位大佬指教。

    20 条回复    2023-12-18 13:19:37 +08:00
    youdoit
        1
    youdoit  
       138 天前   ❤️ 1
    这么简单的配置还难
    最简单的方法,写好配置文档,然后修改管理地址就行了,其他都是复制进去.
    hefish
        2
    hefish  
       138 天前
    接串口线, 通电, 粘贴, 下一台。。。
    laozhoubuluo
        3
    laozhoubuluo  
       138 天前
    传统的方法就是写个基础配置文件,完了基于基础配置文件改出来每一台的配置,到时候直接插串口线刷文件配置。
    有脚本功底的可以考虑脚本调用串口自动写配置,反正每一台就这几个变量。
    TESTFLIGHT2021
        4
    TESTFLIGHT2021  
       138 天前
    写个批处理
    TenRice
        5
    TenRice  
       138 天前
    Excel 下拉填充端口号、VLAN ID 、IP 地址,再用 & 拼接命令,最后所有命令汇总复制成 txt 往交换机里直接刷
    yiluqingshen
        6
    yiluqingshen  
    OP
       137 天前
    @TenRice 大佬有方法或教程吗?不太会哦,1 台每个接口都一条条配置得配置到退休了。
    yiluqingshen
        7
    yiluqingshen  
    OP
       137 天前
    @TESTFLIGHT2021 大佬,不会写批处理文件,怎么写?
    yiluqingshen
        8
    yiluqingshen  
    OP
       137 天前
    @youdoit 兄滴, 能教个方法吗?主要不会才觉得难。
    youdoit
        9
    youdoit  
       137 天前
    打开记事本,创建 vlan
    拷贝交换机上所有端口下来到记事本,然后加入 access
    配置 trunk.
    不理解你的 ip 地址是用来管理还是配置到端口上.

    然后你把记事本这个保存好,其他的每台都是复制进去,改变的就是 ip 地址了.

    这个应该是最简单有效性的方法了(因为你不熟悉,这样不会出错)
    yiluqingshen
        10
    yiluqingshen  
    OP
       137 天前
    @youdoit “不理解你的 ip 地址是用来管理还是配置到端口上”,管理口已经配置好,是配置到每个端口上,
    比如说第一个端口 vlan101 192.168.101.1 ;
    第二个端口: vlan102 192.168.102.1;
    .................... 以此类推到 24 口。
    大佬能贴个代码吗?
    youdoit
        11
    youdoit  
       137 天前
    你这是 vlan 管理地址.你把你交换机 dis cu 拷贝到这里来
    TenRice
        12
    TenRice  
       137 天前
    @yiluqingshen 以图片里的 Excel 表为例,B 列和 D 列下拉填充、E 列拼接命令,选中全部的 E 列贴到记事本里,Ctrl+H 替换掉 " 等无效符号,最后就是可以直接刷入交换机的命令。
    ![h3c]( https://imgur.com/dy2HoOr)

    附上图中的 Excel 链接: https://docs.google.com/spreadsheets/d/1P3eFbx55auxxafmDz9rJFJi5N9kp2IdHvlCYDeuWDeY/edit?usp=sharing
    yiluqingshen
        13
    yiluqingshen  
    OP
       135 天前
    @TenRice "![h3c]( https://imgur.com/dy2HoOr)"
    大佬这个图片打不开,Excel 能打开,拼接命令是&吗?
    yiluqingshen
        14
    yiluqingshen  
    OP
       135 天前
    @youdoit 交换机目前是空配置啊。。。

    ******************************************************************************
    * Copyright (c) 2004-2020 New H3C Technologies Co., Ltd. All rights reserved.*
    * Without the owner's prior written consent, *
    * no decompiling or reverse-engineering shall be allowed. *
    ******************************************************************************

    <H3C>%Jan 2 04:11:09:841 2013 H3C SHELL/5/SHELL_LOGIN: admin logged in from aux 0.

    <H3C>dis cu
    #
    version 7.1.070, Release 6318P01
    #
    sysname H3C
    #
    telnet server enable
    #
    irf mac-address persistent timer
    irf auto-update enable
    undo irf link-delay
    irf member 1 priority 1
    #
    lldp global enable
    #
    password-recovery enable
    #
    vlan 1
    #
    interface NULL0
    #
    interface Vlan-interface1
    ip address 192.168.1.254 255.255.255.0
    dhcp client identifier ascii 3cd2e5e72fb5-VLAN0001
    #
    interface GigabitEthernet1/0/1
    #
    interface GigabitEthernet1/0/2
    #
    interface GigabitEthernet1/0/3
    #
    interface GigabitEthernet1/0/4
    #
    interface GigabitEthernet1/0/5
    #
    interface GigabitEthernet1/0/6
    #
    interface GigabitEthernet1/0/7
    #
    interface GigabitEthernet1/0/8
    #
    interface GigabitEthernet1/0/9
    #
    interface GigabitEthernet1/0/10
    #
    interface GigabitEthernet1/0/11
    #
    interface GigabitEthernet1/0/12
    #
    interface GigabitEthernet1/0/13
    #
    interface GigabitEthernet1/0/14
    #
    interface GigabitEthernet1/0/15
    #
    interface GigabitEthernet1/0/16
    #
    interface GigabitEthernet1/0/17
    #
    interface GigabitEthernet1/0/18
    #
    interface GigabitEthernet1/0/19
    #
    interface GigabitEthernet1/0/20
    #
    interface GigabitEthernet1/0/21
    #
    interface GigabitEthernet1/0/22
    #
    interface GigabitEthernet1/0/23
    #
    interface GigabitEthernet1/0/24
    #
    interface GigabitEthernet1/0/25
    #
    interface GigabitEthernet1/0/26
    #
    interface GigabitEthernet1/0/27
    #
    interface GigabitEthernet1/0/28
    #
    scheduler logfile size 16
    #
    line class aux
    authentication-mode scheme
    user-role network-admin
    #
    line class vty
    authentication-mode scheme
    user-role network-operator
    #
    line aux 0
    user-role network-admin
    #
    line vty 0 63
    user-role network-operator
    TenRice
        15
    TenRice  
       135 天前
    @yiluqingshen 是的,Google Sheet 里可以看到公式
    ZeroYe
        16
    ZeroYe  
       135 天前
    楼主,你要先了解一下二层交换机和三层交换机区别
    1.你是二层交换机,哪来功能可以给接口配 IP 地址,就连 vlan-interface 也只能配置一个
    2.每个接口一个 VLAN ,你只能一个用前面提示的方法了 Excel 自动填充,然后复制粘贴
    youdoit
        17
    youdoit  
       134 天前
    这个地方添加需要修改的配置,vlan,还有管理地址这些,其他的可以不需要改变
    ##################
    interface GigabitEthernet1/0/1
    port link-type access
    interface GigabitEthernet1/0/2
    port link-type access
    interface GigabitEthernet1/0/3
    port link-type access
    interface GigabitEthernet1/0/4
    port link-type access
    interface GigabitEthernet1/0/5
    port link-type access
    interface GigabitEthernet1/0/6
    port link-type access
    interface GigabitEthernet1/0/7
    port link-type access
    interface GigabitEthernet1/0/8
    port link-type access
    interface GigabitEthernet1/0/9
    port link-type access
    interface GigabitEthernet1/0/10
    port link-type access
    interface GigabitEthernet1/0/11
    port link-type access
    interface GigabitEthernet1/0/12
    port link-type access
    interface GigabitEthernet1/0/13
    port link-type access
    interface GigabitEthernet1/0/14
    port link-type access
    interface GigabitEthernet1/0/15
    port link-type access
    interface GigabitEthernet1/0/16
    port link-type access
    interface GigabitEthernet1/0/17
    port link-type access
    interface GigabitEthernet1/0/18
    port link-type access
    interface GigabitEthernet1/0/19
    port link-type access
    interface GigabitEthernet1/0/20
    port link-type access
    interface GigabitEthernet1/0/21
    port link-type access
    interface GigabitEthernet1/0/22
    port link-type access
    interface GigabitEthernet1/0/23
    port link-type access
    interface GigabitEthernet1/0/24
    port link-type access
    interface GigabitEthernet1/0/25
    port link-type access
    interface GigabitEthernet1/0/26
    port link-type access
    interface GigabitEthernet1/0/27
    port link-type access
    interface GigabitEthernet1/0/28
    port link-type trunk
    port trunk permit vlan all



    # 以上配置文件可以直接复制到所有交换机,直接复制.
    yiluqingshen
        18
    yiluqingshen  
    OP
       134 天前
    @youdoit 哥们,学了带皮毛,我只能配置到退休了。我这样配置
    system-view
    vlan 101
    quit
    ---------------------------------------------------------------------
    interface GigabitEthernet1/0/1
    port link-type access
    port access vlan 101

    此处省略 N 个端口。。。。。。。。。。。

    ---------------------------------------------------------------------
    28 口这样设置:
    interface GigabitEthernet1/0/28
    port link-type trunk
    port trunk permit vlan all


    ---------------------------------------------------------------------
    这样对了吗?
    28 口 trunk 是放行所有带标签 VLAN
    yiluqingshen
        19
    yiluqingshen  
    OP
       134 天前
    @youdoit
    交换机显示信息,应该没错吧


    [H3C]dis vlan 101
    VLAN ID: 101
    VLAN type: Static
    Route interface: Not configured
    Description: VLAN 0101
    Name: VLAN 0101
    Tagged ports: None
    Untagged ports:
    GigabitEthernet1/0/1
    [H3C]dis vlan 102
    VLAN ID: 102
    VLAN type: Static
    Route interface: Not configured
    Description: VLAN 0102
    Name: VLAN 0102
    Tagged ports: None
    Untagged ports:
    GigabitEthernet1/0/2
    youdoit
        20
    youdoit  
       134 天前
    按照你实际需求加入 vlan 啊,我的意思是这样的模版做好一个,复制进去,就复制端口这些,其他的不要复制了.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1779 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 16:16 · PVG 00:16 · LAX 09:16 · JFK 12:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.