Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 01-13-2022, 09:52 AM   #1
Registered: Jul 2015
Posts: 122

Rep: Reputation: Disabled
BIND Script

For Linux o/s where I assign a large quantity of IPv4 addresses, I use a simple bind script to quickly bind all IPs.


for i in $(seq 2 254);
        ip addr add xxx.142.100.$i/24 dev eth0
        ip addr add xxx.142.101.$i/24 dev eth0
        ip addr add xxx.142.102.$i/24 dev eth0
        ip addr add xxx.142.103.$i/24 dev eth0        

ip addr show
Is there an easier way to do a single line for whatever size subnet?

Say for example I want to bind a full straight /19 to the server. I cannot do for example...

ip addr add xxx.142.101.$i/19 dev eth0

...because of the sequence line.

Is there an alternative to this?

Last edited by Bashed; 01-13-2022 at 10:17 AM.
Old 01-14-2022, 01:27 PM   #2
Registered: Jul 2015
Posts: 122

Original Poster
Rep: Reputation: Disabled
Old 01-29-2022, 12:18 AM   #3
LQ Newbie
Registered: Dec 2021
Posts: 21

Rep: Reputation: Disabled
Hi Bashed,

If I understood correctly, you also want to generate the 3rd octet of the ip addresses. You can use a double loop like:


for i in $(seq 0 31);
for j in $(seq 2 254);
ip addr add xxx.142.$i.$j/24 dev eth0

ip addr show


This will generate 31 x 254 = 7874 virtual interfaces!


Last edited by beka; 01-29-2022 at 12:19 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: DNS: The Bind Leading the Bind LXer Syndicated Linux News 0 06-15-2006 10:33 PM
How to update BIND ./etc/bind/db.coaxcables AndeAnderson Debian 0 03-03-2006 09:35 AM
Bind 8 and Bind 9 sierra Linux - Networking 2 03-16-2005 11:15 AM
How do I revert to Bind 8 from Bind 9? digging4roots Linux - Newbie 3 06-08-2002 04:40 PM
To 'Bind' or not to 'Bind' that is the question jsurgeson Linux - Newbie 2 03-24-2002 03:10 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:44 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration