이더넷 연결이 설정되면 자동으로 OpenVPN을 시작하려고 합니다(Private Internet Access VPN에 연결됩니다).
/etc/NetworkManager/disaptcher.d/99-custom_script_handler가 있습니다.
#!/bin/bash
if [ "$1" = "eth0" ] && [ "$2" = "up" ]
then
echo "$(date): Starting tunnel script" >> /root/tunnel.log
/bin/bash /root/start_tunnel_script
else
echo No action for this combination
fi
이것은 정상적으로 실행되고 "start_tunnel_script"를 시작합니다.
/root/터널 스크립트 시작
#!/bin/bash
echo "$(date): Running tunnel script as $(whoami)" >> /root/tunnel.log
LOCATION="Netherlands"
openvpn --echo --daemon --cd /etc/openvpn/client/pia_ovpn/ --config "$LOCATION.ovpn" --auth-user-pass /root/.pia_credentials --script-security 2 --syslog --up /root/bootstrap
그러나 OpenVPN은 구성 파일을 찾을 수 없다고 보고합니다.
Sep 3 15:12:39 test openvpn[4056]: Options error: In [CMD-LINE]:1: Error opening configuration file: Netherlands.ovpn
Sep 3 15:12:39 test openvpn[4056]: Use --help for more information.
Sep 3 15:12:39 test nm-dispatcher: req:4 'up' [eth0], "/etc/NetworkManager/dispatcher.d/99-custom_script_handler": complete: failed with Script '/etc/NetworkManager/dispatcher.d/99-custom_script_handler' exited with error status 1.
Sep 3 15:12:39 test NetworkManager[645]: <warn> [1504465959.2123] dispatcher: (40) 99-custom_script_handler failed (failed): Script '/etc/NetworkManager/dispatcher.d/99-custom_script_handler' exited with error status 1.
Sep 3 15:12:40 test NetworkManager[645]: <info> [1504465960.9892] policy: set 'eth0' (eth0) as default for IPv6 routing and DNS
그러나 구성 파일은 분명히 존재합니다.
# ls -al /etc/openvpn/client/pia_ovpn/
total 160
drwxr-xr-x. 2 root root 4096 Sep 2 14:37 .
drwxr-x---. 3 root root 22 Sep 2 14:37 ..
-rw-r--r--. 1 root root 295 Feb 6 2017 AU Melbourne.ovpn
-rw-r--r--. 1 root root 285 Feb 6 2017 AU Sydney.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Brazil.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 CA Montreal.ovpn
-rw-r--r--. 1 root root 2025 Feb 6 2017 ca.rsa.2048.crt
-rw-r--r--. 1 root root 292 Feb 6 2017 CA Toronto.ovpn
-rw-r--r--. 1 root root 869 Feb 6 2017 crl.rsa.2048.pem
-rw-r--r--. 1 root root 289 Feb 6 2017 Denmark.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Finland.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 France.ovpn
-rw-r--r--. 1 root root 289 Feb 6 2017 Germany.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Hong Kong.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 India.ovpn
-rw-r--r--. 1 root root 289 Feb 6 2017 Ireland.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Israel.ovpn
-rw-r--r--. 1 root root 287 Feb 6 2017 Italy.ovpn
-rw-r--r--. 1 root root 287 Feb 6 2017 Japan.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Mexico.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Netherlands.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 New Zealand.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Norway.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Romania.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Singapore.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 South Korea.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Sweden.ovpn
-rw-r--r--. 1 root root 287 Feb 6 2017 Switzerland.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Turkey.ovpn
-rw-r--r--. 1 root root 291 Feb 6 2017 UK London.ovpn
-rw-r--r--. 1 root root 296 Feb 6 2017 UK Southampton.ovpn
-rw-r--r--. 1 root root 295 Feb 6 2017 US California.ovpn
-rw-r--r--. 1 root root 292 Feb 6 2017 US Chicago.ovpn
-rw-r--r--. 1 root root 289 Feb 6 2017 US East.ovpn
-rw-r--r--. 1 root root 292 Feb 6 2017 US Florida.ovpn
-rw-r--r--. 1 root root 292 Feb 6 2017 US Midwest.ovpn
-rw-r--r--. 1 root root 296 Feb 6 2017 US New York City.ovpn
-rw-r--r--. 1 root root 292 Feb 6 2017 US Seattle.ovpn
-rw-r--r--. 1 root root 298 Feb 6 2017 US Silicon Valley.ovpn
-rw-r--r--. 1 root root 290 Feb 6 2017 US Texas.ovpn
-rw-r--r--. 1 root root 289 Feb 6 2017 US West.ovpn
쉘에서 루트로 "start_tunnel_script"를 실행하면 작동합니다. 이것이 가장 좋은 부분입니다. 문제는 start_tunnel_script가 시작되는 방식이지만 평생 동안 무엇이 다른지 알 수 없습니다.
답변1
"pia_ovpn" 폴더의 잘못된 SELinux 컨텍스트 설정
restorecon -R /etc/openvpn/client