클라이언트 VPN 연결이 성공한 후 네트워크 공유를 어떻게 매핑할 수 있나요?

클라이언트 VPN 연결이 성공한 후 네트워크 공유를 어떻게 매핑할 수 있나요?

저는 최근 직장에서 일부 "외근 근무자"에게 VPN 기능을 제공하는 임무를 받았습니다. 저는 CentOS 5.4 Linux 서버를 실행하고 있습니다. 저는 VPN 서버로 OpenVPN을 선택했고 여러 Windows XP 및 7 클라이언트를 성공적으로 배포하고 테스트했습니다. 따라서 네트워크 공유를 수동으로 매핑할 수 있었습니다. 이 시점에서는 모든 연결이 성공적이고 안정적입니다.

제가 원하는 것은 VPN 터널이 성공적으로 설정되면 네트워크 공유를 생성하는 배치 파일을 자동으로 실행할 수 있도록 하는 것입니다. 어떻게 해야 하나요?

나는 다음에서 up 또는 Route-up 명령에 대해 조금 읽었습니다.OpenVPN 매뉴얼 페이지하지만 배치 파일을 호출하는 방법을 알 수 없는 것 같습니다. 어떤 도움이라도 도움이 될 것입니다.

답변1

공유 이름이 항상 동일한 경우 OS 내에서 항상 매핑할 수 있으며 사용자가 VPN에 있을 때까지 연결이 끊긴 상태에 있게 됩니다. 이것이 우리가 하는 방법이며 잘 작동합니다.

매뉴얼 페이지를 보면 이것이 명령줄에 필요한 것이라고 생각됩니다.

--up c:\script.bat

아래는 그 부분이다

--up cmd
Shell command to run after successful TUN/TAP device open (pre --user UID change). The up script is useful for specifying route commands which route IP traffic destined for private subnets which exist at the other end of the VPN connection into the tunnel.
For --dev tun execute as:

cmd tun_dev tun_mtu link_mtu ifconfig_local_ip ifconfig_remote_ip [ init | restart ]

For --dev tap execute as:

cmd tap_dev tap_mtu link_mtu ifconfig_local_ip ifconfig_netmask [ init | restart ]

See the "Environmental Variables" section below for additional parameters passed as environmental variables.

Note that cmd can be a shell command with multiple arguments, in which case all OpenVPN-generated arguments will be appended to cmd to build a command line which will be passed to the shell.

Typically, cmd will run a script to add routes to the tunnel.

Normally the up script is called after the TUN/TAP device is opened. In this context, the last command line parameter passed to the script will be init. If the --up-restart option is also used, the up script will be called for restarts as well. A restart is considered to be a partial reinitialization of OpenVPN where the TUN/TAP instance is preserved (the --persist-tun option will enable such preservation). A restart can be generated by a SIGUSR1 signal, a --ping-restart timeout, or a connection reset when the TCP protocol is enabled with the --proto option. If a restart occurs, and --up-restart has been specified, the up script will be called with restart as the last parameter.

The following standalone example shows how the --up script can be called in both an initialization and restart context. (NOTE: for security reasons, don't run the following example unless UDP port 9999 is blocked by your firewall. Also, the example will run indefinitely, so you should abort with control-c).

openvpn --dev tun --port 9999 --verb 4 --ping-restart 10 --up 'echo up' --down 'echo down' --persist-tun --up-restart

Note that OpenVPN also provides the --ifconfig option to automatically ifconfig the TUN device, eliminating the need to define an --up script, unless you also want to configure routes in the --up script.

If --ifconfig is also specified, OpenVPN will pass the ifconfig local and remote endpoints on the command line to the --up script so that they can be used to configure routes such as:

route add -net 10.0.0.0 netmask 255.255.255.0 gw $5

그런 다음 매핑된 드라이브를 제거하기 위해 하나를 다운로드할 수도 있습니다.

관련 정보