差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

下次修改
前次修改
tech:openvpn-client_ubuntu [2022/06/02 19:10] – 建立 jonathantech:openvpn-client_ubuntu [2023/04/19 12:40] (目前版本) jonathan
行 9: 行 9:
  
 ===== 設定 OpenVPN Client ===== ===== 設定 OpenVPN Client =====
-  * 先透過 OpenVPN Server 取得到相關的憑證設定檔, 請參考 [[tech/openvpn]] 建立用戶憑證檔案 +  * 先透過 OpenVPN Server 取得到相關的憑證設定檔, Exp. amalia_gpu.ovpn 
-  * 將取得的  ca.crt / client1.key / client1.crt / ta.key / 以及範例的 ideas_tp.ovpn 放入 /etc/openvpn/ 內 <file> +  * 將取得的 amalia_gpu.ovpn 放入 /etc/openvpn/ 內 <file> 
-[root@openvpn-client openvpn]# pwd+root@amalia:/etc/openvpn# pwd
 /etc/openvpn /etc/openvpn
-[root@openvpn-client openvpn]# ls +root@amalia:/etc/openvpn# ls 
-ca.crt  ideas_tp.conf  client1.crt  client1.key  ta.key+amalia_gpu.ovpn  client  server  update-resolv-conf
 </file> </file>
-  * 透過手動命令列方式來確認是否設定檔都正確  openvpn --config ideas_tp.conf <code sh> +  * 透過手動命令列方式來確認是否設定檔都正確  openvpn --config amalia_gpu.ovpn <code sh> 
-[root@openvpn-client openvpn]# openvpn --config ideas_tp.conf +root@amalia:/etc/openvpn# openvpn --config amalia_gpu.ovpn 
-Tue May 20 15:22:24 2014 OpenVPN 2.3.x86_64-redhat-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Sep 12 2013 +Jun  2 19:18:20 OpenVPN 2.4.x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Mar 22 2022 
-Tue May 20 15:22:24 2014 WARNING: file 'jonathan-xpc.key' is group or others accessible +Jun  2 19:18:20 library versionsOpenSSL 1.1.1f  31 Mar 2020, LZO 2.10 
-Tue May 20 15:22:24 2014 WARNING: file 'ta.key' is group or others accessible +Jun  2 19:18:20 Outgoing Control Channel Authentication: Using 256 bit message hash 'SHA256' for HMAC authentication 
-Tue May 20 15:22:24 2014 Control Channel Authentication: using 'ta.key' as a OpenVPN static key file +Jun  2 19:18:20 Incoming Control Channel Authentication: Using 256 bit message hash 'SHA256' for HMAC authentication
-Tue May 20 15:22:24 2014 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication +
-Tue May 20 15:22:24 2014 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication +
-Tue May 20 15:22:24 2014 Socket Buffers: R=[87380->131072] S=[16384->131072] +
-Tue May 20 15:22:24 2014 Attempting to establish TCP connection with [AF_INET]175.98.115.2:443 [nonblock]+
 : :
 : :
-Tue May 20 15:22:28 2014 /sbin/ip route add 192.168.102.0/24 via 192.168.201.61 +Jun  2 19:18:23 /sbin/ip route add 10.20.0.0/24 via 10.121.101.73 
-Tue May 20 15:22:28 2014 /sbin/ip route add 192.167.102.0/24 via 192.168.201.61 +Jun  2 19:18:23 /sbin/ip route add 10.50.1.0/24 via 10.121.101.73 
-Tue May 20 15:22:28 2014 /sbin/ip route add 192.168.201.1/32 via 192.168.201.61 +Jun  2 19:18:23 /sbin/ip route add 10.121.101.0/24 via 10.121.101.73
-Tue May 20 15:22:28 2014 Initialization Sequence Completed+
 </code> </code>
-  * 將 範例的 ideas_tp.ovpn 改成 ideas_tp.conf 然後將 openvpn 服務啟動就會自動連上 <code sh+  * 將 範例的 amalia_gpu.ovpn 改成 client.conf 然後將 openvpn 服務啟動就會自動連上 <cli
-[root@openvpn-client openvpn]# service openvpn start +cp amalia_gpu.ovpn client.conf 
-正在啟動 openvpn:                                          確定  ] +</cli
-</code+  * 設定開機自動連上去 VPN Server <cli
-  * 設定開機自動連上去 VPN Server <code sh+sudo vi /etc/default/openvpn 
-chkconfig openvpn on +</cli><file> 
-</code><file> +
-[root@openvpn-client openvpn]chkconfig --list | grep openvpn +AUTOSTART="all" 
-openvpn         0:關閉  1:關閉  2:開啟  3:開啟  4:開啟  5:開啟  6:關閉 +
-</file>+</file><cli> 
 +sudo systemctl enable openvpn@client.service 
 +sudo systemctl daemon-reload 
 +sudo service openvpn@client start 
 +</cli> 
 +  * 確認連上 OpenVPN Server 所取得的 IP <cli> 
 +ip a | grep tun 
 +</cli>結果如下<cli> 
 +root@amalia:/etc/openvpn# ip a | grep tun 
 +11tun0<POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100 
 +    inet 10.121.101.74 peer 10.121.101.73/32 scope global tun0 
 +</cli>可知道 openvpn 取得到的 ip 是 10.121.101.74 
 + 
 +===== 取消與關閉 openvpn ===== 
 +  * <cli> 
 +sudo service openvpn@client stop 
 +sudo systemctl disable [email protected] 
 +sudo systemctl daemon-reload 
 +</cli> 
 +  * 確認已經沒有連上 OpenVPN Server 所取得的 IP <cli> 
 +ip a | grep tun 
 +</cli>結果應該不會出現任何 ip 
  
 ===== 參考網址 ===== ===== 參考網址 =====
   * https://tecadmin.net/install-openvpn-client-on-ubuntu/   * https://tecadmin.net/install-openvpn-client-on-ubuntu/
 +  * https://www.ivpn.net/knowledgebase/linux/linux-autostart-openvpn-in-systemd-ubuntu/
  
 {{tag>openvpn}} {{tag>openvpn}}
  
  • tech/openvpn-client_ubuntu.1654168254.txt.gz
  • 上一次變更: 2022/06/02 19:10
  • jonathan