2018年3月28日 星期三

Re: CentOS 架 L2TP/IPsec VPN


一些設定或IP地址請參考:CentOS 架 L2TP/IPsec VPN


這陣子都在家裡工作,大部分時間都用VPN連回公司,遇到兩個問題。

  1. 家裡網段剛好跟公司網段一樣,連不進公司的設備。
  2. VPN連上後,五分鐘左右時間沒有用就會斷線。

第一個問題是假設家裡網段是192.168.1.0/24,公司網段也是,VPN配到的網段是172.30.10.0/24,如果想要連到公司那端的設備例如:「192.168.1.150」,卻會因為路由表關係是連到本地端的「192.168.1.150」,解決方法很簡單,就是增加路由表。

前一篇設定預設閘道是「172.30.10.1」,指令:
$ sudo route add -host 192.168.1.150 172.30.10.1

直接增加一筆entry讓往192.168.1.150的封包送往172.30.10.1,讓他送往另一端。


第二個問題google了一下,關鍵字是「keep alive」,在檔案「/etc/strongswan/strongswan.conf」增加「keep_alive = 30s」。

[root@vpn ~]# cat /etc/strongswan/strongswan.conf 
# strongswan.conf - strongSwan configuration file
#
# Refer to the strongswan.conf(5) manpage for details
#
# Configuration changes should be made in the included files

charon {
 load_modular = yes
 plugins {
  include strongswan.d/charon/*.conf
 }
 keep_alive = 30s
}

記得restart service。
[root@vpn ~]# service strongswan restart
[root@vpn ~]# service xl2tpd restart

沒有留言:

張貼留言