华三交换机 VLAN 批量配置,请赐教。 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
yiluqingshen
V2EX    宽带症候群

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

  •  
  •   yiluqingshen 2023-12-14 17:22:27 +08:00 2023 次点击
    这是一个创建于 749 天前的主题,其中的信息可能已经有所发展或是发生改变。

    请教大佬: 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 )设置成 runk 与 1-24 口通信。

    批量太难了,不会弄。

    谢谢各位大佬指教。

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

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

    这个应该是最简单有效性的方法了(因为你不熟悉,这样不会出错)
    yiluqingshen
        10
    yiluqingshen  
    OP
       2023-12-15 14:57:56 +08:00
    @youdoit “不理解你的 ip 地址是用来管理还是配置到端口上”,管理口已经配置好,是配置到每个端口上,
    比如说第一个端口 vlan101 192.168.101.1 ;
    第二个端口: vlan102 192.168.102.1;
    .................... 以此类推到 24 口。
    大佬能贴个代码吗?
    youdoit
        11
    youdoit  
       2023-12-15 15:22:47 +08:00
    你这是 vlan 管理地址.你把你交换机 dis cu 拷贝到这里来
    TenRice
        12
    TenRice  
       2023-12-15 16:06:02 +08:00
    @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
       2023-12-17 14:37:21 +08:00
    @TenRice "![h3c]( https://imgur.com/dy2HoOr)"
    大佬这个图片打不开,Excel 能打开,拼接命令是&吗?
    yiluqingshen
        14
    yiluqingshen  
    OP
       2023-12-17 14:41:15 +08:00
    @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  
       2023-12-17 15:51:11 +08:00
    @yiluqingshen 是的,Google Sheet 里可以看到公式
    ZeroYe
        16
    ZeroYe  
       2023-12-17 18:49:46 +08:00
    楼主,你要先了解一下二层交换机和三层交换机区别
    1.你是二层交换机,哪来功能可以给接口配 IP 地址,就连 vlan-interface 也只能配置一个
    2.每个接口一个 VLAN ,你只能一个用前面提示的方法了 Excel 自动填充,然后复制粘贴
    youdoit
        17
    youdoit  
       2023-12-18 09:13:27 +08:00
    这个地方添加需要修改的配置,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
       2023-12-18 12:52:04 +08:00
    @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
       2023-12-18 12:53:40 +08:00
    @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  
       2023-12-18 13:19:37 +08:00
    按照你实际需求加入 vlan 啊,我的意思是这样的模版做好一个,复制进去,就复制端口这些,其他的不要复制了.
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2360 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 57ms UTC 11:41 PVG 19:41 LAX 03:41 JFK 06:41
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86