5

Configure Debian with Multiple IP Addresses

 2 years ago
source link: https://www.vultr.com/docs/configure-debian-with-multiple-ip-addresses
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Using a Different System?

Are we missing a guide for your target system? Request one, or submit your own!
<?xml encoding="utf-8" ??>

Introduction

A basic network configuration at Vultr consists of a single IPv4 address, configured by DHCP. If you have advanced networking requirements, Vultr supports multiple public IPs and up to five private networks. You need to manually configure these advanced scenarios. Refer to the networking configuration page in the customer portal for your exact configuration. This example demonstrates three public IPv4 addresses, two private IPv4 networks, and two public IPv6 addresses.

Note: Your network adapter names may not match the examples. See our article How to Find the Network Adapter Names for a Vultr Cloud Server.

IPv4 Info

MultipleIP

IPv6 Info

MultipleIP

Example for Debian 9 and 10

Configure the public network with three public IPv4 addresses and two public IPv6 addresses. Configure two private networks.

Populate /etc/network/interfaces with:

auto lo
iface lo inet loopback

auto ens3
iface ens3 inet static
    address 192.0.2.101
    netmask 255.255.254.0
    gateway 192.0.2.1
    dns-nameservers 192.0.2.200
    post-up ip route add 169.254.0.0/16 dev ens3

iface ens3 inet6 static
    address 2001:db8:1000::100
    netmask 64
    up /sbin/ip -6 addr add dev ens3 2001:db8:1000::200
    dns-nameservers 2001:db8:1000::1

auto ens3:1
iface ens3:1 inet static
    address 192.0.2.102
    netmask 255.255.255.255

auto ens3:2
iface ens3:2 inet static
    address 192.0.2.103
    netmask 255.255.255.255

# Private network 1
auto ens7
iface ens7 inet static
    address 10.1.1.100
    netmask 255.255.240.0
    mtu 1450

# Private network 2
auto ens8
iface ens8 inet static
    address 10.1.1.200
    netmask 255.255.240.0
    mtu 1450

Restart networking or reboot to activate the network changes.

# systemctl restart networking.service

Example for Debian 7 and 8

Configure the public network with three public IPv4 addresses and two public IPv6 addresses. Configure two private networks.

Populate /etc/network/interfaces with:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.0.2.101
    netmask 255.255.254.0
    gateway 192.0.2.1
    dns-nameservers 192.0.2.200
    post-up ip route add 169.254.0.0/16 dev eth0

iface eth0 inet6 static
    address 2001:db8:1000::100
    netmask 64
    up /sbin/ip -6 addr add dev eth0 2001:db8:1000::200
    dns-nameservers 2001:db8:1000::1

auto eth0:1
iface eth0:1 inet static
    address 192.0.2.102
    netmask 255.255.255.255

auto eth0:2
iface eth0:2 inet static
    address 192.0.2.103
    netmask 255.255.255.255

# Private network: net5eea3b295857e
auto eth1
iface eth1 inet static
    address 10.1.1.100
    netmask 255.255.240.0
    mtu 1450

# Private network: net5eea4e6f7f6c8
auto eth2
iface eth2 inet static
    address 10.1.1.200
    netmask 255.255.240.0
    mtu 1450

Restart networking or reboot to activate the network changes.

# systemctl restart networking.service

Nameservers

Verify that /etc/resolv.conf has your preferred nameservers for IPv4, and optionally IPv6.

domain       example.com
nameserver   2001:db8:1000::1
nameserver   192.0.2.200

More Resources

Want to contribute?

You could earn up to $600 by adding new articles


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK