LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-17-2016, 02:35 PM   #1
youbuntoo
LQ Newbie
 
Registered: Jan 2016
Posts: 9

Rep: Reputation: Disabled
Lightbulb Binding a list of IPv4 addresses to Ubuntu Server quickly


Hey Guys,

Is there a bash script or tool to automatically bind a list of IPv4 addresses to an Ubuntu server quickly?

For example, let's say I have a text file named /root/iplist.txt
and in iplist.txt, I have one IP per line:
1.1.1.1
1.1.1.2
1.1.1.3
... and so on, until .30 let's say. How do I automatically bind that list of individual IPv4 addresses to the Ubuntu server?

I am aware of the ip command to bind a CIDR block (ip addr add 1.1.1.1/24 for example) however I am not sure how to quickly bind a range of individual IPs.

I know how to do this in CentOS with ifcfg-eth1-range0 but it doesn't appear this feature is available in Ubuntu...

I am sure this topic will come in handy for a lot of other people as I was only able to find tutorials on how to do this with CentOS despite my hours of researching I was not able to find anything for Ubuntu. So I am adding the appropriate tags to this post

Thanks for any help,
 
Old 01-17-2016, 06:06 PM   #2
youbuntoo
LQ Newbie
 
Registered: Jan 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
Anyone?
 
Old 01-17-2016, 06:16 PM   #3
youbuntoo
LQ Newbie
 
Registered: Jan 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
Found the solution, in case anyone was needing this! I searched for hours and couldn't find anything so decided to come up with something on my own! I really hope this helps others who were seeking the same solution.

for i in {1..128}; do echo iface eth1:$i inet static >> /etc/network/interfaces; echo address 192.168.0.$i >> /etc/network/interfaces; echo netmask 255.255.255.0 >> /etc/network/interfaces; echo auto eth1:$i >> /etc/network/interfaces; done

Replace 255.255.255.0 with your subnet, and replace 192.168.0. with the first 3 parts of your IP range
Edit "eth1" to eth0 or whatever your main network interface is.

And replace 1..128 accordingly, for example the above commnad would route .1 to .128.
 
  


Reply

Tags
ip address, ubuntu


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
Ubuntu Server 12.04.2 LTS Networking Issues with Multiple IPV4 Addresses westzilla Linux - Server 1 06-23-2013 06:02 AM
Binding 2 NICs (MAC addresses) to 2 IP Addresses in same Subnet RedHat EL4.0 skhira Linux - Networking 13 02-24-2008 08:16 PM
Binding 2 NICs (MAC addresses) to 2 IP Addresses in same Subnet RedHat EL4.0 skhira Linux - Networking 1 02-09-2008 07:17 AM
Binding multiple IP Addresses to same NIC Harlin Linux - Networking 4 10-26-2005 05:10 AM


All times are GMT -5. The time now is 04:21 PM.

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