日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Linux系統(tǒng)安裝和配置OpenVPN

OpenVPN 是一個基于 OpenSSL 庫的應用層 VPN 實現(xiàn)。和傳統(tǒng) VPN 相比,它的優(yōu)點是簡單易用。OpenVPN 提供給企業(yè)之間或者個人與公司之間安全數(shù)據(jù)傳輸?shù)乃淼?,OpenVPN無疑是Linux下開源VPN的先鋒,提供了良好的性能和友好的用戶GUI。

成都創(chuàng)新互聯(lián)公司專注于西藏網(wǎng)站建設服務及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供西藏營銷型網(wǎng)站建設,西藏網(wǎng)站制作、西藏網(wǎng)頁設計、西藏網(wǎng)站官網(wǎng)定制、微信小程序服務,打造西藏網(wǎng)絡公司原創(chuàng)品牌,更為您提供西藏網(wǎng)站排名全網(wǎng)營銷落地服務。

安裝EPEL套件庫,順道更新

# yum -y install epel-release && yum -y update

安裝 OpenVPN

首先我們需要安裝OpenVPN。我們還將安裝Easy RSA來生成我們的SSL密鑰對,這將保護我們的VPN連接。

# yum install -y openvpn easy-rsa

生成密鑰及證書的前置條件

3.1.創(chuàng)建密鑰與證書儲存目錄,并且準備好要產生密鑰與證書的相關文件:

# mkdir -p /etc/openvpn/easy-rsa/keys
# cp -rf /usr/share/easy-rsa/2.0/* /etc/openvpn/easy-rsa
# cp /etc/openvpn/easy-rsa/openssl-1.0.0.cnf /etc/openvpn/easy-rsa/openssl.cnf

3.2.修改憑證的默認資料,之后產生憑證時就會自動填寫,不必再手動輸入。

# vim /etc/openvpn/easy-rsa/vars
所有憑證資料的預設值分別是:國家、省份、城市、組織、電子郵件位址、單位。

...
export KEY_COUNTRY="CN"
export KEY_PROVINCE="GD"
export KEY_CITY="ZHUHAI"
export KEY_ORG="YUNXI"
export KEY_EMAIL="YUNXI@it.cn"
export KEY_OU="IT YUNXI."
...

上述參數(shù)的值可以自定義設置,對配置無影響。

Server 端密鑰與證書生成

4.1.清除并刪除 keys 目錄下的所有 key
# cd /etc/openvpn/easy-rsa
以下步驟列出需要清理的目錄:

# source ./vars
NOTE: If you run ./clean-all, I will be doing a rm -rf on /etc/openvpn/easy-rsa/keys
# ./clean-all
4.2.生成CA的密鑰及憑證,設定值不需修改的話,可以直接按Enter使用vars檔案里的預設值。

# ./build-ca
4.3.生成 OpenVPN Server 端的密鑰及憑證,同樣可以使用vars檔案的預設值。

注意:一直回車,直至最后有兩次交互,輸入 y 確認。

# ./build-key-server renwoleserver
4.4.生成 Diffie Hellman 參數(shù),這個步驟比較久,可能要跑大約 6 分鐘左右。

# ./build-dh
4.5.將Server的密鑰及憑證放到主目錄里:

# cd /etc/openvpn/easy-rsa/keys
# cp dh2048.pem ca.crt renwoleserver.crt renwoleserver.key /etc/openvpn

生成 Client 端的密鑰及憑證,文件名可以自定義,有兩種方式,分別是:(一直回車即可)

5.1.生成不用輸入密碼的憑證:

# /etc/openvpn/easy-rsa/build-key renwoleusers
5.2.生成需要輸入密碼的憑證:

# /etc/openvpn/easy-rsa/build-key-pass renwoleusers

生成TLS-auth密鑰(可選)

OpenVPN提供了TLS-auth功能,可以用來抵御Dos、UDP端口淹沒攻擊。出于安全考慮,你可以啟用該功能;啟用該功能,你需要執(zhí)行以下命令:

# cd /etc/openvpn
# openvpn --genkey --secret ta.key
6.目前我們總共產生了這些金鑰及憑證:

# ll keys/

total 84

01.pem
02.pem
renwoleserver.crt
renwoleserver.csr
renwoleserver.key
renwoleusers.crt
renwoleusers.csr
renwoleusers.key
ca.crt
ca.key
dh2048.pem
index.txt
index.txt.attr
index.txt.attr.old
index.txt.old
serial
serial.old

配置 OpenVPN server.conf

OpenVPN安裝目錄默認存在 server.conf 配置文件,我們拷貝一份并修改使用:

# cp /usr/share/doc/openvpn-*/sample/sample-config-files/server.conf /etc/openvpn
我們進入 /etc/openvpn/ 目錄編輯 server.conf  文件。

配置完成后的內容如下:

# egrep -v "^$|^#|^;" server.conf

local 10.10.204.62
port 1194
proto udp
dev tun
ca ca.crt
cert renwoleserver.crt
key renwoleserver.key # This file should be kept secret
dh dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 223.5.5.5"
client-to-client
keepalive 10 120
tls-auth ta.key 0 # This file is secret
cipher AES-256-CBC
compress lz4-v2
push "compress lz4-v2"
user nobody
group nobody
persist-key
persist-tun
#新增日志路徑
status /var/log/openvpn-status.log
log /var/log/openvpn.log
verb 3
explicit-exit-notify 1

啟動IP轉發(fā)功能

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

配置firewall轉發(fā)規(guī)則

確保服務器可以轉發(fā)數(shù)據(jù)包到服務器內外網(wǎng),開啟必要的通訊服務,并啟用IP偽裝(Masquerade)功能。

# firewall-cmd --permanent --add-service openvpn
# firewall-cmd --permanent --add-masquerade
# DEV=$(ip route get 223.5.5.5 | awk 'NR==1 {print $(NF-2)}' )
# firewall-cmd --permanent --direct --passthrough ipv4 -t nat -A POSTROUTING -s 10.8.0.0/24 -o $DEV -j MASQUERADE
# firewall-cmd --reload
# firewall-cmd --list-all

public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: dhcpv6-client openvpn ssh
ports:
protocols:
masquerade: yes
forward-ports:
sourceports:
icmp-blocks:
rich rules:

啟動 OpenVPN

重啟網(wǎng)絡與OpenVPN服務,并且讓OpenVPN開機后自動啟動:

# systemctl restart network
# systemctl restart openvpn@server
# systemctl enable openvpn@server

執(zhí)行以下命令我們會看到一個新增的OpenVPN 專用網(wǎng)絡:tun0

# ip a
...
tun0:  mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100
link/none
inet 10.8.0.1 peer 10.8.0.2/32 scope global tun0
valid_lft forever preferred_lft forever

Windows PC 客戶端的配置

12.1.下載 openvpn 客戶端并安裝:Windows系統(tǒng)下安裝,按照默認安裝完成即可。

12.2.將Server端生成的Client密鑰與證書下載到本地并放在 C:\Program Files\OpenVPN\config 目錄下。

需要下載的文件列表:

/etc/openvpn/easy-rsa/keys/renwoleusers.crt
/etc/openvpn/easy-rsa/keys/renwoleusers.key
/etc/openvpn/easy-rsa/keys/ca.crt
/etc/openvpn/ta.key
12.3.將 C:\Program Files\OpenVPN\sample-config 下 client.ovpn 文件拷貝到 C:\Program Files\OpenVPN\config 目錄。

client.ovpn 文件配置完成后的內容如下:

client
dev tun
;proto tcp
proto udp
remote 10.10.204.62 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert renwoleusers.crt
key renwoleusers.key
remote-cert-tls server
tls-auth ta.key 1
cipher AES-256-CBC
verb 3

此時點擊桌面上的 “OpenVPN GUI” 圖標,如果不出意外即可連接成功,若連接報錯,請查看分析 C:\Users\yunxi\OpenVPN\log\client.log 日志文件。


分享名稱:Linux系統(tǒng)安裝和配置OpenVPN
鏈接地址:http://www.dlmjj.cn/article/dhiihhp.html