centos7部署l2tp ipsec

简介: 1、查询操作系统版本#cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) 2、查询系统是否支持ppp,返回yes代表通过。#modprobe ppp-compress-18 && echo yes3、查询系统是否开启了tun,返回File descriptor in bad state代表通过。

1、查询操作系统版本

#cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 

2、查询系统是否支持ppp,返回yes代表通过。

#modprobe ppp-compress-18 && echo yes

3、查询系统是否开启了tun,返回File descriptor in bad state代表通过。

#cat /dev/net/tun

4、安装epel源

#yum install epel-release -y

5、安装xl2tpd和libreswan。centos7 版本,libreswan(ipsec)代替了openswan.

#yum install -y xl2tpd libreswan

6、编辑ipsec.conf配置文件,保持默认配置吧

config setup
        protostack=netkey
        dumpdir=/var/run/pluto/
        virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v4:25.0.0.0/8,%v4:100.64.0.0/10,%v6:fd00::/8,%v6:fe80::/10
 
include /etc/ipsec.d/*.conf

7、新建/etc/ipsec.d/l2tp-ipsec.conf文件

#vim /etc/ipsec.d/l2tp-ipsec.conf
conn L2TP-PSK-NAT
  rightsubnet=0.0.0.0/0
  dpddelay=10
  dpdtimeout=20
  dpdaction=clear
  forceencaps=yes
  also=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
  authby=secret
  pfs=no
  auto=add
  keyingtries=3
  rekey=no
  ikelifetime=8h
  keylife=1h
  type=transport
  left=192.168.10.9    #ppp接口的IP地址,对应下面的xl2tpd的配置文件
  leftprotoport=17/1701
  right=%any
  rightprotoport=17/%any

8、配置置预共享密钥PSK

#vim /etc/ipsec.d/default.secrets
: PSK "123A?a456"

9、编辑xl2tpd配置文件

#vim /etc/xl2tpd/xl2tpd.conf
[lns default]
ip range = 192.168.10.10-192.168.10.100
local ip = 192.168.10.9
require chap = yes
refuse pap = yes
require authentication = yes
name = LinuxVPNserver
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes

10、编辑pppoptfile文件

#vim /etc/ppp/options.xl2tpd
ipcp-accept-local
ipcp-accept-remote
ms-dns  192.168.10.3  #内部的DNS服务器
ms-dns  114.114.114.114
name xl2tpd
#noccp
auth
#crtscts
idle 1800
mtu 1410
mru 1410
nodefaultroute
debug
#lock
proxyarp
connect-delay 5000
refuse-pap
refuse-mschap
require-mschap-v2
persist
logfile /var/log/xl2tpd.log

11、配置拨号用户名和密码

vim /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client        server  secret 
# 格式为:用户名  服务类型  密码  允许访问的ip
# *代表所有
aliyunvip    *      Abc?123       *

12、配置CentOS7 防火墙

#firewall-cmd --permanent --add-service=ipsec      #允许ipsec服务
#firewall-cmd --permanent --add-port=1701/udp    #允许 xl2tp 
#firewall-cmd --permanent --add-port=4500/udp   #允许 xl2tp
#firewall-cmd --permanent --add-masquerade       #启用nat转发
#firewall-cmd --reload                          #重新加载配置

13、修改内核参数

#vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.send_redirects = 0

#sysctl -p  #修改内核生效

14、启动ipsec服务

#systemctl enable ipsec     # 设为开机自动启动
#systemctl start ipsec       # 开启服务
#systemctl status ipsec
● ipsec.service - Internet Key Exchange (IKE) Protocol Daemon for IPsec
   Loaded: loaded (/usr/lib/systemd/system/ipsec.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-10-25 17:28:56 CST; 3 days ago
     Docs: man:ipsec(8)
           man:pluto(8)
           man:ipsec.conf(5)
 Main PID: 8831 (pluto)
   Status: "Startup completed."
   CGroup: /system.slice/ipsec.service
           └─8831 /usr/libexec/ipsec/pluto --leak-detective --config /etc/ipsec.conf --nofork

15、检查ipsec状态

#ipsec verify     

Verifying installed system and configuration files

Version check and ipsec on-path                         [OK]
Libreswan 3.25 (netkey) on 3.10.0-862.2.3.el7.x86_64
Checking for IPsec support in kernel                    [OK]
 NETKEY: Testing XFRM related proc values
         ICMP default/send_redirects                    [OK]
         ICMP default/accept_redirects                  [OK]
         XFRM larval drop                               [OK]
Pluto ipsec.conf syntax                                 [OK]
Two or more interfaces found, checking IP forwarding    [OK]
Checking rp_filter                                      [OK]
Checking that pluto is running                          [OK]
 Pluto listening for IKE on udp 500                     [OK]
 Pluto listening for IKE/NAT-T on udp 4500              [OK]
 Pluto ipsec.secret syntax                              [OK]
Checking 'ip' command                                   [OK]
Checking 'iptables' command                             [OK]
Checking 'prelink' command does not interfere with FIPS [OK]
Checking for obsolete ipsec.conf options                [OK]

16、启动xl2tp

#systemctl enable xl2tpd     #设置自启动
#systemctl start xl2tpd      #启动xl2tp
目录
相关文章
|
3月前
|
Linux
CentOS7.9服务器一键脚本部署FRP内网穿透服务端与客户端
CentOS7.9服务器一键脚本部署FRP内网穿透服务端与客户端
210 0
|
4月前
|
人工智能 JavaScript Linux
Nuxt.js在centos7上的发布部署
Nuxt.js在centos7上的发布部署
Nuxt.js在centos7上的发布部署
|
2月前
|
JavaScript Java 应用服务中间件
centos部署vue项目(java,tomcat环境的搭建)
centos部署vue项目(java,tomcat环境的搭建)
39 0
|
3月前
|
监控 安全 Linux
CentOS7下部署ARL资产侦察灯塔系统
CentOS7下部署ARL资产侦察灯塔系统
155 3
|
1月前
|
分布式计算 关系型数据库 MySQL
Sqoop【部署 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
【2月更文挑战第8天】Sqoop CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
93 1
|
2月前
|
存储 NoSQL Linux
centos7部署redis以及多实例
centos7部署redis以及多实例
54 0
|
3天前
|
JavaScript Linux 数据安全/隐私保护
如何在CentOS7部署Wiki.js知识库并实现分享好友公网远程使用【内网穿透】
如何在CentOS7部署Wiki.js知识库并实现分享好友公网远程使用【内网穿透】
|
20天前
|
Linux Shell 开发工具
CentOS8中Docker安装及部署
CentOS8中Docker安装及部署
67 0
|
1月前
|
存储 监控 Linux
Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
【2月更文挑战第17天】Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
27 1
Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
|
2月前
|
关系型数据库 MySQL Linux
Azkaban【部署 02】CentOS release 7.5安装配置azkaban-3.70.0安装阶段(含已编译的10个安装文件:可直接进行安装)
【2月更文挑战第5天】CentOS release 7.5安装配置azkaban-3.70.0安装阶段(含已编译的10个安装文件:可直接进行安装)
48 7

热门文章

最新文章