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 192.168.0.1 – 192.168.0.254 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 255.255.255.0″ >> /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