November 22, 2016

How do I bind a bunch of /24 subnets (secondary) in one shot in Ubuntu 14?

Enter a short description...

I need to bind a bunch of /24 IPv4 subnets as secondary. The primary /29 is already set during the installation of Ubuntu 14x. How do I bind the remainder /24 subnets in one shot instead of individual single IPs one at a time?

I tried this method by adding the below line in /etc/network/interfaces but it didn't work?
 

up route add [-net|-host] <host/net>/<mask> gw <host/IP> dev <Interface>

root@server:~# /etc/init.d/networking restart

I also tried this method too (below example, but did actual IPs and em1)

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
root@server:~# service networking restart
stop: Job failed while stopping
start: Job is already running: networking
root@server:~# ifdown em1 && sudo ifup em1

IPs still don't ping however. They're 100% routed correctly on the Cisco switch though.

Click Here!