CentOS7 install and configuration OpenVPN
info
添加iptables转发规则
开启转发 [root@openvpn ~]# vim /etc/sysctl.conf net.ipv4.ip_forward = 1 [root@openvpn ~]# sysctl -p 服务器IP 172.18.140.173 (10.8.0.0/24为VPN的网段,eth0 为内网网卡,xxxx 为内网ip ) 运行 iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE #添加 iptables 转发规则 改为自己的 10.8.0.0/24吧 #good 让vpn client 可以 直接内网连接其它内网机器 iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eh1 -j SNAT --to-source 172.18.140.173 #内网网关为192.168.0.1 iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to-source 172.18.140.173 service iptables save iptables -t nat -A POSTROUTING -s 172.18.0.0/24 -j MASQUERADE iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j MASQUERADE iptables -t nat -A POSTROUTING -s 172.18.0.0/24 -o eth1 -j SNATA --to-source 172.18.140.173 iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth1 -j SNAT --to-source x.x.x.x (192.168.0.0/24为VPN的网段,eth1 为外网网卡,xxxx 为外网ip ) iptables -L -n -t nat 也要注意 docker网络
see also