openvpn이 설정될 때 여러 스크립트를 실행하는 방법은 무엇입니까?

openvpn이 설정될 때 여러 스크립트를 실행하는 방법은 무엇입니까?

나는 사용하고있다우분투 12.04openvpn 서버에 연결합니다.

두 개의 스크립트,업데이트-해결-conf그리고VPN-up.sh, 연결이 설정되면 /etc/openvpn에서 실행되어야 합니다.

구성 파일에 다음 명령이 추가됩니다.클라이언트.ovpnopenvpn이 연결될 때 두 스크립트가 실행되고 openvpn이 연결이 끊길 때 중지되도록 하려면:

script-security 2
up /etc/openvpn/update-resolv-conf
up /etc/openvpn/vpn-up.sh
down /etc/openvpn/vpn-down.sh
down /etc/openvpn/update-resolv-conf

그러나 연결 중에는 첫 번째 스크립트만 실행됩니다. 그리고 스크립트를 실행해야 할 때마다VPN-up.sh개별적으로 손으로. 그래서 openvpn 터널이 설정될 때 두 가지를 모두 작동시키는 방법을 알고 싶습니다.

답변1

빠른 해킹은 마지막 스크립트 끝에서 두 번째 스크립트를 호출하는 것입니다.

'/etc/openvpn/update-resolv-conf' 스크립트 끝에 다음을 추가하면 됩니다.

/etc/openvpn/vpn-up.sh

나는 여기 사람들이 이 작업을 수행하는 더 우아한 방법을 제공할 것이라고 확신합니다.

답변2

참고용으로만 사용하세요. 스크립트가 몇 개 있고 타이밍이 중요하지 않은 경우 스크립트 실행을 위해 다른 매개변수를 사용할 수도 있습니다.

Script Order of Execution

--up
Executed after TCP/UDP socket bind and TUN/TAP open.
--tls-verify
Executed when we have a still untrusted remote peer.
--ipchange
Executed after connection authentication, or remote IP address change.
--client-connect
Executed in --mode server mode immediately after client authentication.
--route-up
Executed after connection authentication, either immediately after, or some number of seconds after as defined by the --route-delay option.
--client-disconnect
Executed in --mode server mode on client instance shutdown.
--down
Executed after TCP/UDP and TUN/TAP close.
--learn-address
Executed in --mode server mode whenever an IPv4 address/route or MAC address is added to OpenVPN's internal routing table.
--auth-user-pass-verify
Executed in --mode server mode on new client connections, when the client is still untrusted.

https://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html

답변3

up '/bin/bash -c "/etc/openvpn/update-resolv-conf; /etc/openvpn/vpn-up.sh"'

관련 정보