= 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: 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: * [[http://askubuntu.com/questions/547289/how-can-i-from-cli-assign-multiple-ip-addresses-to-one-interface|Multiple IP Addresses to one Interface]] * [[http://askubuntu.com/questions/548940/add-static-route-in-ubuntu-14-04|Add Static Route]] === 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: * [[http://serverfault.com/questions/390410/dhcp-one-nic-and-multiple-subnets]] === 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: * [[http://askubuntu.com/questions/331975/how-can-we-make-our-ubuntu-server-router-as-gateway-mode-to-router-mode]] * [[https://rbgeek.wordpress.com/2012/05/14/ubuntu-as-a-firewallgateway-router/]]