OpenBSD从5.3开始,就自带了npppd这个package,让设置pptp,l2tp轻而易举,只需简单设置下,就可以了。
且该package解决了Android和iOS的IPSec phase 1和 phase 2 模式和
加密方法不同的情况。
以下情形是,OpenBSD作为网关的设定。
/etc/npppd/npppd.conf
----分割线开始----
authentication LOCAL type local {
users-file "/etc/npppd/npppd-users"
}
tunnel L2TP protocol l2tp {
listen on 0.0.0.0
listen on ::
}
ipcp IPCP {
pool-address 11.0.0.2-11.0.0.254
dns-servers 202.96.128.86 202.96.128.143
}
interface pppx0 address 11.0.0.1 ipcp IPCP
bind tunnel from L2TP authenticated by LOCAL to pppx0
----分割线结束----
ipsec设置:
设置文件为:
/etc/ipsec.conf
其中下面的配置里, ext_if是OpenBSD系统里的外网网卡端口,如果是pppoe拨号的,则为pppoe0...
key为L2TP的share key
----分割线开始----
ext_if=em0
key="mypassword"
ike passive esp transport \
proto udp from $ext_if to any port 1701 \
main auth "hmac-sha1" enc "3des" group modp1024 \
quick auth "hmac-sha1" enc "aes" \
psk $key
----分割线结束----
接着得系统启动时,设置以下package随机启动,在 /etc/rc.conf (或者 /etc/rc.conf.local)里设置
isakmpd_flags="-K"
ipsec=YES
ipsec_rules=/etc/ipsec.conf
npppd_flags=""
最后,是PF的设定,
由于作为网关,得在
/etc/sysctl.conf 里写入以下来 启动 ip包 forwarding和npppd所需要的pipex。
net.inet.ip.forwarding=1
net.inet6.ip6.forwarding=1
net.pipex.enable=1
PF设置,简单的可如下设置,在 /etc/pf.conf 按个人需要设置
WAN="em0"
set skip on lo
match out on $WAN from any to any nat-to ($WAN)
pass quick all
阅读(949) | 评论(0) | 转发(0) |