V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
herozzm
V2EX  ›  Debian

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

  •  
  •   herozzm · 2020-07-17 00:36:37 +08:00 · 2180 次点击
    这是一个创建于 1351 天前的主题,其中的信息可能已经有所发展或是发生改变。
    找到这个教程: https://wiki.debian.org/NetworkConfiguration#Multiple_IP_addresses_on_one_Interface
    但是一个一个 ip 硬写上去的,有 200 多个 ip,有没有快捷的写法?
    4 条回复    2020-07-17 10:53:46 +08:00
    billlee
        1
    billlee  
       2020-07-17 01:36:49 +08:00
    写个 shell 脚本调用 ip addr add
    onetown
        2
    onetown  
       2020-07-17 03:02:41 +08:00   ❤️ 2
    DEV=eth0
    PREFIX=192.168.1
    for N in {2..254}; do ip addr add $PREFIX.$N dev $DEV; done;
    ruanimal
        3
    ruanimal  
       2020-07-17 10:33:20 +08:00   ❤️ 1
    for ip in 192.168.{1..254}; do ip addr add $ip dev $DEV; done
    herozzm
        4
    herozzm  
    OP
       2020-07-17 10:53:46 +08:00
    @onetown
    @ruanimal 感谢老铁们
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2861 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:59 · PVG 20:59 · LAX 05:59 · JFK 08:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.