Como configurar uma rede privada no Linux
Rede privada é uma rede entre dois terminais ligadas pela internet,
nesse exemplo vou mostrar como é super facil criar uma rede privada VPN entre dois computadores linux conectados a internet,
observe que suponho que funcionou porque um dos computadores tem um IP publico, mesmo que dinamico, vamos lá:
1) li varias possibilidades de fazer mas quem mais me chamou a atenção foi:
https://wiki.debian.org/OpenVPN open vpn
então basta instalar como administrador:
>su
#digite a senha de admin
>apt install open-vpn
instalar no cliente e no servidor
agora vamos testar,
no servidor (ip publico) o comando é simples:
root@MiqueiasNoteHP:/home/mfernandes# openvpn --dev tun1 --ifconfig 10.9.8.1 10.9.8.2
Mon Jun 11 22:21:54 2018 disabling NCP mode (--ncp-disable) because not in P2MP client or server mode
Mon Jun 11 22:21:54 2018 OpenVPN 2.4.0 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Jul 18 2017
Mon Jun 11 22:21:54 2018 library versions: OpenSSL 1.0.2l 25 May 2017, LZO 2.08
Mon Jun 11 22:21:54 2018 ******* WARNING *******: all encryption and authentication features disabled -- all data will be tunnelled as cleartext
Mon Jun 11 22:21:54 2018 TUN/TAP device tun1 opened
Mon Jun 11 22:21:54 2018 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Mon Jun 11 22:21:54 2018 /sbin/ip link set dev tun1 up mtu 1500
Mon Jun 11 22:21:54 2018 /sbin/ip addr add dev tun1 local 10.9.8.1 peer 10.9.8.2
Mon Jun 11 22:21:54 2018 Could not determine IPv4/IPv6 protocol. Using AF_INET
Mon Jun 11 22:21:54 2018 UDPv4 link local (bound): [AF_INET][undef]:1194
Mon Jun 11 22:21:54 2018 UDPv4 link remote: [AF_UNSPEC]
Mon Jun 11 22:21:58 2018 Peer Connection Initiated with [AF_INET]200.137.72.202:35432
Mon Jun 11 22:22:00 2018 Initialization Sequence Completed
como administrador, certo,
agora no cliente:
root@bioserver1:/home/mfernandes# openvpn --remote IP_REMOTO --dev tun1 --ifconfig 10.9.8.2 10.9.8.1
Mon Jun 11 22:21:48 2018 disabling NCP mode (--ncp-disable) because not in P2MP client or server mode
Mon Jun 11 22:21:48 2018 OpenVPN 2.4.0 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Jul 18 2017
Mon Jun 11 22:21:48 2018 library versions: OpenSSL 1.0.2l 25 May 2017, LZO 2.08
Mon Jun 11 22:21:48 2018 ******* WARNING *******: all encryption and authentication features disabled -- all data will be tunnelled as cleartext
Mon Jun 11 22:21:48 2018 TUN/TAP device tun1 opened
Mon Jun 11 22:21:48 2018 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Mon Jun 11 22:21:48 2018 /sbin/ip link set dev tun1 up mtu 1500
Mon Jun 11 22:21:48 2018 /sbin/ip addr add dev tun1 local 10.9.8.2 peer 10.9.8.1
Mon Jun 11 22:21:48 2018 TCP/UDP: Preserving recently used remote address: [AF_INET]179.109.10.65:1194
Mon Jun 11 22:21:48 2018 UDP link local (bound): [AF_INET][undef]:1194
Mon Jun 11 22:21:48 2018 UDP link remote: [AF_INET]179.109.10.65:1194
Mon Jun 11 22:21:58 2018 Peer Connection Initiated with [AF_INET]179.109.10.65:1194
Mon Jun 11 22:22:00 2018 Initialization Sequence Completed
pronto!
esses dois ips serao da maquina local e remota respectivamente olhando pelo lado do cliente, ou basta testar, [detalhe] qq porta!
10.9.8.2
10.9.8.1
abçss
nesse exemplo vou mostrar como é super facil criar uma rede privada VPN entre dois computadores linux conectados a internet,
observe que suponho que funcionou porque um dos computadores tem um IP publico, mesmo que dinamico, vamos lá:
1) li varias possibilidades de fazer mas quem mais me chamou a atenção foi:
https://wiki.debian.org/OpenVPN open vpn
então basta instalar como administrador:
>su
#digite a senha de admin
>apt install open-vpn
instalar no cliente e no servidor
agora vamos testar,
no servidor (ip publico) o comando é simples:
root@MiqueiasNoteHP:/home/mfernandes# openvpn --dev tun1 --ifconfig 10.9.8.1 10.9.8.2
Mon Jun 11 22:21:54 2018 disabling NCP mode (--ncp-disable) because not in P2MP client or server mode
Mon Jun 11 22:21:54 2018 OpenVPN 2.4.0 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Jul 18 2017
Mon Jun 11 22:21:54 2018 library versions: OpenSSL 1.0.2l 25 May 2017, LZO 2.08
Mon Jun 11 22:21:54 2018 ******* WARNING *******: all encryption and authentication features disabled -- all data will be tunnelled as cleartext
Mon Jun 11 22:21:54 2018 TUN/TAP device tun1 opened
Mon Jun 11 22:21:54 2018 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Mon Jun 11 22:21:54 2018 /sbin/ip link set dev tun1 up mtu 1500
Mon Jun 11 22:21:54 2018 /sbin/ip addr add dev tun1 local 10.9.8.1 peer 10.9.8.2
Mon Jun 11 22:21:54 2018 Could not determine IPv4/IPv6 protocol. Using AF_INET
Mon Jun 11 22:21:54 2018 UDPv4 link local (bound): [AF_INET][undef]:1194
Mon Jun 11 22:21:54 2018 UDPv4 link remote: [AF_UNSPEC]
Mon Jun 11 22:21:58 2018 Peer Connection Initiated with [AF_INET]200.137.72.202:35432
Mon Jun 11 22:22:00 2018 Initialization Sequence Completed
como administrador, certo,
agora no cliente:
root@bioserver1:/home/mfernandes# openvpn --remote IP_REMOTO --dev tun1 --ifconfig 10.9.8.2 10.9.8.1
Mon Jun 11 22:21:48 2018 disabling NCP mode (--ncp-disable) because not in P2MP client or server mode
Mon Jun 11 22:21:48 2018 OpenVPN 2.4.0 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Jul 18 2017
Mon Jun 11 22:21:48 2018 library versions: OpenSSL 1.0.2l 25 May 2017, LZO 2.08
Mon Jun 11 22:21:48 2018 ******* WARNING *******: all encryption and authentication features disabled -- all data will be tunnelled as cleartext
Mon Jun 11 22:21:48 2018 TUN/TAP device tun1 opened
Mon Jun 11 22:21:48 2018 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Mon Jun 11 22:21:48 2018 /sbin/ip link set dev tun1 up mtu 1500
Mon Jun 11 22:21:48 2018 /sbin/ip addr add dev tun1 local 10.9.8.2 peer 10.9.8.1
Mon Jun 11 22:21:48 2018 TCP/UDP: Preserving recently used remote address: [AF_INET]179.109.10.65:1194
Mon Jun 11 22:21:48 2018 UDP link local (bound): [AF_INET][undef]:1194
Mon Jun 11 22:21:48 2018 UDP link remote: [AF_INET]179.109.10.65:1194
Mon Jun 11 22:21:58 2018 Peer Connection Initiated with [AF_INET]179.109.10.65:1194
Mon Jun 11 22:22:00 2018 Initialization Sequence Completed
pronto!
esses dois ips serao da maquina local e remota respectivamente olhando pelo lado do cliente, ou basta testar, [detalhe] qq porta!
10.9.8.2
10.9.8.1
abçss
Comentários
Postar um comentário