http://openvpn.net/index.php/open-source/documentation/howto.htmlhttp://openvpn.net/index.php/open-source/faq.htmlIPforwarding的方法1.echo1>/proc/sys/net/ipv4/ip_forward2./etc/sysctl.confnet.ipv4.ip_forward=1根据HOWTO的配置,已经可以让客户端建立VPN,并且可以ping到VPNServer的内网网卡,但是就是不能访问公司内网的其他机器。根据这篇文章http://blog.chinaunix.net/u/2389/showart_69121.htmlQ:我的OpenVPN连接上了,也可以ping同VPNServer的VPN内网地址,为什么我访问不了远程内网的机器呢?A:说实话,这个问题已经超出了VPN的范围了,只要你能ping同Server的VPN内网地址,说明VPN工作正常了,剩下是网络配置的问题了。要访问远程的内网,首先要让你的机器只要远程内网的IP地址段,新增路由表项,使得去往该段地址的数据从VPN过去,其次,VPNServer的forward要打开,然后,让远程机器路由表项里面有去往VPN内网网段的路由发送给VPNserver(也可以在VPNServer上启用MASQUERADE,这个简单)。说明我的VPN已经配置可以了,唯一缺的就是内网机器不知道到达我VPN客户端的路由。根据下面这篇文章的建议http://ubuntuforums.org/showthread.php?t=711574Re:openVPNserver,cantseesubnetcomputersithinkwhatyouaremissingisinformationatthereceivingendoftheconnectiongonwheretosendtherepliesto.TheVPNserverknowshowtosendthepacketsintoyourLAN(sinceithasanicconnectedtoit)buttheclientsontheLANdonotknowwheretheVPNis…onlytheVPNserverknowsthat.Sotheirrepliesgetsenttothedefaultgateway,whichshouldforwardthemtotheinternetwheretheygetlost…Therearethreewaysicanthinkofhowtosolvethis…1,)telleverymachineontheLANthatthesubnet10.8.0.0/24isfoundat192.168.1.50.2.)tellyournetworksdefaultgatewaywheretoroutepacketsthatareforthatsubnet,i.e.addarouteatthemachinehavingthe192.168.1.254torouteallpacketsfor10.8.0.0/24totheip192.168.1.503.)MasqueradethetrafficoftheVPNattheVPNserver.ThismeansthatyouwillgetconnectonfromtheVPNintothelocalnetwork,ButnotfromthelocalnetworktotheVPN…sincetheclientontheLANstilldon’tknowwhereyourVPNis…第一个方法有效,我的VPNServer是192.168.200.226,VPN客户端分配到的IP是10.8.1.6,想访问192.168.200.208只要在192.168.200.208上运行routeadd-net10.8.1.0netmask255.255.255.0gw192.168.200.226立即解决问题另,删除路由命令是routedel-net10.8.1.0netmask255.255.255.0,查看路由route-r第二个方法,在我的TPLINKWR841N上无效,这个路由器的IP是192.168.200.1,网络的网关也是它,我在路由器上添加了一条静态路由目的IP地址:10.8.1.0子网掩码:255.255.255.0网关:192.168.200.226192.168.200.208的默认网关是192.168.200.1即使重启路由器,仍然无法从客户端ping通192.168.200.208,但是可以从192.168.200.208ping到10.8.1.x的机器。第三个方法,启动防火墙iptables,允许openvpn的端口。然后在openvpn服务器上运行以下命令iptables-tnat-APOSTROUTING-oeth0-s10.8.1.0/24-jMASQUERADE搞定,参考http://bbs.hxjsq.com/thread-7866-1-1.html###/sbin/iptables-tnat-APOSTROUTING-o(vpn网卡)-s10.0.8.1/24-jMASQUERADE我记得好像是这样,你试试看。###