在Gentoo安装OpenVPN Server

以前的一篇关于OpenVPN在Gentoo上运行需要编译内核的TUN/TAP选项,如果仅仅是使用OpenVPN作为客户端没有什么问题,要用作OpenVPN Server就需要安装iptables,并且编译对iptables支持的新内核。

iptables内核的编译选项在:

Networking options  --->
    [*] Network packet filtering framework (Netfilter)  --->
        Core Netfilter Configuration  --->
            <*> Netfilter connection tracking support
            -*- Netfilter Xtables support (required for ip_tables)

在这个下面有很多个match support,搞不清楚到底哪个和openvpn有关,所以全部选上。

安装openvpn的命令:

emerge -avt openvpn

到/usr/share/openvpn/easy-rsa/目录下制作证书文件,这个过程和在Ubuntu下是一样的,请参考Ubuntu Server下安装OpenVPN Server。将生成好的配置文件拷贝到/etc/openvpn下,余下的设置过程和在Ubuntu上是一样的,只不过配置文件的名字要改为openvpn.conf,这个配置文件的名字是可以通过编辑/etc/init.d/openvpn这个脚本进行修改的。

修改/etc/sysctl.conf文件中的net.ipv4.ip_forward = 0,将0改为1,并用命令sysctl -p让其立即生效。然后执行:

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

iptables的命令能否正确执行,检验了内核的编译结果。如果不放心,最好将NAT有关的选项都编译进去。

Tags: , , , ,

One Response to 在Gentoo安装OpenVPN Server

  1. [...] « [Google AppEngine] 中使用Flex实现Google Account SignIn/SignOut 在Gentoo安装OpenVPN Server [...]

Leave a Reply

Name and Email Address are required fields. Your email will not be published or shared with third parties.