我在一台私有IP地址为10.0.0.13的机器上build立了一个OpenVPN服务器。 网关是10.0.0.2,它将10.0.0。*地址发送给networking上的其他机器。 VPN设置为桥接。 我的/ etc / network / interfaces文件如下所示:
# Bring these interfaces up automatically auto lo br0 # The loopback network interface iface lo inet loopback # The bridge connection iface br0 inet static address 10.0.0.13 bridge_ports eth0 bridge_stp on broadcast 10.0.0.255 gateway 10.0.0.2 netmask 255.255.255.0 network 10.0.0.0 # The primary network interface iface eth0 inet manual up ifconfig $IFACE 0.0.0.0 up up ip link set $IFACE promisc on down ip link set $IFACE promisc off down ifconfig $IFACE down
服务器configuration文件(/etc/openvpn/server.conf)如下所示:
port 1194 proto udp dev tap0 up "/etc/openvpn/up.sh br0" down "/etc/openvpn/down.sh br0" ca ca.crt cert VPNserver.crt key VPNserver.key dh dh1024.pem ifconfig-pool-persist ipp.txt server-bridge 10.0.0.13 255.255.255.0 10.0.0.200 10.0.0.219 push "route 10.0.0.2 255.255.255.0" push "redirect-gateway def1 bypass-dhcp" client-to-client keepalive 10 120 tls-auth ta.key 0 comp-lzo max-clients 20 user nobody group nogroup persist-key persist-tun status openvpn-status.log log-append /var/log/openvpn.log verb 3 crl-verify crl.pem
我认为服务器桥和它下面的线可能需要调整。 OpenVPN应该是为自己创build一个子网并连接客户端? 起初,我只是觉得OpenVPN可以在同一个子网中分配IP地址,只要它们在路由器的DHCP范围之外; 现在我不太确定。
无论如何,这是当前configuration的症状。 客户端计算机(位于10.6.0.0networking中 – 您将在输出中看到这一点)可以连接,但只有OpenVPN服务器的IP是可ping通的,而且我无法浏览网页。 我从Linux CLI连接; 这是我得到的一些输出,这导致我相信路由是问题。 我粗体显示了与我相关的输出。
Fri Jun 3 12:54:51 2011 [VPNserver] Peer Connection Initiated with [AF_INET]SERVER.PUBLIC.IP.ADDRESS:1194 Fri Jun 3 12:54:53 2011 SENT CONTROL [VPNserver]: 'PUSH_REQUEST' (status=1) Fri Jun 3 12:54:53 2011 PUSH: Received control message: 'PUSH_REPLY,route 10.0.0.2 255.255.255.0,redirect-gateway def1 bypass-dhcp,route-gateway 10.0.0.13,ping 10,ping-restart 120,ifconfig 10.0.0.201 255.255.255.0' Fri Jun 3 12:54:53 2011 OPTIONS IMPORT: timers and/or timeouts modified Fri Jun 3 12:54:53 2011 OPTIONS IMPORT: --ifconfig/up options modified Fri Jun 3 12:54:53 2011 OPTIONS IMPORT: route options modified Fri Jun 3 12:54:53 2011 OPTIONS IMPORT: route-related options modified Fri Jun 3 12:54:53 2011 ROUTE default_gateway=10.6.0.1 Fri Jun 3 12:54:53 2011 TUN/TAP device tap0 opened Fri Jun 3 12:54:53 2011 TUN/TAP TX queue length set to 100 Fri Jun 3 12:54:53 2011 /sbin/ifconfig tap0 10.0.0.201 netmask 255.255.255.0 mtu 1500 broadcast 10.0.0.255 Fri Jun 3 12:54:53 2011 /sbin/route add -net SERVER.PUBLIC.IP.ADDRESS netmask 255.255.255.255 gw 10.6.0.1 **SIOCADDRT: File exists Fri Jun 3 12:54:53 2011 ERROR: Linux route add command failed: external program exited with error status: 7** Fri Jun 3 12:54:53 2011 /sbin/route add -net 0.0.0.0 netmask 128.0.0.0 gw 10.0.0.13 Fri Jun 3 12:54:53 2011 /sbin/route add -net 128.0.0.0 netmask 128.0.0.0 gw 10.0.0.13 **Fri Jun 3 12:54:53 2011 /sbin/route add -net 10.0.0.2 netmask 255.255.255.0 gw 10.0.0.13 route: netmask doesn't match route address** Usage: route [-nNvee] [-FC] [<AF>] List kernel routing tables route [-v] [-FC] {add|del|flush} ... Modify routing table for AF. route {-h|--help} [<AF>] Detailed usage syntax for specified AF. route {-V|--version} Display version/author and exit. -v, --verbose be verbose -n, --numeric don't resolve names -e, --extend display other/more information -F, --fib display Forwarding Information Base (default) -C, --cache display routing cache instead of FIB <AF>=Use '-A <af>' or '--<af>'; default: inet List of possible address families (which support routing): inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) x25 (CCITT X.25) **Fri Jun 3 12:54:53 2011 ERROR: Linux route add command failed: external program exited with error status: 4** Fri Jun 3 12:54:53 2011 GID set to nogroup Fri Jun 3 12:54:53 2011 UID set to nobody Fri Jun 3 12:54:53 2011 Initialization Sequence Completed
所以我想我正在寻找:
如果你是桥接,那么你可能不应该推动任何路线。
好的,所以在技术上@Zoredache是正确的。 我的问题是,“什么是推动桥接OpenVPN服务器的正确路线?” 我不应该推route 10.0.0.2 255.255.255.0 (无论如何应该是route 10.0.0.0 255.255.255.0 )。 删除该行解决了我的问题的第一部分。
我的问题的第二部分(不能ping通10.0.0.0networking上的其他机器)与我没有提到的细节有关,这是该服务器驻留在VMWare虚拟机上。 感谢这篇博文 ,我发现“ESXi虚拟交换机在默认情况下会丢弃混杂的数据包”,并且我学会了如何configuration虚拟机不这样做。
我无法实现通过VPN路由所有stream量的第三个目标,但是我认为这对于此特定部署并不重要。 在默认configuration的意见build议,通过取消注释push "redirect-gateway def1 bypass-dhcp"我会configuration所有的客户端redirect他们的默认网关通过VPN,导致所有的IPstream量,如网页浏览和DNS查找通过VPN“,但是当我取消注释时,根本无法离开networking。