centos stream 9 openvpn 配置

1,305次阅读
没有评论
OpenVPN : Configure VPN Server2022/07/21
  Install OpenVPN to Configure Virtual Private Network.This example is based on the environment like follows.
By settings of OpenVPN Server/Client, [tun] interface will be configured automatically and when connecting with VPN from Client to Server, Client can access to the the local network of the Server.On this example, it needs to set IP Masquerading on Router, too. +———————-+ | [ OpenVPN Server ] |192.168.100.1 | dlp.srv.world +——–+ | |tun | +———–+———-+ | eth0|10.0.0.29 | | | | Local Network | 10.0.0.1| | +——+—–+ | ——-| Router |————-|—– +——+—–+ | | | | Internet | ————–+——————-|—– | | | Local Network | 192.168.0.100| | +———–+———-+ | | |tun | | VPN Client +——–+ | |192.168.100.x +———————-+
[1] Install OpenVPN.
# install from EPEL
[root@dlp ~]# dnf –enablerepo=epel -y install openvpn easy-rsa net-tools
[2] Create CA and Certificates.
[root@dlp ~]# cd /usr/share/easy-rsa/3# initialize
[root@dlp 3]# ./easyrsa init-pki
init-pki complete; you may now create a CA or requests. Your newly created PKI dir is: /usr/share/easy-rsa/3/pki # create CA
[root@dlp 3]# ./easyrsa build-ca
Using SSL: openssl OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021) # set any pass-phrase Enter New CA Key Passphrase: Re-Enter New CA Key Passphrase: Enter PEM pass phrase: Verifying – Enter PEM pass phrase: —– You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter ‘.’, the field will be left blank. —– Common Name (eg: your user, host, or server name) [Easy-RSA CA]:Server-CA CA creation complete and you may now import and sign cert requests. Your new CA certificate file for publishing is at: /usr/share/easy-rsa/3/pki/ca.crt # create server certificates
# any name is OK for [server1] name
# (it is set for file name of certs or commonName)
[root@dlp 3]# ./easyrsa build-server-full server1 nopass
Using SSL: openssl OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021) Using configuration from /usr/share/easy-rsa/3/pki/easy-rsa-3233.tTgxXj/tmp.kQNNfp # answer with pass-phrase set on CA Enter pass phrase for /usr/share/easy-rsa/3/pki/private/ca.key: Check that the request matches the signature Signature ok The Subject’s Distinguished Name is as follows commonName :ASN.1 12:’server1′ Certificate is to be certified until Oct 10 06:31:42 2024 GMT (825 days) Write out database with 1 new entries Data Base Updated # create client certificates
# any name is OK for [client1] name
# (it is set for file name of certs or commonName)
[root@dlp 3]# ./easyrsa build-client-full client1 nopass
Using SSL: openssl OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021) Using configuration from /usr/share/easy-rsa/3/pki/easy-rsa-3312.bpp3lw/tmp.1bkU1Q # answer with pass-phrase set on CA Enter pass phrase for /usr/share/easy-rsa/3/pki/private/ca.key: Check that the request matches the signature Signature ok The Subject’s Distinguished Name is as follows commonName :ASN.1 12:’client1′ Certificate is to be certified until Oct 10 06:33:42 2024 GMT (825 days) Write out database with 1 new entries Data Base Updated # generate Diffie Hellman ( DH ) parameter
[root@dlp 3]# ./easyrsa gen-dh
Using SSL: openssl OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021) Generating DH parameters, 2048 bit long safe prime DH parameters of size 2048 created at /usr/share/easy-rsa/3/pki/dh.pem # create TLS-Auth key[root@dlp 3]# openvpn –genkey secret ./pki/ta.key# copy generated certs
[root@dlp 3]# cp -pR /usr/share/easy-rsa/3/pki/{issued,private,ca.crt,dh.pem,ta.key} /etc/openvpn/server/
[3] Configure OpenVPN.
It based on the environment Firewalld is running because of using routing rules.
# copy sample configuration[root@dlp ~]# cp /usr/share/doc/openvpn/sample/sample-config-files/server.conf /etc/openvpn/server/[root@dlp ~]# vi /etc/openvpn/server/server.conf# line 32 : change if need (listening port of OpenVPN)port 1194# line 35 : change if need (use udp on this example);proto tcp
proto udp# line 53 : change if need (use tun on this example);dev tap
dev tun# line 78 : specify certificatesca ca.crtcert issued/server1.crtkey private/server1.key# line 85 : specify DH filedh dh.pem# line 101 : specify network to be used on VPN
# any network are OK except your local networkserver 192.168.100.0 255.255.255.0# line 142 : uncomment and change to your local networkpush “route 10.0.0.0 255.255.255.0″# line 231 : keepalive settingskeepalive 10 120# line 244 : specify TLS-Auth keytls-auth ta.key 0# line 281 : enable persist optionspersist-key
persist-tun# line 287 : change log pathstatus /var/log/openvpn-status.log# line 296 : change log path
log /var/log/openvpn.log log-append /var/log/openvpn.log # line 306 : specify log level (0 – 9, 9 means debug level)verb 3[root@dlp ~]# vi /etc/openvpn/server/add-bridge.sh# create new#!/bin/bash # network interface which can connect to local network IF=enp1s0 # interface VPN tunnel uses # for the case of this example like specifying [tun] on the config, generally this param is [tun0] VPNIF=tun0 # listening port of OpenVPN PORT=1194 firewall-cmd –zone=public –add-masquerade firewall-cmd –direct –add-rule ipv4 filter FORWARD 0 -i ${VPNIF} -o ${IF} -j ACCEPT firewall-cmd –direct –add-rule ipv4 nat POSTROUTING 0 -o ${IF} -j MASQUERADE firewall-cmd –add-port=${PORT}/udp [root@dlp ~]# vi /etc/openvpn/server/remove-bridge.sh# create new#!/bin/bash # network interface which can connect to local network IF=enp1s0 # interface VPN tunnel uses # for the case of this example like specifying [tun] on the config, generally this param is [tun0] VPNIF=tun0 # listening port of OpenVPN PORT=1194 firewall-cmd –zone=public –remove-masquerade firewall-cmd –direct –remove-rule ipv4 filter FORWARD 0 -i ${VPNIF} -o ${IF} -j ACCEPT firewall-cmd –direct –remove-rule ipv4 nat POSTROUTING 0 -o ${IF} -j MASQUERADE firewall-cmd –remove-port=${PORT}/udp [root@dlp ~]# chmod 700 /etc/openvpn/server/{add-bridge.sh,remove-bridge.sh}
[root@dlp ~]# systemctl edit openvpn-server@server# create new[Service] ExecStartPost=/etc/openvpn/server/add-bridge.sh ExecStopPost=/etc/openvpn/server/remove-bridge.sh [root@dlp ~]# systemctl enable –now openvpn-server@server
[4] Transfer certs follows you generated to Client Host you’d like to connect with VPN.
It’s OK all for VPN Server settings.* /etc/openvpn/server/ca.crt
* /etc/openvpn/server/ta.key
* /etc/openvpn/server/issued/client1.crt
* /etc/openvpn/server/private/client1.key
正文完
可以使用微信扫码关注公众号(ID:xzluomor)
post-qrcode
 0
评论(没有评论)

文心AIGC

2024 年 1 月
1234567
891011121314
15161718192021
22232425262728
293031  
文心AIGC
文心AIGC
人工智能ChatGPT,AIGC指利用人工智能技术来生成内容,其中包括文字、语音、代码、图像、视频、机器人动作等等。被认为是继PGC、UGC之后的新型内容创作方式。AIGC作为元宇宙的新方向,近几年迭代速度呈现指数级爆发,谷歌、Meta、百度等平台型巨头持续布局
文章搜索
热门文章
清库存!DeepSeek突然补全R1技术报告,训练路径首次详细公开

清库存!DeepSeek突然补全R1技术报告,训练路径首次详细公开

清库存!DeepSeek突然补全R1技术报告,训练路径首次详细公开 Jay 2026-01-08 20:18:...
训具身模型遇到的很多问题,在数据采集时就已经注定了丨鹿明联席CTO丁琰分享

训具身模型遇到的很多问题,在数据采集时就已经注定了丨鹿明联席CTO丁琰分享

训具身模型遇到的很多问题,在数据采集时就已经注定了丨鹿明联席CTO丁琰分享 衡宇 2026-01-08 20:...
开源“裸考”真实世界,国产具身智能基座模型拿下全球第二!

开源“裸考”真实世界,国产具身智能基座模型拿下全球第二!

开源“裸考”真实世界,国产具身智能基座模型拿下全球第二! 西风 2026-01-08 19:02:20 来源:...
「北京版幻方」冷不丁开源SOTA代码大模型!一张3090就能跑,40B参数掀翻Opus-4.5和GPT-5.2

「北京版幻方」冷不丁开源SOTA代码大模型!一张3090就能跑,40B参数掀翻Opus-4.5和GPT-5.2

「北京版幻方」冷不丁开源SOTA代码大模型!一张3090就能跑,40B参数掀翻Opus-4.5和GPT-5.2...
最新评论
ufabet ufabet มีเกมให้เลือกเล่นมากมาย: เกมเดิมพันหลากหลาย ครบทุกค่ายดัง
tornado crypto mixer tornado crypto mixer Discover the power of privacy with TornadoCash! Learn how this decentralized mixer ensures your transactions remain confidential.
ดูบอลสด ดูบอลสด Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
Obrazy Sztuka Nowoczesna Obrazy Sztuka Nowoczesna Thank you for this wonderful contribution to the topic. Your ability to explain complex ideas simply is admirable.
ufabet ufabet Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
ufabet ufabet You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
ufabet ufabet Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
热评文章
给AI打个分,结果搞出17亿估值独角兽???

给AI打个分,结果搞出17亿估值独角兽???

给AI打个分,结果搞出17亿估值独角兽??? 闻乐 2026-01-07 17:32:01 来源:量子位 「匿...
港科大教授实测AI眼镜“作弊”:30分钟碾压95%的学生,把传统教学评估体系整破防了

港科大教授实测AI眼镜“作弊”:30分钟碾压95%的学生,把传统教学评估体系整破防了

港科大教授实测AI眼镜“作弊”:30分钟碾压95%的学生,把传统教学评估体系整破防了 梦瑶 2026-01-0...
全自主、更好用!北京人形 “干活机器人” 惊艳亮相 CES2026

全自主、更好用!北京人形 “干活机器人” 惊艳亮相 CES2026

全自主、更好用!北京人形 “干活机器人” 惊艳亮相 CES2026 量子位的朋友们 2026-01-06 16...
杜比在CES 2026重塑了观影、娱乐的方式

杜比在CES 2026重塑了观影、娱乐的方式

杜比在CES 2026重塑了观影、娱乐的方式 十三 2026-01-07 12:47:06 来源:量子位 树立...