openvpn on opensuse

  1. Server 配置
    1.1 安装openvpn
zypper in -y openvpn

1.2 把脚本复制到/etc

cp -r /usr/share/openvpn /etc/

1.3 可选,设置用于证书的参数,如果跳过了后面需要手工输入
编辑 ./vars
建议把KEY_SIZE修改为 2048, 其余按照实际情况修改

export KEY_SIZE=2048

# These are the default values for fields
# which will be placed in the certificate.
# Don't leave any of these fields blank.
export KEY_COUNTRY="CN"
export KEY_PROVINCE="Guangdong"
export KEY_CITY="Shenzhen"
export KEY_ORG="poetpalace"
export KEY_EMAIL="lyre@poetpalace.org"

1.4 清空原来的配置,如果有的话

cd /etc/opensuse/easy-rsa/2.0/
 . ./vars
./clean-all

1.5 生成ca和server证书,还有dh

./build-ca
./build-key-server server
./build-dh
./clean-all

1.6 生成server配置文件

cd /etc/openvpn
cp /usr/share/doc/packages/openvpn/sample-config-files/server.conf ./

编辑 /etc/openvpn/server.conf

ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
key /etc/openvpn/easy-rsa/2.0/keys/server.key
dh /etc/openvpn/easy-rsa/2.0/keys/dh2048.pem

1.7 可选,如果你需要用vpn server来翻墙
编辑/etc/openvpn/server.conf
去掉这一行的注释

push "redirect-gateway def1 bypass-dhcp"

配置ip_forward

echo 'net.ipv4.ip_forward=1' >>/etc/sysctl.conf
sysctl -p

配置nat,注意修改地址

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

suse user注意把这句加到某个合适的启动脚本里面,我是加到了/etc/init.d/openvpn里面了

1.8 启动服务

chkconfig openvpn on
rcopenvpn start

1.9 additional
网上流传的应付gfw的方法:
a) tls-auth
在交换密钥的时候使用tls 验证

openvpn --genkey --secret ta.key

把ta.key复制到 client和server,修改配置文件
server

tls-auth ta.key 0

client

tls-auth ta.key 1

b) 修改默认的cipher
在server和client各自加上

cipher AES-256-CBC

或者

cipher AES-128-CBC

不过,我试过了,这些参数并不是完全有效,一般过1-3天gfw就发现了……

updatedupdated2022-02-222022-02-22