LoginSignup
18
20

More than 5 years have passed since last update.

一枚のNICに大量のIPアドレスを割り当てる

Last updated at Posted at 2016-04-28

ミッション

1000台分の接続テストがしたい。

シェルスクリプト

sample.sh
#!/bin/sh

loop=1
for adr3 in $(seq 30 39)
do
  for adr4 in $(seq 0 99)  
  do
    echo $loop $adr3 $adr4
    ifconfig eth0:$loop 172.21.$adr3.$adr4 netmask 255.255.0.0 up
    loop=`expr $loop + 1`
  done
done

確認

$ ip address show
:
:
    inet 172.21.30.0/16 brd 172.21.255.255 scope global eth0:1
    inet 172.21.30.1/16 brd 172.21.255.255 scope global secondary eth0:2
    inet 172.21.30.2/16 brd 172.21.255.255 scope global secondary eth0:3
    inet 172.21.30.3/16 brd 172.21.255.255 scope global secondary eth0:4
    inet 172.21.30.4/16 brd 172.21.255.255 scope global secondary eth0:5
    inet 172.21.30.5/16 brd 172.21.255.255 scope global secondary eth0:6
    inet 172.21.30.6/16 brd 172.21.255.255 scope global secondary eth0:7
    inet 172.21.30.7/16 brd 172.21.255.255 scope global secondary eth0:8
    inet 172.21.30.8/16 brd 172.21.255.255 scope global secondary eth0:9
    inet 172.21.30.9/16 brd 172.21.255.255 scope global secondary eth0:10
    inet 172.21.30.10/16 brd 172.21.255.255 scope global secondary eth0:11
    inet 172.21.30.11/16 brd 172.21.255.255 scope global secondary eth0:12
    inet 172.21.30.12/16 brd 172.21.255.255 scope global secondary eth0:13
:
:
18
20
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
20