我目前正在尝试configurationOpenVPN以远程访问我们的公司networking。
我能够build立连接并在configuration的地址(10.8.0.1)上ping服务器,但是我无法从客户端访问服务器端的networking。
服务器configuration为将路由推送到服务器:
push "route 155.0.0.0 255.255.0.0 10.8.0.1 1"
其中155.0.0.0/16是服务器端networking。
这不起作用,所以我补充说
push "route 155.0.0.68 255.255.255.255 net_gateway 1"
因为我在某处读到,如果包括到服务器(155.0.0.68)的所有数据包都通过隧道路由,那么这可能会有问题,但仍然不起作用。 我无法ping通服务器networking上的任何地址。 连155.0.0.68上的服务器本身都没有。
我究竟做错了什么?
其他信息:客户端和服务器运行窗口和OpenVPN运行udp协议的tun模式。 防火墙在客户端和服务器上closures。
我已经在networking工程上问过这个问题,但是我被告知ServerFault会是一个更好的地方。
VPN隧道两端的路由都是必需的。
此外,IP路由必须在服务器上启用。 例如在Windows 7上:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] "IPEnableRouter"=dword:00000001
让我们假设下面的IP和子网:
192.168.0.0/24 192.168.0.2 10.8.0.2 155.0.0.0/16 155.0.0.68 10.8.0.1 为服务器和客户端创build一组密钥。 查看OpenVPN安装目录下的README文件..\OpenVPN\easy-rsa\README.txt ,了解如何生成这些文件。
将以下行添加到服务器configuration文件中:
port 1194 proto udp dev tun topology subnet server 10.8.0.0 255.255.255.0 client-config-dir C:\\OpenVPN\\config\\ccd route 192.168.0.0 255.255.255.0 10.8.0.2 ca C:\\OpenVPN\\config\\ca.crt cert C:\\OpenVPN\\config\\server.crt key C:\\OpenVPN\\config\\server.key dh C:\\OpenVPN\\config\\dh1024.pem keepalive 10 60 comp-lzo persist-key persist-tun status C:\\OpenVPN\\config\\openvpn-status-tun.log 20 log C:\\OpenVPN\\config\\openvpn-tun.log verb 3
将pathreplace为相应的安装目录。
在服务器上添加一个自定义客户端configuration文件:
在与服务器configuration文件相同的目录中创build一个目录ccd ,并在那里以客户端证书的CN ( 公用名称 )命名的configuration文件。
检查客户端证书并查找此行( CN=<client_name> ):
Subject: C=CH, ST=State, L=City, O=org, OU=unit, CN=client1/name=EasyRSA/emailAddress=root@localhost
在这个例子中,该文件将被命名为client1 (没有扩展名),将以client1添加到文件中:
ifconfig-push 10.8.0.2 255.255.255.0 push "route 155.0.0.0 255.255.0.0 10.8.0.1" iroute 192.168.0.0 255.255.255.0
ifconfig-push会给这个客户端一个静态IP push "route ..."将路由到达服务器端子网到客户端 iroute在OpenVPN中为客户的子网生成一条内部路由 将以下行添加到客户端configuration文件中:
client dev tun proto udp remote 155.0.0.68 1194 resolv-retry infinite nobind persist-key persist-tun comp-lzo ca C:\\OpenVPN\\config\\client1.crt cert C:\\OpenVPN\\config\\client1.crt key C:\\OpenVPN\\config\\client1.key remote-cert-tls server
用您的安装目录replacepath。
如果运行OpenVPN的服务器也是路由器,并且设置为服务器端子网上所有客户端上的default-gateway ,则此设置可用。
如果存在专用路由器,则添加以下静态路由(或将其添加到所有客户端)以到达VPN子网和client1的子网。
静态服务器端子网路由:
Destination Gateway Genmask 192.168.0.0 155.0.0.68 255.255.255.0 10.8.0.0 155.0.0.68 255.255.255.0
有关此主题的其他提示,请参阅此答案 。
因为你的干净不知道,如何到达另一边,你需要这样的东西:
VPN客户端:
route add -net 192.168.0.0/24 gw 10.8.0.1 1 #in this way, the client knows, how to reach the other side.
远程局域网(服务器端),如果我想达到我的VPN服务器端的电脑:
route add -net 10.0.0/16 gw "192.168.0.100(local lan ip of my vpn server)"` #in this way, the other pc knows, where to route the traffic for the vpn network
对不起,如果是的命令,但我不使用Windows
如果您的客户端运行Windows 7,则必须使用pipe理员权限运行打开的VPN客户端,否则路由表将无法填充,并且您可能无法ping服务器networking上的主机。