How to quickly bind a range of IPs in Debian based systems

How to bind a range of IPs in Debian using bash scripting:

Lets say we want to add the C block of IPs. Its too boring to add all of them by hands in intefaces file. So… Lets make this job fast and simple 🙂

Lets create a small bash script. This script will add the range of IPs – to /etc/network/interfaces.

for i in {1..254}; do echo “iface eth0:$i inet static” >> /etc/network/interfaces; echo ” address 192.168.0.$i” >> /etc/network/interfaces; echo ” netmask″ >> /etc/network/interfaces; echo “auto eth0:$i” >> /etc/network/interfaces; done

Just type this line in bash console and hit the Enter key.

Now we need to bring the interfaces up. Type in console or just copy and paste:

for i in {1..254}; do ifup eth0:$i; done


Bare Metal Dedicated Servers

A single tenant, physical server allowing you full access to its resources.

Browse servers

Professional Hybrid Servers

Virtualized server platform hosted on enterprise-grade physical servers.

Browse servers

Scalable Cloud Servers

High-performance and highly-available infrastructure.

Browse servers

Managed Colocation

Our next-generation data center facilities.

Browse servers

Your email address will not be published.

There are no comments yet, why not be the first?