Adding A Range of IP Addresses in Debian

Posted
Comments None

Following up our previous articles about how to Add an Additional IP Address and Adding A Range of IP Addresses in CentOS we’ll now see how to add a range of IP addresses under Debian. As previously mentioned there is no easy, standard way to do so, that’s why we’re going create a small script that will automate the job for you.

add-range.sh

#!/bin/bash for ip in {1..254}; do echo up ip addr add 192.168.1.$ip/24 dev eth0>>/etc/network/interfaces done

Once you create the file add-range.sh, don’t forget to set execute permissions for the file.

chmod 755 add-range.sh

Keep an eye on the netmask /24 which may be different in your case. The script will append data in your /etc/network/interfaces file so running it twice may not be a desired behavior.

Within the next article we’ll present a similar script that will allow you to add IP addresses from a specific list, not necessary sequential.


There are currently no comments on this article.

Comment

Enter your comment below. Fields marked * are required. You must preview your comment first before finally posting.





← Older Newer →