P2i Setup
Network
  • Public IP Address: 64.128.240.59
  • Intranet IP Address: 192.168.2.20
  • 192.168.2.0 subnet gateway: 192.168.0.20
  • 192.168.2.0 subnet DHCP server: 192.168.2.2

DHCP server has only one network card. Added secondary virtual NIC to DHCP server to have both addresses 192.168.0.2 and 192.168.2.2, each one in their respective subnets.

# ip addr add 192.168.2.2/24 dev eth0
# ip addr show eth0
1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:01:02:38:6c:e2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.2/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.2.2/24 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::201:2ff:fe38:6ce2/64 scope link
       valid_lft forever preferred_lft forever

Add permanent address changes to file /etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  address 192.168.0.2/24

iface eth0 inet static
  address 192.168.2.2/24
  ### add persistent route command ###
  post-up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1

dns-nameservers 192.168.0.104 4.2.2.2

Activate changes without rebooting:

# ifdown eth0 && sudo ifup eth0

Source:

DHCP Server

Configure DHCP to have a shared-network when using a single NIC with multiple subnets (IP addresses). Edit /etc/dhcp/dhcpd.conf:

shared-network my-net {
  subnet 192.168.0.0 netmask 255.255.255.0 {
    ...
  }

  subnet 192.168.2.0 netmask 255.255.255.0 {
    ...
  }
}

Example:

#----------------------------
# subnets
# shared-network used since it uses single shared NIC eth0
#----------------------------
shared-network 2-09 {
  subnet 192.168.0.0 netmask 255.255.255.0 {
    #------------------------------------------
    # Subnet options
    #------------------------------------------
    default-lease-time 86400; # 24 hrs
    max-lease-time 86400;     # 24 hrs

    #------------------------------------------
    # Address ranges for dynamic distribution
    #------------------------------------------
    #range 192.168.0.1 192.168.0.50;     # gw, switches, printers, servers
    #range 192.168.0.60 192.168.0.69;    # access points
    #range 192.168.0.70 192.168.0.110;   # servers
    range 192.168.0.111 192.168.0.254;   # dynamic distribution
  }
  subnet 192.168.2.0 netmask 255.255.255.0 {
    #------------------------------------------
    # Subnet options
    #------------------------------------------
    default-lease-time 86400; # 24 hrs
    max-lease-time 86400;     # 24 hrs
    option subnet-mask          255.255.255.0;
    option broadcast-address    192.168.2.255;
    option routers              192.168.2.1;
    option domain-name-servers 4.2.2.2, 8.8.8.8;
    #option domain-name-servers  192.168.0.104, 192.168.2.2;
    option domain-name          "acme.com";
    #option netbios-name-servers 192.168.2.2;
    #option ntp-servers          192.168.0.31;   

    #------------------------------------------
    # Address ranges for dynamic distribution
    #------------------------------------------
    #range 192.168.2.1 192.168.2.99;     # gw, switches
    #range 192.168.2.100 192.168.2.254;   # dynamic distribution
  }
}

Source:

Gateway

Enable IP forwarding on the server with single NIC and multiple subnets, so traffic passes from one subnet to the next. Edit /etc/sysctl.conf:

# Uncomment to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

Source: