How to configure range of static IPs (/22) in Ubuntu 16 Server?

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

Bashed

Member
Apr 29, 2015
36
0
6
73
I’m having trouble getting a /22 subnet working on an Ubuntu 16 server. From the outside world, I cannot ping any IPs assigned to VLAN except .2

Ubuntu Server Network Config:


Code:
root@server15:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eno1
iface eno1 inet static
       address xxx.53.16.2
        netmask 255.255.252.0
        network xxx.53.16.0
        broadcast xxx.53.19.255
        gateway xxx.53.16.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers xxx.xxx.33.61 xxx.xxx.33.62
        dns-search domain.com
Also added this line in interfaces, still doesn't work

Code:
#Add internal route
up route add -net xxx.53.16.0/22 gw xxx.53.16.1 dev eno1
root@server15:~# sudo service networking restart

How do I permanently configure a range of static IPs (/22) in Ubuntu 16 Server?
 

NashBrydges

Member
Apr 30, 2015
86
24
8
57
Sorry, but I'm confused as to what you're trying to do here.

You have an Ubuntu server but what is assigning the IP addresses on your network? Router? Switch? The interfaces file is for assigning a static IP address to the server itself...just 1 IP address though. So don't know what "...a range of static IPs (/22) in Ubuntu 16 Server" means. Using a /22 netmask only expands the number of IP addresses that are available to 1022 hosts.

Can you ping any other IP address within this same network? If you're trying to access your server from "the ourside world", you're first going to need to DNAT a port or use some kind of web application firewall to expose your internal server to the outside world.
 

Locutis

New Member
Oct 26, 2016
8
4
3
47
Here is the contents of my 'interfaces' file with 3 NICs on 3 different networks (I've changed some numbers for my public IPs so they're not the same as my real IP addresses):

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface (on-board / upper)
allow-hotplug eth0
auto eth0
iface eth0 inet static

address 139.144.111.233
netmask 255.255.255.240
broadcast 139.144.111.243
network 139.144.111.228
post-up iptables-restore < /etc/iptables.up.rules
gateway 139.144.111.242
# dns-* options are implemented by the resolvconf package, if installed

# The primary network interface (PCIe)
allow-hotplug eth1
auto eth1
iface eth1 inet static

address 192.168.10.133
netmask 255.255.255.0
broadcast 192.168.10.255
network 192.168.10.0

# The secondary network interface (onboard / lower)
allow-hotplug eth2
auto eth2
iface eth2 inet static

address 192.168.10.233
netmask 255.255.255.0
broadcast 192.168.10.255
network 192.168.10.0
I have network manager uninstalled. My IP addresses are /28 and start at xxx.xxx.xxx.229 and end at xxx.xxx.xxx.241. The gateway is xxx.xxx.xxx.242.

You can find your netmask by looking up this cheat sheet:

Subnet Mask Cheat Sheet

For /22, this is how it should look:

auto eth0
iface eth0 inet static
address 173.246.100.1
network 173.246.100.0
netmask 255.255.252.0
broadcast 173.246.100.255
gateway 173.246.103.254​

auto eth1
iface eth0 inet static
address 173.246.100.2
network 173.246.100.0
netmask 255.255.252.0
broadcast 173.246.100.255
gateway 173.246.103.254​


I hope this helps you.
 
Last edited:

manxam

Active Member
Jul 25, 2015
234
50
28
I'm not certain if this is in any way related but your "broadcast" is out of scope..
Code:
        address xxx.53.16.2
        network xxx.53.16.0
        broadcast xxx.53.19.255