
		sgtmaykel
		
		(usa Linux Mint)
		
		Enviado em 13/02/2014 - 13:44h 
		boa tarde, estou tentando montar um tunel vpn entre 2 máquinas virtuais com fins didáticos, porém só tem dado erro.
configuração máquina servidor:
maykel-virtual-machine maykel # apt-get install openvpn
maykel-virtual-machine maykel # openvpn --genkey --secret /etc/openvpn/chave
maykel-virtual-machine maykel # cat /etc/openvpn/chave
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
f6fec9f85220af2f35ea4a5263f12def
338fdd21ef256fe4e674ae9f40cbde61
e2348ac18dc880e89feeb6dca5fc8141
8ae459ec8d0c7ae6a1eaf14f30a7a632
8fd6ce67584ca1d00db7ee3574e0ea88
6d0dbc4586a90f2460cb070af3566a3e
be59ae77b633003c8ceadaabf3ead083
4665516c531ef168cccb9ab4d5decf9a
9c53a74cc214052cf0d4a725b79ad07b
5f47e816e83ccc509b172729707a39cf
23d2be744191e50a320e693d7037dbbd
1f1069dd2f2e64d6475cd3621b5d9339
fb22d66811aeb78d1a2e22481a3583d9
67c8c47dc4445b19d75753a1be643e37
0deeb469b670bc5e7eea04261a7cac34
4b0d86473e8dec35dd437f2b743e4054
-----END OpenVPN Static key V1-----
maykel-virtual-machine maykel # gedit /etc/openvpn/matriz.conf
     dev tun
    # 10.0.1.1 ip da matriz
    # 10.0.1.2 ip remoto, ou seja, o ip da filial
    ifconfig 10.0.1.1 10.0.1.2
    # Indica que esse túnel possui uma chave de criptografia
    secret /etc/openvpn/chave
    # OpenVPN usa a porta 5000/UDP por padrão.
    # Cada túnel do OpenVPN deve usar
    # uma porta diferente.
    # O padrão é a porta 5000 # Se omitido, será criada a conexão na porta 5000
    port 5000
    # Usuário que rodará o daemon do OpenVPN
    user nobody
    # Usa a biblioteca lzo
    comp-lzo
    # Mantem a conexão enviando pings
    # de 15 em 15 segundos.
    ping 15
    # Nível de log
    verb 3 
maykel-virtual-machine maykel # ifconfig
eth0      Link encap:Ethernet  Endereço de HW 00:0c:29:46:3e:6a  
          inet end.: 192.168.65.140  Bcast:192.168.65.255  Masc:255.255.255.0
          endereço inet6: fe80::20c:29ff:fe46:3e6a/64 Escopo:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Métrica:1
          pacotes RX:7857 erros:0 descartados:0 excesso:0 quadro:0
          Pacotes TX:5700 erros:0 descartados:0 excesso:0 portadora:0
          colisões:0 txqueuelen:1000 
          RX bytes:8500370 (8.5 MB) TX bytes:628248 (628.2 KB)
          IRQ:19 Endereço de E/S:0x2000 
lo        Link encap:Loopback Local  
          inet end.: 127.0.0.1  Masc:255.0.0.0
          endereço inet6: ::1/128 Escopo:Máquina
          UP LOOPBACK RUNNING  MTU:65536  Métrica:1
          pacotes RX:200 erros:0 descartados:0 excesso:0 quadro:0
          Pacotes TX:200 erros:0 descartados:0 excesso:0 portadora:0
          colisões:0 txqueuelen:0 
          RX bytes:25613 (25.6 KB) TX bytes:25613 (25.6 KB)
tun0      Link encap:Não Especificado  Endereço de HW 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet end.: 10.0.1.1  P-a-P:10.0.1.2  Masc:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Métrica:1
          pacotes RX:0 erros:0 descartados:0 excesso:0 quadro:0
          Pacotes TX:0 erros:0 descartados:0 excesso:0 portadora:0
          colisões:0 txqueuelen:100 
          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
maykel-virtual-machine maykel # openvpn --config /etc/openvpn/matriz.conf -daemon
Thu Feb 13 13:04:42 2014 OpenVPN 2.3.2 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Jul 12 2013
Thu Feb 13 13:04:42 2014 WARNING: --ping should normally be used with --ping-restart or --ping-exit
Thu Feb 13 13:04:42 2014 WARNING: you are using user/group/chroot/setcon without persist-tun -- this may cause restarts to fail
Thu Feb 13 13:04:42 2014 WARNING: you are using user/group/chroot/setcon without persist-key -- this may cause restarts to fail
Thu Feb 13 13:04:42 2014 Static Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Feb 13 13:04:42 2014 Static Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Feb 13 13:04:42 2014 Static Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Feb 13 13:04:42 2014 Static Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Feb 13 13:04:42 2014 Socket Buffers: R=[212992->131072] S=[212992->131072]
Thu Feb 13 13:04:42 2014 TCP/UDP: Socket bind failed on local address [undef]: Address already in use
Thu Feb 13 13:04:42 2014 Exiting due to fatal error
configuração máquina filial:
maykel-virtual-machine maykel # apt-get install openvpn
####Na máquina matriz realizei o seguinte comando para transferir a chave gerada na matriz para a filial:
maykel-virtual-machine maykel # scp /etec/openvpn/chave 192.168.65.139:/etc/openvpn/chave
####onde 192.168.65.139 é o ip da máquina filial. e para conferir se a chave é a mesma o seguinte comando já na máquina filial:
maykel-virtual-machine maykel # cat /etc/openvpn/chave
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
f6fec9f85220af2f35ea4a5263f12def
338fdd21ef256fe4e674ae9f40cbde61
e2348ac18dc880e89feeb6dca5fc8141
8ae459ec8d0c7ae6a1eaf14f30a7a632
8fd6ce67584ca1d00db7ee3574e0ea88
6d0dbc4586a90f2460cb070af3566a3e
be59ae77b633003c8ceadaabf3ead083
4665516c531ef168cccb9ab4d5decf9a
9c53a74cc214052cf0d4a725b79ad07b
5f47e816e83ccc509b172729707a39cf
23d2be744191e50a320e693d7037dbbd
1f1069dd2f2e64d6475cd3621b5d9339
fb22d66811aeb78d1a2e22481a3583d9
67c8c47dc4445b19d75753a1be643e37
0deeb469b670bc5e7eea04261a7cac34
4b0d86473e8dec35dd437f2b743e4054
-----END OpenVPN Static key V1-----
maykel-virtual-machine maykel # gedit /etc/openvpn/filial.conf
     dev tun
    # 10.0.1.1 ip da matriz
    # 10.0.1.2 ip remoto, ou seja, o ip da filial
    ifconfig 10.0.1.2 10.0.1.1
    # Aqui vai o ip da filial na rede ou internet
    remote 200.207.59.175
    # Indica que esse túnel possui uma chave de criptografia
    secret /etc/openvpn/chave
    # OpenVPN usa a porta 5000/UDP por padrão.
    # Cada túnel do OpenVPN deve usar
    # uma porta diferente.
    # O padrão é a porta 5000
    # Se omitido, será criada a conexão na porta 5000
    port 5000
    # Usuário que rodará o daemon do OpenVPN
    user nobody
    # Usa a biblioteca lzo
    comp-lzo
    # Mantem a conexão enviando pings
    # de 15 em 15 segundos.
    ping 15
    # Nível de log
    verb 3
maykel-virtual-machine maykel # ifconfig
eth0      Link encap:Ethernet  Endereço de HW 00:0c:29:da:f0:08  
          inet end.: 192.168.65.139  Bcast:192.168.65.255  Masc:255.255.255.0
          endereço inet6: fe80::20c:29ff:feda:f008/64 Escopo:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Métrica:1
          pacotes RX:4451 erros:0 descartados:0 excesso:0 quadro:0
          Pacotes TX:3933 erros:0 descartados:0 excesso:0 portadora:0
          colisões:0 txqueuelen:1000 
          RX bytes:4407446 (4.4 MB) TX bytes:448344 (448.3 KB)
          IRQ:19 Endereço de E/S:0x2000 
lo        Link encap:Loopback Local  
          inet end.: 127.0.0.1  Masc:255.0.0.0
          endereço inet6: ::1/128 Escopo:Máquina
          UP LOOPBACK RUNNING  MTU:65536  Métrica:1
          pacotes RX:138 erros:0 descartados:0 excesso:0 quadro:0
          Pacotes TX:138 erros:0 descartados:0 excesso:0 portadora:0
          colisões:0 txqueuelen:0 
          RX bytes:16370 (16.3 KB) TX bytes:16370 (16.3 KB)
tun0      Link encap:Não Especificado  Endereço de HW 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet end.: 10.0.1.2  P-a-P:10.0.1.1  Masc:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Métrica:1
          pacotes RX:0 erros:0 descartados:0 excesso:0 quadro:0
          Pacotes TX:0 erros:0 descartados:0 excesso:0 portadora:0
          colisões:0 txqueuelen:100 
          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
maykel-virtual-machine maykel # echo 1 > /proc/sys/net/ipv4/ip_forward
maykel-virtual-machine maykel # route add -net 192.168.2.0/24 gw 10.0.1.2
maykel-virtual-machine maykel # openvpn --config /etc/openvpn/filial.conf -daemon
Thu Feb 13 12:52:56 2014 OpenVPN 2.3.2 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Jul 12 2013
Thu Feb 13 12:52:56 2014 WARNING: --ping should normally be used with --ping-restart or --ping-exit
Thu Feb 13 12:52:56 2014 WARNING: you are using user/group/chroot/setcon without persist-tun -- this may cause restarts to fail
Thu Feb 13 12:52:56 2014 WARNING: you are using user/group/chroot/setcon without persist-key -- this may cause restarts to fail
Thu Feb 13 12:52:56 2014 WARNING: file '/etc/openvpn/chave' is group or others accessible
Thu Feb 13 12:52:56 2014 Static Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Feb 13 12:52:56 2014 Static Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Feb 13 12:52:56 2014 Static Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Feb 13 12:52:56 2014 Static Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Feb 13 12:52:56 2014 Socket Buffers: R=[212992->131072] S=[212992->131072]
Thu Feb 13 12:52:56 2014 TCP/UDP: Socket bind failed on local address [undef]: Address already in use
Thu Feb 13 12:52:56 2014 Exiting due to fatal error
ainda executei os seguinte comandos:
# echo 1 > /proc/sys/net/ipv4/ip_forward (tanto na matriz como na filial)
# route add -net 192.168.2.0/24 gw 10.0.1.2 (dentro da matriz)
# route add -net 192.168.1.0/24 gw 10.0.1.1 (dentro da filial)
mas não da certo! como vcs podem verificar. o que devo fazer para corrigir esse erro?
me baseei no tutorial de 
http://www.vivaolinux.com.br/perfil/verPerfil.php?login=guilhermerezende e de 
http://redeunderground.blogspot.com.br/2012/02/configurando-uma-vpn-entre-duas.html
att
maykel