Quantcast
Channel: 看得透又看得远者prevail. ppt.cc/flUmLx ppt.cc/fqtgqx ppt.cc/fZsXUx ppt.cc/fhWnZx ppt.cc/fnrkVx ppt.cc/f2CBVx
Viewing all articles
Browse latest Browse all 20529

编译openvpn(配置文件里启用cipher),从而成功翻墙

$
0
0
我在bandwagonhost.com的一款kvm vps上,安装openvpn-install一键安装脚本,没想到竟然失败了。于是就想着自己编译openvpn.

wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz
tar zxvf lzo-2.10.tar.gz
cd lzo-2.10
./configure
make
make install


cd ~
wget http://openvpn.net/release/openvpn-2.4.3.tar.gz 
tar zxvf openvpn-2.4.3.tar.gz
cd openvpn-2.4.3
./configure
make
make install



root@host openvpn-2.4.3]# cd sample
[root@host sample]# ls
Makefile     Makefile.in          sample-keys     sample-scripts
Makefile.am  sample-config-files  sample-plugins  sample-windows
[root@host sample]# ls sample-keys
ca.crt         client-ec.key    dh2048.pem          server.crt     ta.key
ca.key         client.key       gen-sample-keys.sh  server-ec.crt
client.crt     client.p12       openssl.cnf         server-ec.key
client-ec.crt  client-pass.key  README              server.key
[root@host sample]# mkdir /etc/openvpn-2.4.3
[root@host sample]# cp -rf sample-keys/* /etc/openvpn-2.4.3/
[root@host sample]# ls sample-config-files
client.conf      loopback-server      README              tls-home.conf
firewall.sh      office.up            server.conf         tls-office.conf
home.up          openvpn-shutdown.sh  static-home.conf    xinetd-client-config
loopback-client  openvpn-startup.sh   static-office.conf  xinetd-server-config
[root@host sample]# cp sample-config-files/client.conf /etc/openvpn-2.4.3/
[root@host sample]# cp sample-config-files/server.conf /etc/openvpn-2.4.3/
[root@host sample]# cd /etc/openvpn-2.4.3/
[root@host openvpn-2.4.3]# nano openvpn-server.conf
 (openvpn-server.conf的内容如下)
[root@host openvpn-2.4.3]# cat openvpn-server.conf
port 1278
proto udp
dev tun
sndbuf 0
rcvbuf 0
ca /etc/openvpn-2.4.3/ca.crt
cert /etc/openvpn-2.4.3/server.crt
key /etc/openvpn-2.4.3/server.key
dh /etc/openvpn-2.4.3/dh2048.pem
auth SHA512
tls-auth /etc/openvpn-2.4.3/ta.key 0
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 10 120
cipher AES-256-CBC
comp-lzo
user nobody
group nobody
persist-key
persist-tun
status openvpn-status.log
verb 3
[root@host openvpn-2.4.3]# nano client1.ovpn
(client1.ovpn的内容如下)
[root@host openvpn-2.4.3]# cat client1.ovpn
client
dev tun
proto udp
sndbuf 0
rcvbuf 0
remote my-vps-ip 1278
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
cipher AES-256-CBC
comp-lzo
auth SHA512
setenv opt block-outside-dns
key-direction 1

verb 3
<ca>
此处粘贴ca.crt文件的内容
</ca>
<cert>
此处粘贴client.crt文件的内容
</cert>
<key>
此处粘贴client.key文件的内容
</key>
<tls-auth>
此处粘贴ta.key文件的内容
</tls-auth>
[root@host openvpn-2.4.3]#
(运行当前目录下的gen-sample-keys.sh,可以生成另外的证书/私匙等文件)

OpenVPN服务器访问外网的设置:

开启路由转发功能:
echo 1 > /proc/sys/net/ipv4/ip_forward
#为了使vps重启后仍然开启路由转发功能我们需要再执行下列命令
sysctl -w net.ipv4.ip_forward=1 添加iptables转发规则:
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE


启动OpenVPN服务器:
openvpn --config /etc/openvpn-2.4.3/openvpn-server.conf --daemon
设置vps重启后,自动启动openvpn

 # nano /etc/rc.local
然后在该文件内容的最后面加入此行:
 openvpn --config /etc/openvpn-2.4.3/openvpn-server.conf --daemon

把客户端配置文件client1.ovpn下载到你的本地电脑(windows上,则是下载到
c:\program files\openvpn\config\目录中;mac系统,则先安装tunnelblick,然后在
finder中,搜索文件client1.ovpn,双击它,导入到tunnelblick)

启动客户端程序,待连接成功后,即可翻墙。

我下载了openvpn在2007年的版本:
http://openvpn.net/release/openvpn-2.1_rc15.tar.gz

解压后,进入openvpn-2.1_rc15目录,然后进入sample-config-files目录,
打开server.conf,一看里面有如下内容:
;cipher BF-CBC        # Blowfish (default)
;cipher AES-128-CBC   # AES
;cipher DES-EDE3-CBC  # Triple-DES

而打开client.conf,一看里面有如下内容:
# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
;cipher x


当年很少有人启用cipher AES-128-CBC这一行,导致2012年11月左右,openvpn的流量
特征被gfw识别而予以封杀,这样openvpn就阵亡了。如果启用了
cipher AES-128-CBC这一行,估计当时gfw对openvpn还是无可奈何的。

现在服务器/客户端2边的配置文件启用cipher AES-256-CBC后,gfw对openvpn就无可奈何了。

相关帖子:http://briteming.blogspot.com/2017/07/openvpnopenvpn-installopenvpnopenvpn.html

Viewing all articles
Browse latest Browse all 20529

Trending Articles