A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

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 >> /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!