openvpn[]: オプションエラー: [CMD-LINE]:1: 設定ファイルを開くときにエラーが発生しました

openvpn[]: オプションエラー: [CMD-LINE]:1: 設定ファイルを開くときにエラーが発生しました

しようとするときservice openvpn start

Oct 12 14:02:01 ccushing1 openvpn[9091]: Options error: In [CMD-LINE]:1: Error opening configuration file: devnet-client-vm.conf

実行はopenvpn devnet-client-vm.conf問題なく動作します。なぜ openvpn が起動しないのでしょうか? どうすれば修正できますか?

答え1

走ってみたくなるかもしれない

fixfiles -R openvpn restore

ls -alZ を実行すると、次のような結果が表示されます (ファイルが正しい selinux コンテキストにあることが示されます)。

[root@server openvpn]# ls -alZ /etc/openvpn/
drwxr-xr-x. root    root    system_u:object_r:openvpn_etc_t:s0 .
drwxr-xr-x. root    root    system_u:object_r:etc_t:s0       ..
drwxr-xr-x. root    root    unconfined_u:object_r:openvpn_etc_t:s0 certs
-rw-r--r--. root    root    unconfined_u:object_r:openvpn_etc_t:s0 dh2048.pem
drwxr-xr-x. root    root    unconfined_u:object_r:openvpn_etc_t:s0 easy-rsa
-rw-------. root    root    unconfined_u:object_r:openvpn_etc_rw_t:s0 ipp.txt
-rw-------. root    root    unconfined_u:object_r:openvpn_etc_t:s0 ta.key
-rw-------. openvpn openvpn unconfined_u:object_r:openvpn_etc_t:s0 server.conf

次のような文があった場合

status openvpn-status.log

openvpnの設定ファイルで、サーバーがまだ起動しないことに気付くかもしれません。/var/log/audit/audit.logを覗いてみると、

type=AVC msg=audit(1413580155.710:1265): avc:  denied  { write } for  pid=19725 comm="openvpn" name="openvpn-status.log" dev="dm-1" ino=54153273 scontext=system_u:system_r:openvpn_t:s0 tcontext=unconfined_u:object_r:openvpn_etc_t:s0 tclass=file

このファイルのコンテキストを rw に変更すると、問題は解決します。

chcon -t openvpn_etc_rw_t openvpn-status.log

そして

[root@server openvpn]# ls -alZ openvpn-status.log
-rw-------. root    root    unconfined_u:object_r:openvpn_etc_t:s0 openvpn-status.log

となります

-rw-------. root    root    unconfined_u:object_r:openvpn_etc_rw_t:s0 openvpn-status.log

その後、電話

service openvpn@server start

完璧に動作しました。

[root@server openvpn]# service openvpn@server status
Redirecting to /bin/systemctl status  [email protected]
[email protected] - OpenVPN Robust And Highly Flexible Tunneling Application On server
   Loaded: loaded (/usr/lib/systemd/system/[email protected]; disabled)
   Active: active (running) since Fri 2014-10-17 23:13:49 CEST; 9s ago
  Process: 20445 ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf (code=exited, status=0/SUCCESS)
 Main PID: 20449 (openvpn)
   CGroup: /system.slice/system-openvpn.slice/[email protected]
           └─20449 /usr/sbin/openvpn --daemon --writepid /var/run/openvpn/server.pid --cd /etc/openvpn/ --config server.conf

Oct 17 23:13:49 server openvpn[20445]: ROUTE_GATEWAY xx.xxx.xx.x/255.255.255.0 IFACE=eth0 HWADDR=XX:XX:XX:XX:XX:XX
Oct 17 23:13:49 server openvpn[20449]: GID set to nobody
Oct 17 23:13:49 server openvpn[20449]: UID set to nobody
Oct 17 23:13:49 server openvpn[20449]: UDPv4 link local (bound): [undef]
Oct 17 23:13:49 server openvpn[20449]: UDPv4 link remote: [undef]
Oct 17 23:13:49 server openvpn[20449]: MULTI: multi_init called, r=256 v=256
Oct 17 23:13:49 server openvpn[20449]: IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0
Oct 17 23:13:49 server systemd[1]: Started OpenVPN Robust And Highly Flexible Tunneling Application On server.
Oct 17 23:13:49 server openvpn[20449]: IFCONFIG POOL LIST
Oct 17 23:13:49 server openvpn[20449]: Initialization Sequence Completed

PS: Centos 7 を使用しています。

答え2

このスレッドを見つけた他の人のために言っておくと、私は Fedora 26 で同じ問題を抱えていました。私が従っていた手順では、conf ファイルを /etc/openvpn ディレクトリに置くように指示されていましたが、実際には /etc/openvpn/server に置く必要がありました。

答え3

問題は SELinux です。編集して/etc/sysconfig/selinux設定しSELINUX=permissive、再起動すると、私の場合は修正されました。Fedora では、cert ディレクトリを適切に使用できるようにするために実行する必要のあるコマンドがあったことを覚えていますが、そのコマンドが何だったかは忘れてしまいました。permissive に設定すると完全に修正されますが、より好ましい方法は、ディレクトリを適切に使用できるように修正することです。

答え4

上記のエラーは、confファイルを client次のディレクトリに移動することで解決しました。

/etc/openvpn/client/openvpn.conf

関連情報