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) 
AI 代码解读

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

#modprobe ppp-compress-18 && echo yes
AI 代码解读

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

#cat /dev/net/tun
AI 代码解读

4、安装epel源

#yum install epel-release -y
AI 代码解读

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

#yum install -y xl2tpd libreswan
AI 代码解读

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
AI 代码解读

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
AI 代码解读

8、配置置预共享密钥PSK

#vim /etc/ipsec.d/default.secrets
: PSK "123A?a456"
AI 代码解读

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
AI 代码解读

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
AI 代码解读

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

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

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                          #重新加载配置
AI 代码解读

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  #修改内核生效
AI 代码解读

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
AI 代码解读

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]
AI 代码解读

16、启动xl2tp

#systemctl enable xl2tpd     #设置自启动
#systemctl start xl2tpd      #启动xl2tp
AI 代码解读
目录
打赏
0
3
0
3
4
分享
相关文章
centos7系统安装部署zabbix5.0
【9月更文挑战第23天】在CentOS 7系统上部署Zabbix 5.0的步骤包括:安装MariaDB数据库及必要软件包,配置Zabbix仓库,设置数据库并导入Zabbix数据库架构,配置Zabbix服务器与前端参数,启动相关服务,并通过浏览器访问Web界面完成安装向导。
587 0
CentOS 7.6操作系统部署JDK实战案例
这篇文章介绍了在CentOS 7.6操作系统上通过多种方式部署JDK的详细步骤,包括使用yum安装openjdk、基于rpm包和二进制包安装Oracle JDK,并提供了配置环境变量的方法。
384 80
部署05-VMwareWorkstation中安装CentOS7 Linux操作系统, VMware部署CentOS系统第一步,下载Linux系统,/不要忘, CentOS -7-x86_64-DVD
部署05-VMwareWorkstation中安装CentOS7 Linux操作系统, VMware部署CentOS系统第一步,下载Linux系统,/不要忘, CentOS -7-x86_64-DVD
Centos7下图形化部署单点KFS同步工具并将Oracle增量同步到KES
Centos7下图形化部署单点KFS同步工具并将Oracle增量同步到KES
Centos7下图形化部署单点KFS同步工具并将Oracle增量同步到KES
CentOS 7.9二进制部署K8S 1.28.3+集群实战
本文详细介绍了在CentOS 7.9上通过二进制方式部署Kubernetes 1.28.3+集群的全过程,包括环境准备、组件安装、证书生成、高可用配置以及网络插件部署等关键步骤。
1175 4
CentOS 7.9二进制部署K8S 1.28.3+集群实战
虚拟机centos7.9一键部署docker
本文介绍了如何在 CentOS 7.9 虚拟机上安装 Docker 社区版 (Docker-ce-20.10.20)。通过使用阿里云镜像源,利用 `wget` 下载并配置 Docker-ce 的 YUM 仓库文件,然后通过 `yum` 命令完成安装。安装后,通过 `systemctl` 设置 Docker 开机自启并启动 Docker 服务。最后,使用 `docker version` 验证安装成功,并展示了客户端与服务器的版本信息。文中还提供了列出所有可用 Docker-ce 版本的命令。
474 0
虚拟机centos7.9一键部署docker
|
8月前
|
CentOS7部署阿里巴巴开源的pouch容器管理工具实战
关于如何在CentOS 7.6操作系统上安装和使用阿里巴巴开源的Pouch容器管理工具的实战教程。
184 2
百度飞桨(PaddlePaddle) - PP-OCRv3 文字检测识别系统 基于 Paddle Serving快速使用(服务化部署 - CentOS 7)
百度飞桨(PaddlePaddle) - PP-OCRv3 文字检测识别系统 基于 Paddle Serving快速使用(服务化部署 - CentOS 7)
238 1
百度飞桨(PaddlePaddle) - PP-OCRv3 文字检测识别系统 基于 Paddle Serving快速使用(服务化部署 - CentOS 7)
CentOS 7.6使用kubeadm部署k8s 1.17.2测试集群实战篇
该博客文章详细介绍了在CentOS 7.6操作系统上使用kubeadm工具部署kubernetes 1.17.2版本的测试集群的过程,包括主机环境准备、安装Docker、配置kubelet、初始化集群、添加节点、部署网络插件以及配置k8s node节点管理api server服务器。
233 0
CentOS 7.6使用kubeadm部署k8s 1.17.2测试集群实战篇