基于OpenVPN建立局域网

搭建Server

安装依赖

// curl 下载centos7依赖
// curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum update
yum install epel-release

官方一键安装

wget https://raw.githubusercontent.com/Angristan/openvpn-install/master/openvpn-install.sh


sudo chmod +x openvpn-install.sh
sudo ./openvpn-install.sh


systemctl start openvpn@server
systemctl status openvpn@server

vim /etc/openvpn/server.conf


// 监听网卡
tcpdump -i tun0
  • 选择绑定公网IP

  • 选择协议UDP/TCP,记得打开对应端口

  • 选择密码模式

  • 查看 .ovpn文件

Client安装

添加账号

sudo ./openvpn-install.sh

安装依赖

yum update
yum install epel-release

启动

oepnvpn --config 

固定IP

vim /etc/openvpn/ccd/{username}

ifconfig-push 10.8.0.10 255.255.255.0