herozzm
V2EX  ›  Debian

debian 10 如何快捷的将 xx.xx.xx.2-254 200 多个 ip 绑定在一个网口上?

  •  
  •   herozzm · Jul 17, 2020 · 2871 views
    This topic created in 2203 days ago, the information mentioned may be changed or developed.
    找到这个教程: https://wiki.debian.org/NetworkConfiguration#Multiple_IP_addresses_on_one_Interface
    但是一个一个 ip 硬写上去的,有 200 多个 ip,有没有快捷的写法?
    4 replies    2020-07-17 10:53:46 +08:00
    billlee
        1
    billlee  
       Jul 17, 2020
    写个 shell 脚本调用 ip addr add
    onetown
        2
    onetown  
       Jul 17, 2020   ❤️ 2
    DEV=eth0
    PREFIX=192.168.1
    for N in {2..254}; do ip addr add $PREFIX.$N dev $DEV; done;
    ruanimal
        3
    ruanimal  
       Jul 17, 2020   ❤️ 1
    for ip in 192.168.{1..254}; do ip addr add $ip dev $DEV; done
    herozzm
        4
    herozzm  
    OP
       Jul 17, 2020
    @onetown
    @ruanimal 感谢老铁们
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5768 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:57 · PVG 09:57 · LAX 18:57 · JFK 21:57
    ♥ Do have faith in what you're doing.