Configuring multiple public network Interfaces

The use of multiple public interfaces attached to an single instance is possible for IPV4 and IPV6 using an OpenStack instance. 

An instance configured using the horizon web- interface or the OpenStack CLI tools needs to be configured to make multiple public addresses available from the internet binding them to the correct network interface and gateway. The example below describes how- to do this for Ubuntu as well as CentOS. In this example we configure 2 IPV4 and 2 IPV6 interfaces using an single OpenStack instance.

  • Updating the Routing table for Ubuntu and CentOS ​

First adjust the routing table by adding an entry for every network interface attached to the instance.

Open the routing table with an appropriate editor.

vim /etc/iproute2/rt_tables

 

In this example we use 4 network interfaces. We need to create a route table entry for each interface: table1, table2, table3 and table4. Every routing table had its own priority like the example below.

#
# reserved values
#
255    local
254    main
253    default
0    unspec
#
# local
#
#1    inr.ruhep

# Public interfaces
100    table1 
101    table2
102    table3 
103    table4

 

Enable IP Forwarding 

  • Check if IP forwarding is enabled.
sysctl net.ipv4.ip_forward

Output value must be 1 , if  0 then enable IP forwarding. 

net.ipv4.ip_forward = 1
  • Enabling IP forwarding, open the sysctl configuration with an appropriate editor.
vim /etc/sysctl.conf

Add the line below at the end of the configration file. 

net.ipv4.ip_forward = 1

Reload sysctl to make the change active.

sysctl --system

 

  • Setup the Network configuration with Ubunu

Open the network interface configuration.

vim /etc/network/interfaces

The example below shows how to configure the network routing for multiple addresses. Every interface uses dhcp to retrieve the network address, and ip route statics to setup the correct routing.  Please adjust the example below accordingly your own situation. It's not possible to setup IPV6 routing using the network configuration file.

# The First network interface: Public IPV4 IP 83.96.255.29
auto     eth0
iface    eth0        inet dhcp 

    post-up      ip route add 83.96.252.0/22 dev eth0 src 83.96.255.29 table table1
    post-up      ip route add default via 83.96.252.1 dev eth0 table table1
    post-up      ip rule add from 83.96.255.29/32 table table1
    post-up      ip rule add to 83.96.255.29/32 table table1
    post-down    ip route del 83.96.252.0/22 dev eth0 src 83.96.255.29 table table1
    post-down    ip route del default via 83.96.252.1 dev eth0 table table1
    post-down    ip rule del from 83.96.255.29/32 table table1
    post-down    ip rule del to 83.96.255.29/32 table table1


# The Second network interface: Public IPV4 IP 83.96.242.164
auto     eth1
iface    eth1        inet dhcp 

    post-up      ip route add 83.96.240.0/22 dev eth1 src 83.96.242.164 table table2
    post-up      ip route add default via 83.96.240.1 dev eth1 table table2
    post-up      ip rule add from 83.96.242.164/32 table table2
    post-up      ip rule add to 83.96.242.164/32 table table2
    post-down    ip route del 83.96.240.0/22 dev eth1 src 83.96.242.164 table table2
    post-down    ip route del default via 83.96.240.1 dev eth1 table table2
    post-down    ip rule del from 83.96.242.164/32 table table2
    post-down    ip rule del to 83.96.242.164/32 table table2

# The Thirth network interface:    Public IPV6 IP 2a02:348:5e6:1::ab40
auto     eth2
iface    eth2        inet dhcp 

# The Fourth network interface:    Public IPV6 IP 2a02:348:5e6:1::ab40
auto eth3
    iface eth3       inet6 dhcp

Configuring IPV6 routes does not work with the normal network configuration, to do so please adjust the /etc/rc.local configuration.

vim /etc/rc.local

Like the example below, please adjust accordingly your situation.

#!/bin/sh

sleep 5

# ip -6 route add <SUBNET> dev <DEVICE> src <IPV6_ADDRESS> table <TABLE_NAME>
# ip -6 route add default via <IPV6_GATEWAY> dev <DEVICE> table <TABLE_NAME>
# ip -6 rule add from <IPV6_ADDRESS/NETMASKER> table <TABLE_NAME>
# ip -6 rule add to <IPV6_ADDRESS/NETMASKER> table <TABLE_NAME>

ip -6 route add 2a02:348:5e6:1::/112 dev eth2 src 2a02:348:5e6:1::ab40 table table3
ip -6 route add default via 2a02:348:5e6:1::1 dev eth2 table table3
ip -6 rule add from 2a02:348:5e6:1::ab40/128 table table3
ip -6 rule add to 2a02:348:5e6:1::ab40/128 table table3

ip -6 route add 2a02:348:5e6:1::/112 dev eth3 src 2a02:348:5e6:1::ab40 table table4
ip -6 route add default via 2a02:348:5e6:1::1 dev eth3 table table4
ip -6 rule add from 2a02:348:5e6:1::ab40/128 table table4
ip -6 rule add to 2a02:348:5e6:1::ab40/128 table table4


exit 0

Please restart the instance to make the network changes active.

 

Setup the Network configuration with CentOS ​

Check or create the configuration for each network interfaces attached to the instance.

  • The First network interface
vim /etc/sysconfig/network-scripts/ifcfg-eth0

Configure like below

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp
NM_CONTROLLED=no

 

  • The Second network interface
vim /etc/sysconfig/network-scripts/ifcfg-eth1

Configure like below

DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp
NM_CONTROLLED=no

 

  • The Thirth network interface
vim /etc/sysconfig/network-scripts/ifcfg-eth2

Configure like below

DEVICE=eth2
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp
NM_CONTROLLED=no

 

  • The Fourth network interface
vim /etc/sysconfig/network-scripts/ifcfg-eth3

Configure like below

DEVICE=eth3
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp
NM_CONTROLLED=no

 

For each network interface create a Routing en Rules configuration.

  • The First network interface

Routes Configuration

vim /etc/sysconfig/network-scripts/route-eth0

Configure like below

83.96.252.0/22 dev eth0 src 83.96.255.29 table table1
default via 83.96.252.1 dev eth0 table table1

Rules Configuration

vim /etc/sysconfig/network-scripts/rule-eth0

Configure like below

from 83.96.255.29/32 table table1
to 83.96.255.29/32 table table1

 

  • The Second network interface

Routes Configuration

vim /etc/sysconfig/network-scripts/route-eth1

Configure like below

83.96.240.0/22 dev eth1 src 83.96.242.164 table table2
default via 83.96.240.1 dev eth1 table table2

Rules Configuration

vim /etc/sysconfig/network-scripts/rule-eth1

Configure like below

from 83.96.242.164/32 table table2
to 83.96.242.164/32 table table2

Configuring IPV6 routes does not work with the normal network configuration, to do so please adjust the /etc/rc.local configuration.

vim /etc/rc.local

Like the example below, please adjust accordingly your situation.

#!/bin/sh

sleep 5

# ip -6 route add <SUBNET> dev <DEVICE> src <IPV6_ADDRESS> table <TABLE_NAME>
# ip -6 route add default via <IPV6_GATEWAY> dev <DEVICE> table <TABLE_NAME>
# ip -6 rule add from <IPV6_ADDRESS/NETMASKER> table <TABLE_NAME>
# ip -6 rule add to <IPV6_ADDRESS/NETMASKER> table <TABLE_NAME>

ip -6 route add 2a02:348:5e6:1::/112 dev eth2 src 2a02:348:5e6:1::ab40 table table3
ip -6 route add default via 2a02:348:5e6:1::1 dev eth2 table table3
ip -6 rule add from 2a02:348:5e6:1::ab40/128 table table3
ip -6 rule add to 2a02:348:5e6:1::ab40/128 table table3

ip -6 route add 2a02:348:5e6:1::/112 dev eth3 src 2a02:348:5e6:1::ab40 table table4
ip -6 route add default via 2a02:348:5e6:1::1 dev eth3 table table4
ip -6 rule add from 2a02:348:5e6:1::ab40/128 table table4
ip -6 rule add to 2a02:348:5e6:1::ab40/128 table table4


exit 0

Enable the rc.local during a system startup start- up.

systemctl enable rc-local

Please restart the instance to make the network changes active.

Helpcenter

General FAQ

Show all FAQs

OpenStack FAQ

Show all FAQs

Knowledgebase

Show all FAQs