最後更新: 2024-02-10
目錄
- Windown GUI
- 儲放 config 的位置
- Install window NIC driver
- Set IP on Windows
- Set NIC(tap name) on Windows
Windown GUI
Version:
openvpn-gui-1.0.3
Auto Start
Step0: 測試 CLI 先
* .ovpn files can be found in the 'C:\Program Files\OpenVPN\config' folder
"%ProgramFiles%\OpenVPN\bin\openvpn-gui.exe" --connect xxxxx.ovpn
* Windows 7 and 8, OpenVPN-GUI must be run as administrator in order for the VPN to properly function.
(Disable the UAC / set the program to always run as administrator)
方法 1:
START -> RUN -> regedit.exe
去以下的 key
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
新增 "S" (REG_SZ)
name: OpenVPN
value: "%ProgramFiles%\OpenVPN\bin\openvpn-gui.exe" --connect home.ovpn
方法 2:
用 StartupCPL2.8
* For Windows Vista and Windows 7 and 8, OpenVPN-GUI must be run as administrator in order for the VPN to properly function.
(avoid these conflicts is to disable the UAC)
(always run as administrator in the properties of the application)
有用 Opts
- --silent_connection # 1=Do not show the status dialog while connecting / non-critical warnings at startup
- --append_string # 1=Append to log file. 0=Truncate logfile
- --show_balloon # 0=Never; 1=At initial connect; 2=At every (連接成功時會 show 自己拿到的 IP)
- --allow_edit # 1=Show "Edit Config" menu (右 click 右下角的 Icon 沒有 "Edit Config")
My Example
Windows shortcut
openvpn-gui.exe --connect xxxxx.ovpn --silent_connection 1 --append_string 0 --show_balloon 0 --allow_edit 0
Show OVPN interface
C:\Program Files\OpenVPN\bin>openvpn.exe --show-adapters
Available TAP-WIN32 adapters [name, GUID]: 'openvpn' {E8C50CC2-FB3E-4E89-BF66-699BFB7083CE}
Remark
openvpn 係自己改的名
Auto connect on Logon
Run -> taskschd.msc
"Actions" -> "Create Basic Task…"
"C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --connect myprofile.ovpn
Setting:
- "When I log on"
- "Run with highest privileges"
之後人手 run 一次測試
儲放 config 的位置
-
HKEY_CURRENT_USER\Software\OpenVPN-GUI\configs
- 由 OpenVPN-GUI 提供 -
%userprofile%\OpenVPN\config
- 當沒有設定 log 時, 會 log 到 %userprofile%\OpenVPN\log\FILE.log - C:\Program Files\OpenVPN\config
Install window NIC driver
執行
C:\Program Files\OpenVPN\bin\addtap.bat
# 行一次, 多一張 NIC
# 它們可以在"硬件管理員見到"TAP-Win32 Provider V9
addtap.bat:
rem Add a new TAP virtual ethernet adapter "C:\Program Files\OpenVPN\bin\tapinstall.exe" install "C:\Program Files\OpenVPN\driver\OemWin2k.inf" tap0901 pause
Folder 名並不重要, 重要的是 folder 內的設定檔案名 !!
Set IP on Windows
ip-win32 method
在 Windows client 使用 --ifconfig 設定 TAP-Win32 adapter IP 時所用到的 "method"
OVPN 會以 method 去設定 IP
method:
- dynamic (Default) - By replying to DHCP query messages generated by the kernel.
- netsh - By Windows command-line "netsh"
- ipapi - By IP helper API
i.e.
1) 使用了 default 的 dynamic 去設定 IP
ifconfig 192.168.123.200 255.255.255.0
2) 當 Server subnet 有 DHCP Server 時, 會出現雙 IP 情況
ip-win32 netsh ifconfig 192.168.123.200 255.255.255.0
* 使用 "--ip-win32 netsh" 後就必須使用 "--ifconfig"
Set NIC(tap name) on Windows
--dev-node node
Explicitly set the device node
# 查看 NIC 的 GUID
openvpn.exe --show-adapters
OVPN' {x-x-x-x-x} tap-windows6
.ovpn Settings
dev-node {x-x-x-x-x} dev-type tap
* If OpenVPN cannot figure out whether node is a TUN or TAP device based on the name,
you should also specify --dev-type tun or --dev-type tap.
Notes
dev-type tap / tun
- tun = OSI Layer 3
- tap = OSI Layer 2
Use this option only if the TUN/TAP device used with --dev does not begin with tun or tap.
* You must use either tun devices on both ends of the connection or tap devices on both ends.
(You cannot mix them)
dev tunX | tapX | null
TUN/TAP virtual network device ( X can be omitted for a dynamic device )