[olug] adding a ton of IPs to one interface automaticly

Christopher Cashell topher-olug at zyp.org
Sat Feb 13 09:11:08 UTC 2010


On Fri, Feb 12, 2010 at 8:28 PM, Charles Bird <cbird.omaha at gmail.com> wrote:
> Anyone got a good method of adding a /22 or /20 to eth0 without having to
> type out a bunch of BS??
>
> I got some ideas forming about how to go about this, but nothing concrete in
> mind yet, needing some perspective on this issue.

Do you want a one-time command, or do you want this to be persistent?
If you want it to be persistent, you'll have to supply which
distribution you're using.  Without that, I don't know which network
config scripts to suggest.

If you just want an ad hoc config, try something like this:

root at host#  for x in $(seq 0 255) ; do for y in $(seq 0 16); do ip
addr add 192.168.$y.$x dev eth0; done ; done

You can adjust the sequences and interface as needed to fit your
network requirements.  To remove them, you can use 'ip addr flush'
(just make sure you read the man page and understand what you're
removing so you don't wipe addresses you might need to keep active).
Alternately, you can replace the 'add' with 'del' above to do it.

I was thinking there was another (better) way of doing it, but I can't
remember what it is, and a quick google didn't show me anything
matching what I thought I remembered.

-- 
Christopher



More information about the OLUG mailing list