Configure two /28 subnets on CentOS 7 server

Issues related to configuring your network
Post Reply
Simon1994
Posts: 1
Joined: 2020/11/07 07:17:22

Configure two /28 subnets on CentOS 7 server

Post by Simon1994 » 2020/11/07 07:47:44

Hey guys,

I've got a CentOS 7 server with two /28 subnets (all the IPs are needed for VMs) - i just cant figure out how to configure both at the same time.
I can get one or the other working and pingable, but not both at the same time.

In

Code: Select all

/etc/sysconfig/network-scripts
I've got a file called

Code: Select all

ifcfg-primary-range0 
With..(IPs redacted)

Code: Select all

  IPADDR_START="1.1.1.1"
  IPADDR_END="1.1.1.2"
  NETMASK="255.255.255.240"
  NO_ALIASROUTING=yes
  CLONENUM_START=0
The IPs of that subnet work and are pingable.

I cant figure out how to add my other subnet though.

If i add..

Code: Select all

  IPADDR_START="2.2.2.1"
  IPADDR_END="2.2.2.3"
  NETMASK="255.255.255.240"
  NO_ALIASROUTING=yes
  CLONENUM_START=0
under the other subnet, in the same file, it cancels out the first subnet and i end up with the second subnet configured and pingable but not the first.

Im willing to bet the solution is extremely simple!

Thanks for your help!
:)

User avatar
jlehtone
Posts: 3173
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Configure two /28 subnets on CentOS 7 server

Post by jlehtone » 2020/11/07 19:12:23

First a note, you seem to have mistakenly posted your CentOS 7 question into CentOS 8 forum. (The moderators can probably help with that.)


The default way to configure network in CentOS 7 is with NetworkManager.service. No direct file editing.

You say that you have "server" and "VMs".
How many physical networks is the server connected to? Any VLANs?
What is the network setup of the VMs? Bridged, routed, routed with NAT, or what?

Your config looks like IP aliasing. That technique has been superceded almost two decades ago.

aks
Posts: 3045
Joined: 2014/09/20 11:22:14

Re: Configure two /28 subnets on CentOS 7 server

Post by aks » 2020/11/08 19:32:09

I imagine you need what is called "sub-interface(s)"
Perhaps Google it?

BShT
Posts: 369
Joined: 2019/10/09 12:31:40

Re: Configure two /28 subnets on CentOS 7 server

Post by BShT » 2020/11/10 19:03:20

# cat ifcfg-eth3
...
IPADDR1="1.2.3.4"
PREFIX1="27"

IPADDR2="2.3.4.5"
PREFIX2="27"

IPADDR3="3.4.5.6"
PREFIX3="28"
...

Post Reply

Return to “CentOS 7 - Networking Support”