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
Complete Digital Server Solutions For All
Dedicated Servers
A single tenant, physical server allowing you full access to its resources.
Hybrid Servers
Virtualized server platform hosted on enterprise-grade physical servers.
Cloud Servers
High-performance and highly-available infrastructure, delivering a reliable, secure, and scalable solution.