Я установил OpenVPN на машине Linux в моем подвале.
Я могу подключиться с моего компьютера с Windows 8.1 без проблем, когда я подключен к локальной сети.
В этом случае я установил конфигурационный файл для использования remote 192.168.0.111 1194
Когда я покидаю свою локальную сеть, я изменяю этот файл конфигурации следующим образом: remote 63.xxx.x.xxx 1194 Где 63.xxx.xx.xx - мой публичный IP-адрес.
Когда я нахожусь вне моей локальной сети, я не могу подключиться. Вот моя запись в журнале с моей последней попытки подключения из внешней сети.
Mon Oct 06 13:59:54 2014 OpenVPN 2.3.4 i686-w64-mingw32 [SSL (OpenSSL)] [LZO] [PKCS11] [IPv6] built on May  2 2014
Mon Oct 06 13:59:54 2014 library versions: OpenSSL 1.0.1g 7 Apr 2014, LZO 2.05
Mon Oct 06 13:59:54 2014 MANAGEMENT: TCP Socket listening on [AF_INET]127.0.0.1:25340
Mon Oct 06 13:59:54 2014 Need hold release from management interface, waiting...
Mon Oct 06 13:59:55 2014 MANAGEMENT: Client connected from [AF_INET]127.0.0.1:25340
Mon Oct 06 13:59:55 2014 MANAGEMENT: CMD 'state on'
Mon Oct 06 13:59:55 2014 MANAGEMENT: CMD 'log all on'
Mon Oct 06 13:59:55 2014 MANAGEMENT: CMD 'hold off'
Mon Oct 06 13:59:55 2014 MANAGEMENT: CMD 'hold release'
Mon Oct 06 13:59:55 2014 Socket Buffers: R=[65536->65536] S=[65536->65536]
Mon Oct 06 13:59:55 2014 UDPv4 link local: [undef]
Mon Oct 06 13:59:55 2014 UDPv4 link remote: [AF_INET]63.xxx.xx.xx:1194
Mon Oct 06 13:59:55 2014 MANAGEMENT: >STATE:1412625595,WAIT,,,
Mon Oct 06 14:00:55 2014 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Mon Oct 06 14:00:55 2014 TLS Error: TLS handshake failed
Mon Oct 06 14:00:55 2014 SIGUSR1[soft,tls-error] received, process restarting
Mon Oct 06 14:00:55 2014 MANAGEMENT: >STATE:1412625655,RECONNECTING,tls-error,,
Mon Oct 06 14:00:55 2014 Restart pause, 2 second(s)
Mon Oct 06 14:00:57 2014 Socket Buffers: R=[65536->65536] S=[65536->65536]
Mon Oct 06 14:00:57 2014 UDPv4 link local: [undef]
Mon Oct 06 14:00:57 2014 UDPv4 link remote: [AF_INET]63.xxx.xx.xx:1194
Mon Oct 06 14:00:57 2014 MANAGEMENT: >STATE:1412625657,WAIT,,,
Кажется, это может быть проблема с брандмауэром, но я снова и снова перебираю все пункты на этой странице и не могу найти никаких проблем.
- Брандмауэр периметра в сети сервера фильтрует входящие пакеты OpenVPN (по умолчанию OpenVPN использует порт UDP или TCP
№ 1194).
Я проверил и дважды проверил настройку маршрутизатора, и порт 1194 определенно должен быть перенаправлен на мой ящик Linux ... Вот конфиг iptables моего роутера:
 > iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
drop       all  --  anywhere             63.xxx.xx.xx
ACCEPT     2    --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere            icmp echo-request
DROP       tcp  --  anywhere             anywhere            tcp dpt:www
DROP       tcp  --  anywhere             anywhere            tcp dpt:https
DROP       tcp  --  anywhere             anywhere            tcp dpt:telnet
DROP       tcp  --  anywhere             anywhere            tcp dpt:ssh
DROP       tcp  --  anywhere             anywhere            tcp dpt:ftp
DROP       tcp  --  anywhere             anywhere            tcp dpt:domain
DROP       tcp  --  anywhere             anywhere            tcp dpt:44401
DROP       tcp  --  anywhere             anywhere            tcp dpt:49431
DROP       udp  --  anywhere             anywhere            udp dpt:domain
DROP       udp  --  anywhere             anywhere            udp dpt:tftp
DROP       udp  --  anywhere             anywhere            udp dpt:1900
DROP       udp  --  anywhere             anywhere            udp dpt:37000
DROP       udp  --  anywhere             anywhere            udp dpt:38000
DROP       udp  --  anywhere             anywhere            udp dpts:5098:5100
DROP       udp  --  anywhere             anywhere            udp dpt:50032
DROP       udp  --  anywhere             anywhere            udp dpt:54008
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     udp  --  anywhere             anywhere            udp dpt:500
ACCEPT     esp  --  anywhere             anywhere
ACCEPT     ah   --  anywhere             anywhere
ACCEPT    !esp  --  anywhere             anywhere            MARK match 0x10000000/0x10000000
ACCEPT    !ah   --  anywhere             anywhere            MARK match 0x10000000/0x10000000
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:4567
DROP       all  --  anywhere             anywhere
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             224.0.1.60
ACCEPT     udp  --  anywhere             192.168.0.111       udp dpt:1194
ACCEPT     tcp  --  anywhere             192.168.0.111       tcp dpt:1194
ACCEPT     tcp  --  anywhere             192.168.0.111       tcp dpt:https
ACCEPT     udp  --  anywhere             192.168.0.17        udp dpt:51490
ACCEPT     udp  --  anywhere             192.168.0.25        udp dpt:53681
ACCEPT     udp  --  anywhere             192.168.0.111       udp dpt:1194
ACCEPT     tcp  --  anywhere             192.168.0.111       tcp dpt:1194
ACCEPT     udp  --  anywhere             192.168.0.111       udp dpt:https
ACCEPT     tcp  --  anywhere             192.168.0.111       tcp dpt:https
ACCEPT     tcp  --  anywhere             5.5.126.125         tcp dpt:15979
ACCEPT     udp  --  anywhere             192.168.0.22        udp dpt:16402
ACCEPT     all  --  anywhere             224.0.0.0/3
ACCEPT     icmp --  anywhere             anywhere            icmp echo-request
ACCEPT     icmp --  anywhere             anywhere            icmp echo-reply
ACCEPT     icmp --  anywhere             anywhere            icmp time-exceeded
ACCEPT     icmp --  anywhere             anywhere            icmp type 30
TCPMSS     tcp  --  anywhere             anywhere            tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
ACCEPT     tcp  --  anywhere             192.168.0.111       tcp dpt:www
ACCEPT     udp  --  anywhere             192.168.0.18        udp dpt:62558
ACCEPT     udp  --  anywhere             192.168.0.17        udp dpt:57874
ACCEPT     udp  --  anywhere             192.168.0.17        udp dpt:51621
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:58670
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:50209
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:60530
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:60285
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:59415
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:62603
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:52438
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:53919
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:62384
ACCEPT     tcp  --  anywhere             192.168.0.3         tcp dpt:35689
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:35689
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:55287
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:50487
ACCEPT     udp  --  anywhere             192.168.0.3         udp dpt:51697
urlfilter  tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST/NONE
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT    !esp  --  anywhere             anywhere            MARK match 0x10000000/0x10000000
ACCEPT    !ah   --  anywhere             anywhere            MARK match 0x10000000/0x10000000
DROP       udp  --  192.168.0.9          anywhere            udp dpt:l2tp
DROP       tcp  --  192.168.0.9          anywhere            tcp dpt:1723
ACCEPT     tcp  --  anywhere             anywhere            tcp dpts:5060:5061
ACCEPT     udp  --  anywhere             anywhere            udp dpts:5060:5061
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www
ACCEPT     udp  --  205.171.2.65         anywhere            udp dpt:domain
ACCEPT     udp  --  205.171.3.65         anywhere            udp dpt:domain
ACCEPT     udp  --  anywhere             anywhere            udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere            tcp dpts:27167:27169
ACCEPT     tcp  --  anywhere             anywhere            tcp dpts:27164:27166
ACCEPT     tcp  --  anywhere             anywhere            tcp dpts:27161:27163
drop       all  --  anywhere             anywhere
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
Chain drop (2 references)
target     prot opt source               destination
ACCEPT     icmp --  anywhere             anywhere            icmp echo-request
LOG        all  --  anywhere             anywhere            LOG level info prefix `firewall drop: '
DROP       all  --  anywhere             anywhere
Chain urlfilter (1 references)
target     prot opt source               destination
SKIPLOG    tcp  --  anywhere             anywhere            tcp dpt:www
QUEUE      tcp  --  anywhere             anywhere            tcp dpt:www
Мне кажется, что мой маршрутизатор должен перенаправить порт 1194 на мою Linux-коробку. У меня это также переадресация порта 80 без каких-либо проблем в тот же ящик.
Я сомневаюсь, что мой провайдер будет блокировать порт 1194, а не порт 80 ...
- Программный брандмауэр, работающий на компьютере сервера OpenVPN, сам фильтрует входящие соединения через порт 1194. Помните, что многие ОС
будет блокировать входящие соединения по умолчанию, если не настроено
иначе.
Я использовал Yast на своей локальной машине, чтобы открыть порт 1194 на машине с Linux. Я уверен, что это не проблема, так как я могу подключиться к Linux, пока подключен к локальной сети. Если бы проблема заключалась в брандмауэре Linux, я бы тоже не смог подключиться с локального адреса.
- Шлюз NAT в сети сервера не имеет правила переадресации порта для TCP/UDP 1194 на внутренний адрес сервера OpenVPN.
машина.
Я уверен, что на роутере это тоже настроено правильно. Вот конфигурация iptables nat на маршрутизаторе:
 > iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             224.0.0.0/3
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:4567
DNAT       udp  --  anywhere             anywhere            udp dpt:51697 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:50487 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:55287 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:35689 to:192.168.0.3
DNAT       tcp  --  anywhere             anywhere            tcp dpt:35689 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:62384 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:53919 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:52438 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:62603 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:59415 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:60285 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:60530 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:50209 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:58670 to:192.168.0.3
DNAT       udp  --  anywhere             anywhere            udp dpt:51621 to:192.168.0.17
DNAT       udp  --  anywhere             anywhere            udp dpt:57874 to:192.168.0.17
DNAT       udp  --  anywhere             anywhere            udp dpt:62558 to:192.168.0.18
DNAT       tcp  --  anywhere             anywhere            tcp dpt:www to:192.168.0.111
REDIRECT   tcp  --  anywhere             anywhere            tcp dpt:webcache redir ports 80
DNAT       udp  --  anywhere             anywhere            udp dpt:57106 to:192.168.0.22:16402
DNAT       tcp  --  anywhere             anywhere            tcp dpt:15980 to:5.5.126.125:15979
DNAT       tcp  --  anywhere             anywhere            tcp dpt:https to:192.168.0.111
DNAT       udp  --  anywhere             anywhere            udp dpt:https to:192.168.0.111
DNAT       tcp  --  anywhere             anywhere            tcp dpt:1194 to:192.168.0.111
DNAT       udp  --  anywhere             anywhere            udp dpt:1194 to:192.168.0.111
DNAT       udp  --  anywhere             anywhere            udp dpt:53681 to:192.168.0.25
DNAT       udp  --  anywhere             anywhere            udp dpt:51490 to:192.168.0.17
DNAT       tcp  --  anywhere             anywhere            tcp dpt:https to:192.168.0.111
DNAT       tcp  --  anywhere             anywhere            tcp dpt:1194 to:192.168.0.111
DNAT       udp  --  anywhere             anywhere            udp dpt:1194 to:192.168.0.111
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
MASQUERADE  all  --  anywhere             anywhere
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
- Конфигурация клиента OpenVPN не имеет правильного адреса сервера в своем файле конфигурации. Директива remote в файле конфигурации клиента должна указывать либо на сам сервер, либо на общедоступный IP-адрес сетевого шлюза сервера.
Я проверил, дважды проверил и трижды проверил этот IP, к которому он подключается, и это правильно.
- Другой возможной причиной является то, что брандмауэр Windows блокирует доступ для двоичного файла openvpn.exe. Вам может понадобиться белый список (добавить его
в список "Исключения") для работы OpenVPN.
Я совершенно уверен, что это не проблема, потому что я могу подключиться из моей локальной сети. Я ошибся? Блокирует ли Windows 8.1 двоичный файл при подключении к удаленному адресу, но не при подключении к локальному адресу? Это кажется маловероятным для меня ...
РЕДАКТИРОВАТЬ --
Вот мой файл конфигурации
##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server.     #
#                                            #
# This configuration can be used by multiple #
# clients, however each client should have   #
# its own cert and key files.                #
#                                            #
# On Windows, you might want to rename this  #
# file so it has a .ovpn extension           #
##############################################
# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client client1
# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun
# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap
# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp
# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
;remote 192.168.0.111 1194
remote 63.xxx.xx.xx 1194
# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random
# Keep trying indefinitely to resolve the
# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite
# Most clients don't need to bind to
# a specific local port number.
nobind
# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nobody
# Try to preserve some state across restarts.
persist-key
persist-tun
# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]
# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings
# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
ca "C:\\Program Files\\OpenVPN\\config\\ca.crt"
cert "C:\\Program Files\\OpenVPN\\config\\client1.crt"
key "C:\\Program Files\\OpenVPN\\config\\client1.key"
# Verify server certificate by checking
# that the certicate has the nsCertType
# field set to "server".  This is an
# important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server".  The build-key-server
# script in the easy-rsa folder will do this.
ns-cert-type server
# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth ta.key 1
# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
;cipher x
# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo yes
# Set log file verbosity.
verb 3
# Silence repeating messages
;mute 20
auth-nocache
script-security 2
remote-cert-tls server
У кого-нибудь есть идеи, почему у меня могут быть проблемы с подключением?
EDIT2 - я использовал это для настройки openVPN:http://en.opensuse.org/SDB:OpenVPN_Installation_and_Setup
Там есть раздел "Конфигурация брандмауэра", который мне не подходит, так как у меня нет openvz и kvm. Я использовал yast для открытия порта 1194 в SuSEfirewall2
