-2

我想为我的本地网络流量(iPhone/iPad/MacBook)设置一个 VPN-Server。

到目前为止,我设法使用 CA 和 Client-Cert 设置了基本配置。目前我的客户端可以连接到服务器并访问服务器资源,但没有到互联网的路由。

服务器可通过公共 IP 直接访问(无需家庭安装......)。

我需要更改哪些内容才能通过 VPN-Server 路由我的所有客户端流量并为我的客户端启用 Internet 访问?

提前致谢

/etc/ipsec.conf

config setup

conn rw
    keyexchange=ikev1
    authby=xauthrsasig
    xauth=server
    auto=add
    #
    #LEFT (SERVER)
    left=%defaultroute
    leftsubnet=0.0.0.0/0
    leftfirewall=yes
    leftcert=serverCert.pem
    #
    #RIGHT (CLIENT)
    right=%any
    rightsubnet=10.0.0.0/24
    rightsourceip=10.0.0.0/24
    rightcert=clientCert.pem

iptables --list

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  10.0.0.1             anywhere             policy match dir in pol ipsec                                                                                                                reqid 1 proto esp
ACCEPT     all  --  anywhere             10.0.0.1             policy match dir out pol ipsec                                                                                                                reqid 1 proto esp

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
4

1 回答 1

4

找到了解决方案!

/etc/ipsec.conf

rightsubnet=10.0.0.0/24

iptables

iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -m policy --dir out --pol ipsec -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE

系统

sysctl net.ipv4.ip_forward=1
于 2014-04-24T10:05:44.863 回答