惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Blog — PlanetScale
Blog — PlanetScale
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
L
LangChain Blog
F
Fortinet All Blogs
C
Check Point Blog
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
J
Java Code Geeks
月光博客
月光博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
宝玉的分享
宝玉的分享
Jina AI
Jina AI

方永、南天紫雲

linux透明代理 技术的边界 停机问题通俗说明 Rust与oracle、redis集群的纠结 学习能力的增长 微信调试的原语 mac外接移动硬盘安装ArchLinux linux的死机问题 linux下全键盘操作 漂亮又好用的bspwm linux本机透明代理 ssh、mosh、autossh linux不能待机又一例 从WordPress切换到Hugo 折腾电脑开机 linux系统QQ新思路 Arch Linux的字体渲染 svn管理之submin OpenWrt自动fucking墙記錄 二维码(qrcode)名片的一些事儿 用lua nginx module搭建一个二维码(qr code)生成器 CentOS 7 安裝註記 php程序連接MySQL时只能127.0.0.1而localhost無法連接的問題 ThinkPad之FAN_ERROR、hi fi聲卡 jetty多端口部署 OpenWrt簡單暴力限網 linux中cron之PATH变量 OpenWrt的WDS無線橋接模式 再敘OpenWrt下的rtl8187無線中繼 sed之模擬tail
ArchLinux配置ipsec之VPN客户端
zola · 2021-02-18 · via 方永、南天紫雲

ArchLinux 配置 L2TP/IPSec VPN 流水帐。

安装软件包

pacman -S strongswan xl2tpd 

生成配置文件

VPN_SERVER_IP='your vpn server address'
VPN_IPSEC_PSK='your psk'
VPN_USER='your username'
VPN_PASSWORD='your password'

cat > /etc/ipsec.conf <<EOF
# ipsec.conf - strongSwan IPsec configuration file

conn myvpn
  auto=add
  authby=secret
  right=$VPN_SERVER_IP
EOF

cat > /etc/ipsec.secrets <<EOF
: PSK "$VPN_IPSEC_PSK"
EOF

chmod 600 /etc/ipsec.secrets

cat > /etc/xl2tpd/xl2tpd.conf <<EOF
[lac vpn-connection]
lns = $VPN_SERVER_IP
ppp debug = yes
pppoptfile = /etc/ppp/options.l2tpd.client
length bit = yes
EOF

cat > /etc/ppp/options.l2tpd.client <<EOF
ipcp-accept-local
ipcp-accept-remote
refuse-eap
require-mschap-v2
noccp
noauth
idle 1800
mtu 1410
mru 1410
defaultroute
usepeerdns
debug
connect-delay 5000
name $VPN_USER
password $VPN_PASSWORD
EOF
systemctl start strongswan-starter
ipsec up myvpn
systemctl start xl2tpd
echo "c vpn-connection" > /var/run/xl2tpd/l2tp-control

添加路由

ip route add xxx.xxx.xxx.xxx via yyy.yyy.yyy.yyy dev pppX

其中,xxx.xxx.xxx.xxx 是需要被路由的ip或网段,比如192.168.3.0/24, yyy.yyy.yyy.yyy是拨号成功后的ip地址, pppX是拨号成功后的虚拟设备, 可用ip address命令查看。

2022-03-16 更新说明

  1. 更新 /etc/ipsec.conf ,去除无用配置项
  2. 注意执行 ipsec up myvpn 时会有报错,不用处理,执行后续命令即可,然后 ping <ppp peer ip address> 测试

参考

  1. Openswan L2TP/IPsec VPN client setup
  2. setup-ipsec-vpn
  3. strongSwan