Example /etc/network/interfaces for Debian and Ubuntu

The following are example /etc/network/interfaces files for different IPv4 subnet sizes. See interfaces(5) for more information.

IPv6

Please note the IPv6 stanza is not included in the examples but should be preserved whenever editing your interfaces(5) file or else you will lose IPv6 connectivity.

/30 subnet, 1 usable IP

Say your subnet is 10.0.0.0/30 and the Portal has the following network settings for your VPS:

Network: 10.0.0.0/30
Usable IPs: 10.0.0.2
Gateway: 10.0.0.1
Subnet Mask: 255.255.255.252
Broadcast Address: 10.0.0.3

Your /etc/network/interfaces would look like:

# The loopback network interface
auto lo                          
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 10.0.0.2
        netmask 255.255.255.252
        gateway 10.0.0.1
        broadcast 10.0.0.3

/29 subnet, 5 usable IPs

Say your subnet is 10.0.0.0/29 and the Portal has the following network settings for your VPS:

Network: 10.0.0.0/29
Usable IPs: 10.0.0.2 - 10.0.0.6
Gateway: 10.0.0.1
Subnet Mask: 255.255.255.248
Broadcast Address: 10.0.0.7

Your /etc/network/interfaces would look like:

# The loopback network interface
auto lo                          
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 10.0.0.2
        netmask 255.255.255.248
        gateway 10.0.0.1
        broadcast 10.0.0.7
        up ip address add 10.0.0.3 dev eth0
        up ip address add 10.0.0.4 dev eth0
        up ip address add 10.0.0.5 dev eth0
        up ip address add 10.0.0.6 dev eth0

/28 subnet, 13 usable IPs

Say your subnet is 10.0.0.0/28 and the Portal has the following network settings for your VPS:

Network: 10.0.0.0/28
Usable IPs: 10.0.0.2 - 10.0.0.14
Gateway: 10.0.0.1
Subnet Mask: 255.255.255.240
Broadcast Address: 10.0.0.15

Your /etc/network/interfaces would look like:

# The loopback network interface
auto lo                          
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 10.0.0.2
        netmask 255.255.255.240
        gateway 10.0.0.1
        broadcast 10.0.0.15
        up ip address add 10.0.0.3 dev eth0
        up ip address add 10.0.0.4 dev eth0
        up ip address add 10.0.0.5 dev eth0
        up ip address add 10.0.0.6 dev eth0
        up ip address add 10.0.0.7 dev eth0
        up ip address add 10.0.0.8 dev eth0
        up ip address add 10.0.0.9 dev eth0
        up ip address add 10.0.0.10 dev eth0
        up ip address add 10.0.0.11 dev eth0
        up ip address add 10.0.0.12 dev eth0
        up ip address add 10.0.0.13 dev eth0
        up ip address add 10.0.0.14 dev eth0