How to Use Routed Subnet

The routed subnet is directly routed to your main IP, so there’s no need to provide any additional gateway.

You can configure IPs from routed subnet as alias on your network interface:

CentOS #

  • Check on which interface your network is configured by typing ip addr show command
  • Go to /etc/sysconfig/network-scripts/ and find file named as your active interface
  • Make a copy of your current config file and add :0 (where 0 is number of your first alias) to the end of the file name (eg. ifcfg-ens160:0)
  • Now modify your new interface file with your favourite editor:
    • Remove line with gateway information
    • Adjust IPADDR and NETMASK with your routed subnet
    • Change NAME and DEVICE by adding :0 to the end of the interface name
    • Save your file and execute ifup ens160:0 (remember, ens160:0 is a example interface name and can be diffrent on your server)
  • Your additional IP from routed subnet should now work.

Example of /etc/sysconfig/network-script/ifcfg-ens160:0 config

NAME=”ens160:0″
ONBOOT=”yes”
BOOTPROTO=”static”
IPADDR=”192.168.0.10″
NETMASK=”255.255.255.128″

Debian/Ubuntu #

  • Please edit /etc/network/interfaces
  • Make copy of your current interface config and paste it on the end of the file
  • Add :0 (where 0 is number of your first alias) to interface name (eg. eth0:0)
  • Remove line with gateway information
  • Remove line with broadcast information
  • Remove line with network information
  • Adjust address and netmask with your routed subnet
  • Save file and restart your networking by executing service networking restart

Example of /etc/network/interface alias config:

auto eth0:0
iface eth0:0 inet static
address 192.168.0.10
netmask 255.255.255.128

PROXMOX/ESXi/Other Virtualization Panels. #

If you want to use your routed subnet inside proxmox’s VMs, you need to add first IP from routed subnet inside proxmox bridged interface. You can add it as alias to bridged interface.

This first address from your routed subnet will be used as gateway for your VMs.

 

Netplan based configuration  #

Please see: https://netplan.io/examples/ for documentation and examples based on your requirements.

 

Windows Server 2019 #

 

For windows and routed subnets you will first need to enable IP routing in windows, this is done as follows:

Go to the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters. 
If not already there, create a new REG_DWORD value named IPEnableRouter. 
Set IPEnableRouter to 1 and reboot. 

Packet forwarding should now be enabled.

Now you simply add the additional IP’s to the main interface in windows, by opening the IPv4 properties on the main adaptor, the click adanced then add additional IP addresses, they will function through the gateway for the main IP address so there is no need to set an additional gateway.