在linux上配置外网vpn连接

来源:互联网 发布:vb中picturebox的属性 编辑:程序博客网 时间:2024/06/05 03:59

在公司同事们想上外网,需要搭建一个公司自己的vpn服务器,你只需要在淘宝购买一个vpn账号就行,账号包括一个ip地址,用户名和密码。然后找一台linux的电脑开始部署。写两个文件就行了
需要写配置文件

proxy.sh

#!/usr/bin/expect -fset IPadnPort "0.0.0.0:1080"set username "xxxxx"set remoteHost "x.x.x.x"set password "xxxxx"set timeout -1spawn autossh -M 11111 -N -D $IPadnPort $username@$remoteHostwhile true{        expect{                "(yes/no)"{send "yes\r";exp_continue}                "password:"{send "$password\r";puts \r;set DATE [exec date "+%F %H:%M:%S"]; puts "$DATE\r"}        }}

还需要写一个执行文件来调用上面的连接文件

auto.sh

#!/bin/sh -esu -l rocky -c 'nohup /home/rocky/proxy.sh > /home/rocky/prixy.log &' &exit 0

最后只需要执行一下 ./auto.sh就行了