首页 > 其他分享 >将 OpenVP 客户端作为 Systemd 服务运行

将 OpenVP 客户端作为 Systemd 服务运行

时间:2023-11-20 13:00:48浏览次数:34  
标签:Systemd 14 16 OpenVP 00 koromicha openvpn 6877 客户端

为了在服务器重新启动时自动建立连接,可以启用 OpenVPN 客户端 systemd 服务。

将 OpenVP 客户端作为 Systemd 服务运行_客户端

在执行此操作之前,请将 VPN 配置文件的扩展名从 更改.ovpn.conf. 相应地替换文件名。

cp koromicha.ovpn koromicha.conf

将文件复制.conf到 OpenVPN 客户端配置目录/etc/openvpn/client.


cp koromicha.conf /etc/openvpn/client
/etc/openvpn/client

接下来,启动 OpenVPN 客户端 systemd 服务。将名称koromicha替换为 .conf 配置文件的名称。

systemctl start openvpn-client@koromicha

检查状态;


systemctl status openvpn-client@koromicha
[email protected] - OpenVPN tunnel for koromicha
   Loaded: loaded (/lib/systemd/system/[email protected]; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-04-14 16:00:35 EAT; 8s ago
     Docs: man:openvpn(8)
           https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
           https://community.openvpn.net/openvpn/wiki/HOWTO
 Main PID: 6877 (openvpn)
   Status: "Initialization Sequence Completed"
    Tasks: 1 (limit: 2300)
   CGroup: /system.slice/system-openvpn\x2dclient.slice/[email protected]
           └─6877 /usr/sbin/openvpn --suppress-timestamps --nobind --config koromicha.conf

Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: Incoming Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key
Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: ROUTE_GATEWAY 10.0.2.2/255.255.255.0 IFACE=enp0s3 HWADDR=08:00:27:4b:ff:18
Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: TUN/TAP device tun0 opened
Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: TUN/TAP TX queue length set to 100
Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: /sbin/ip link set dev tun0 up mtu 1500
Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: /sbin/ip addr add dev tun0 10.8.0.2/24 broadcast 10.8.0.255
Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: /sbin/ip route add 192.168.2.132/32 via 10.0.2.2
Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: /sbin/ip route add 0.0.0.0/1 via 10.8.0.1
Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: /sbin/ip route add 128.0.0.0/1 via 10.8.0.1
Elb 14 16:00:37 ubuntu1804.kifarunix-demo.com openvpn[6877]: Initialization Sequence Completed

使其能够在系统启动时运行;

systemctl enable openvpn-client@koromicha

您已在 CentOS 8 上成功安装和设置 OpenVPN 客户端。

关于如何在 CentOS 8上安装和配置 OpenVP 客户端的教程到此结束。


标签:Systemd,14,16,OpenVP,00,koromicha,openvpn,6877,客户端
From: https://blog.51cto.com/chenxuewen/8487490

相关文章