PERGUNTA:
Tenho uma infraestrutura com 5 servidores (Server #1, #2, #3, #4 e #5). Estou tentando usar um servidor (servidor #5) com ISC KEA DHCP (DHCPv4) ( https://kea.isc.org/wiki ) para enviar rotas para outros servidores (servidor #1, #2, #3 e # 4). O objetivo é que todos os servidores possam se comunicar com outros ( ping
, ssh
, etc) usando uma LAN entre os Servidores #2 e 3# (um túnel VPN).
SERVIDORES:
Server #1 - DHCPv4 Client;
Server #2 - DHCPv4 Client and OpenVPN Server;
Server #3 - DHCPv4 Client and OpenVPN Client;
Server #4 - DHCPv4 Client;
Server #5 - ISC KEA DHCP (DHCPv4).
SUB-REDES:
192.168.56.0/24
10.1.2.0/24
10.1.4.0/24
10.1.6.0/24
10.8.0.1/24 (VPN tunnel)
CONFIGURAÇÕES DE SERVIDORES:
NOTA: A infraestrutura apresentada aqui faz parte de um ambiente de teste que criei no VirtualBox para rodar os testes (não o ambiente real). A rede 192.168.56.0/24, por exemplo, está presente em todos os servidores.
Informações sobre as LANs (interfaces de rede) de cada servidor...
Servidor1
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:56:84:1f brd ff:ff:ff:ff:ff:ff
inet 10.1.6.3/24 brd 10.1.6.255 scope global noprefixroute dynamic enp0s8
valid_lft 3514sec preferred_lft 3514sec
inet6 fe80::a00:27ff:fe56:841f/64 scope link
valid_lft forever preferred_lft forever
3: enp0s17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:12:26:e2:6c brd ff:ff:ff:ff:ff:ff
inet 192.168.56.3/24 brd 192.168.56.255 scope global noprefixroute dynamic enp0s17
valid_lft 3606sec preferred_lft 3606sec
inet6 fe80::a00:12ff:fe26:e26c/64 scope link
valid_lft forever preferred_lft forever
Servidor #2
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:2c:d1:58 brd ff:ff:ff:ff:ff:ff
inet 10.1.6.4/24 brd 10.1.6.255 scope global noprefixroute dynamic enp0s8
valid_lft 3856sec preferred_lft 3856sec
inet6 fe80::a00:27ff:fe2c:d158/64 scope link
valid_lft forever preferred_lft forever
3: enp0s17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:1c:a6:b9:59 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.4/24 brd 192.168.56.255 scope global noprefixroute dynamic enp0s17
valid_lft 3897sec preferred_lft 3897sec
inet6 fe80::a00:1cff:fea6:b959/64 scope link
valid_lft forever preferred_lft forever
4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
link/none
inet 10.8.0.1/24 brd 10.8.0.255 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::ec75:f69e:e65c:1215/64 scope link flags 800
valid_lft forever preferred_lft forever
Servidor #3
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:71:77:07 brd ff:ff:ff:ff:ff:ff
inet 10.1.4.5/24 brd 10.1.4.255 scope global noprefixroute dynamic enp0s8
valid_lft 3741sec preferred_lft 3741sec
inet6 fe80::a00:27ff:fe71:7707/64 scope link
valid_lft forever preferred_lft forever
3: enp0s17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:ea:4e:40:ae brd ff:ff:ff:ff:ff:ff
inet 192.168.56.5/24 brd 192.168.56.255 scope global noprefixroute dynamic enp0s17
valid_lft 3766sec preferred_lft 3766sec
inet6 fe80::a00:eaff:fe4e:40ae/64 scope link
valid_lft forever preferred_lft forever
4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
link/none
inet 10.8.0.6/24 brd 10.8.0.255 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::6763:9d85:a754:bf0f/64 scope link flags 800
valid_lft forever preferred_lft forever
Servidor #4
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:e0:d2:c8 brd ff:ff:ff:ff:ff:ff
inet 10.1.4.6/24 brd 10.1.4.255 scope global noprefixroute dynamic enp0s8
valid_lft 3907sec preferred_lft 3907sec
inet6 fe80::a00:27ff:fee0:d2c8/64 scope link
valid_lft forever preferred_lft forever
3: enp0s17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:aa:e7:60 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.6/24 brd 192.168.56.255 scope global noprefixroute dynamic enp0s17
valid_lft 3907sec preferred_lft 3907sec
inet6 fe80::a00:27ff:feaa:e760/64 scope link
valid_lft forever preferred_lft forever
Servidor #5
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:63:ce:c5 brd ff:ff:ff:ff:ff:ff
inet 10.1.2.2/24 brd 10.1.2.255 scope global noprefixroute enp0s8
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe63:cec5/64 scope link
valid_lft forever preferred_lft forever
3: enp0s9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:98:ee:35 brd ff:ff:ff:ff:ff:ff
inet 10.1.4.2/24 brd 10.1.4.255 scope global noprefixroute enp0s9
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe98:ee35/64 scope link
valid_lft forever preferred_lft forever
4: enp0s10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:b6:6b:50 brd ff:ff:ff:ff:ff:ff
inet 10.1.6.2/24 brd 10.1.6.255 scope global noprefixroute enp0s10
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:feb6:6b50/64 scope link
valid_lft forever preferred_lft forever
5: enp0s17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:78:ed:d4 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.2/24 brd 192.168.56.255 scope global noprefixroute enp0s17
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe78:edd4/64 scope link
valid_lft forever preferred_lft forever
Obrigado!
Sobre esta resposta (tutorial):
Este tutorial destina-se a demonstrar um "caso de sucesso" para a configuração e implantação do ISC KEA DHCP (DHCPv4). Demonstrar particularmente o push de rotas para clientes DHCP. Outros pontos também são considerados para o caso específico e existem para tornar a demonstração mais didática.
No caso específico (simulação usando VirtualBox) usamos um túnel OpenVPN e demonstramos como fazer um roteamento para usá-lo de duas maneiras em uma infraestrutura LAN-TO-LAN.
Este tutorial foi construído considerando um cenário onde temos um servidor na Internet (Serverloft) rodando um Hypervisor (Xen) em uma ponta da VPN e uma LAN corporativa na outra ponta da VPN onde todos os servidores de ambas as redes são capazes comunicar de forma transparente.
Outras considerações são feitas ao longo deste tutorial e recomendamos que você o leia na íntegra.
Sentimos a necessidade de fazer este tutorial já que nada "prático" como ele pode ser encontrado na internet. Este tutorial também tem como alvo um público que como nós tem maior dificuldade com os conceitos básicos aqui apresentados.
Antes de continuarmos, gostaríamos de agradecer às muitas pessoas que ajudaram nesse processo. Em especial agradecemos aos usuários: @Filipe Brandenburger , @Rui F Ribeiro , @AB , @Isaac, @slm e outros (infelizmente não podemos citar todos).
Servidores neste tutorial:
NOTA: Todos os servidores são CentOS 7.
Sub-redes:
Servidor #5 - Servidor ISC KEA DHCP (DHCPv4):
. Instalando ISC KEA DHCP (DHCPv4) no CentOS 7
. Crie configurações (configurações de inicialização) para serviços KEA no systemd (systemctl)...
vi '/usr/lib/systemd/system/kea-dhcp4.service'
vi '/usr/lib/systemd/system/kea-dhcp6.service'
vi '/usr/lib/systemd/system/kea-dhcp-ddns.service'
. Crie (ajuste) o arquivo de configuração "/usr/local/etc/kea/kea-dhcp4.conf"...
vi '/usr/local/etc/kea/kea-dhcp4.conf'
. Configurar interfaces de rede
Essas interfaces de rede fornecerão o servidor DHCP para todas as máquinas (consulte "kea-dhcp4.conf" acima).
NOTE: In a REAL WORLD SCENARIO the machines that are on the "OpenVPN server side network" would own a DHCP server and machines that are on the "OpenVPN client side network" would own another DHCP server. This division works perfectly as we are talking about the "layer 2" of the OSI model, which is therefore isolated from "layer 3" where there will be "routing", "ip forward" etc, which will be part of the integration between the two networks.
vi '/etc/sysconfig/network-scripts/ifcfg-enp0s17'
vi '/etc/sysconfig/network-scripts/ifcfg-enp0s8'
vi '/etc/sysconfig/network-scripts/ifcfg-enp0s9'
vi '/etc/sysconfig/network-scripts/ifcfg-enp0s10'
Server #2 - Client DHCPv4 and OpenVPN Server:
. OpenVPN server settings
vi '/etc/openvpn/server/server.conf'
IMPORTANT: We are only considering the CONFIGURATIONS STRICTLY NECESSARY FOR THE OPENVPN OPERATION IN THE PROPOSED INFRASTRUCTURE ("server.conf" and "client0"). Other settings are required. For more information, check out the OpenVPN documentation. More details on the needs addressed here at this link https://openvpn.net/index.php/open-source/documentation/howto.html#scope .
. OpenVPN client settings
NOTE: These settings are consumed by the client on the server side.
vi '/etc/openvpn/ccd/client0'
Server #3 - Client DHCPv4 and OpenVPN Client
. OpenVPN client settings
vi '/etc/openvpn/client/client0.conf'
Server #2 e #3:
. Open the firewall for "OpenVPN" (Server #2 and #3)
NOTE: Openvpn is not the focus of the thread so we will not go into details here!
. Enable "ip_forward" (Server #2 and #3)
Server #1, #2, #3 e #4:
. Configure network interfaces
vi '/etc/sysconfig/network-scripts/ifcfg-enp0s8'
NOTE: All interfaces in all machines follow this same model since the network configurations will be provided by Server #5 (KEA DHCP Server).
vi '/etc/sysconfig/network'
Test:
. This tutorial will have been successfully executed if all of these tests are positive:
Tips:
Internet (WAN) test
Renew DHCP on clients
Remove DHCP leases settings from clients:
NOTE: Important to test the operation of the DHCP server.
Remove DHCP leases settings from server:
NOTE: Important to test the operation of the DHCP server.
Other guidelines:
General guidelines and about the environment used for this tutorial:
This configuration tutorial was built in a test environment using VirtualBox;
All networks in use are "Host-only" and one of them (192.168.56.0/24) has internet (see 3). None of them should have VirtualBox DHCP enabled;
By default "Host-only" networks have no internet access ( https://www.virtualbox.org/manual/ch06.html#networkingmodes ). However, in this tutorial https://forum.manjaro.org/t/manjaro-and-virtualbox-host-only-with-internet/28722/12 I teach how to "circumvent" this limitation;
The internet (WAN) for the 192.168.56.0/24 network must be activated only when it is necessary. Must be disabled for running tests except to check internet access (
curl http://www.google.com
) on Servers #1, #2, #3 and #4 (see 3);Services such as "dnsmasq" and "iptables" should be disabled on the host when the network tests are executed (ping, ssh, etc) (see 3);
Generally speaking, no DHCP should be present on layer 2 of the networks during the tests except what is on Server #5.
Use tun or tap (OpenVPN) - A Discussion:
We transpose below part of a chat ( chat.stackexchange.com ) between @Eduardo Lucio and @Isaac about the deploy model in this answer. We ( @Eduardo Lucio ) opted, at the moment, for using "tun", even though it was a "more laborious" configuration. However if you want a truly transparent integration between the networks on both sides of the VPN opt for tap (with all its pros and cons). I believe that the clarifications of @Isaac are very relevant to decide what to use (tap or tun) and so are transposed here so that it can reach more people.