Introdução

Index:NetplanifupdownHabilitar Internet

 

Configuração utilizando: Netplan

Exemplo de Arquivo de configuração de redes utilizando netplan, no Ubuntu Server 18.


network:
        version: 2
        ethernets:
                enp0s3:
                        optional: false
                enp0s9:
                        optional: false
                enp0s10:
                        optional: false
                enp0s8:
                        optional: false
        vlans:
                enp0s3.5:
                        id: '5'
                        link: 'enp0s3'
                        optional: false
                enp0s3.10:
                        id: '10'
                        link: 'enp0s3'
                        optional: false
                enp0s3.20:
                        id: '20'
                        link: 'enp0s3'
                        optional: false
                enp0s3.30:
                        id: '30'
                        link: 'enp0s3'
                        optional: false
        bridges:
                br_giga:
                        addresses: []
                        dhcp4: true
                        interfaces: [enp0s3]
                        optional: false
                        parameters:
                                stp: false
                br_internet:
                        addresses: [177.125.143.8/27]
                        gateway4: 177.125.143.1
                        interfaces: [enp0s3.30]
                        optional: false
                        nameservers:
                                addresses: [8.8.8.8,8.8.4.4]
                        parameters:
                                stp: false
                br_control:
                        addresses: [10.138.0.30/16]
                        interfaces: [enp0s3.10]
                        optional: false
                        routes:
                              - to: 10.0.0.0/8
                                via: 10.138.0.1
                                on-link: true
                        parameters:
                                stp: false
                br_cmc:
                        addresses: [172.16.138.30/24]
                        interfaces: [enp0s3.5]
                        optional: false
                        parameters:
                                stp: false
                br_exp1:
                        interfaces: [enp0s9]
                        optional: false
                        parameters:
                                stp: false
                br_exp2:
                        interfaces: [enp0s10]
                        optional: false
                        parameters:
                                stp: false

 

Feita as configurações no arquivo yaml, aplique-as com o seguinte comando:

netplan apply

 

Configuração utilizando: ifupdown

 

Ao utilizar o ifupdown é possível reaproveitar as configurações do /etc/network/interfaces. Para que o uso do ifupdown seja feito com sucesso, realize os seguintes procedimentos:

 

Desabilitar o Netplan.

cd /etc/netplan/
rm /etc/netplan/*.yaml


Instale o pacote do ifupdown.

 

apt-get install ifupdown

 

Edite o arquivo interfaces.

vim /etc/network/interfaces

 

Conteúdo de exemplo:

É importante remapear as interfaces de acordo com as novas notações.
auto lo
iface lo inet loopback

auto br_giga
iface br_giga inet dhcp
bridge_ports eth0.20
bridge-stp off
bridge-maxwait 2

auto br_internet
iface br_internet inet static
address 177.125.143.8
netmask 255.255.255.224
dns-nameservers 177.125.142.47 8.8.8.8 8.8.4.4
gateway 177.125.143.1
bridge_ports eth0.30
bridge-stp off
bridge-maxwait 2

auto br_control
iface br_control inet static
bridge_ports eth0.10
bridge-stp off
bridge-maxwait 2
address 10.138.0.30
netmask 255.255.0.0
dns-nameservers 10.138.0.80 8.8.8.8 8.8.4.4
post-up ip route add 10.0.0.0/8 via 10.138.0.1

auto br_cmc
iface br_cmc inet static
bridge_ports eth0.5
bridge-stp off
bridge-maxwait 2
address 172.16.138.30
netmask 255.255.255.0

auto br_exp1
iface br_exp1 inet manual
bridge_ports eth2
bridge-stp off
bridge-maxwait 2

auto br_exp2
iface br_exp2 inet manual
bridge_ports eth3
bridge-stp off
bridge-maxwait 2

auto br_exp3
iface br_exp3 inet manual
bridge_ports eth1
bridge-stp off
bridge-maxwait 2

 

Aplicadas as configurações do ifupdown, recomendamos reiniciar o servidor.

 

Habilitar Internet para VMs

Para habilitar a Internet para as VMs, recomendamos os seguintes procedimentos.


Método provisório:

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.XXX.0.0/16 -o br_internet -j MASQUERADE

 

Aonde XXX é o ID da ilha.