`
haoningabc
  • 浏览: 1465954 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

aws搭建xl2tp给iphone使用

阅读更多
2019年12月26日

可以参考原来的配置
https://haoningabc.iteye.com/blog/2147783

有点太乱了,重新整理,客户端的配置可以参考上面的

aws申请免费vm搭建自己的呵呵哒
最后有个关键操作
iptables -t nat -A POSTROUTING -s 172.31.39.0/24  -o eth0  -j MASQUERADE

如果自己vm的内网ip是172.31.39.123



在aws的redhat7.6上


参考
#######https://blog.csdn.net/kitvv/article/details/50696585

https://www.linuxprobe.com/centos7-install-l2tp.html






yum install -y epel-release 通不过
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install epel-release-latest-7.noarch.rpm


yum install -y xl2tpd libreswan lsof 




cat  /etc/xl2tpd/xl2tpd.conf
[global]
; listen-addr = 192.168.1.98
;
; requires openswan-2.5.18 or higher - Also does not yet work in combination
; with kernel mode l2tp as present in linux 2.6.23+
; ipsec saref = yes
; Use refinfo of 22 if using an SAref kernel patch based on openswan 2.6.35 or
;  when using any of the SAref kernel patches for kernels up to 2.6.35.
; saref refinfo = 30
;
; force userspace = yes
;
; debug tunnel = yes

[lns default]
ip range = 172.100.1.100-172.100.1.150
local ip = 172.100.1.1
require chap = yes
refuse pap = yes
require authentication = yes
name = LinuxVPNserver
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes





cat  /etc/ppp/options.xl2tpd
ipcp-accept-local
ipcp-accept-remote
ms-dns  8.8.8.8
#ms-dns  172.31.0.2
# ms-dns  192.168.1.1
# ms-dns  192.168.1.3
# ms-wins 192.168.1.2
# ms-wins 192.168.1.4
name xl2tpd
#noccp
auth
#crtscts
idle 1800
mtu 1410
mru 1410
nodefaultroute
debug
#lock
proxyarp
connect-delay 5000

refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
persist
logfile /var/log/xl2tpd.log


crtscts 和lock 在启动的时候报错所以去掉了
加了
name xl2tpd
#noccp

#比原来默认的配置多了这几项
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
persist
logfile /var/log/xl2tpd.log

查看log开始如果这里没有,可以先去看/var/log/messages

cat /etc/ipsec.conf
config setup
	# Normally, pluto logs via syslog.
	#logfile=/var/log/pluto.log
	#
	# Do not enable debug options to debug configuration issues!
	#
	# plutodebug="control parsing"
	# plutodebug="all crypt"
    protostack=netkey
    dumpdir=/var/run/pluto/
#	plutodebug=none
	#
	# NAT-TRAVERSAL support
	# exclude networks used on server side by adding %v4:!a.b.c.0/24
	# It seems that T-Mobile in the US and Rogers/Fido in Canada are
	# using 25/8 as "private" address space on their wireless networks.
	# This range has never been announced via BGP (at least up to 2015)
#	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
    virtual_private=%v4:10.0.0.0/8,%v4:172.100.0.0/12,%v4:25.0.0.0/8,%v4:100.64.0.0/10,%v6:fd00::/8,%v6:fe80::/10


注释掉了# plutodebug=none
加了
    protostack=netkey
    dumpdir=/var/run/pluto/

virtual_private 里面的172.100.0.0

对应
/etc/xl2tpd/xl2tpd.conf 中的ip range



cat /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=172.31.39.212
    leftprotoport=17/1701
    right=%any
    rightprotoport=17/%any


left 为:
#service/VPS的外网地址,某些vps只有eth0一块网卡的,
                        #就填内网地址,内核开启nat转发就可以了,
                        #CentOS7以下的用iptables定义转发规则





[root@aws ~]# cat  /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client	server	secret			IP addresses
root * haha *



[root@aws ~]# cat /etc/ipsec.d/default.secrets
: PSK "testvpn"


[root@aws ~]# cat /etc/sysctl.d/60-sysctl_ipsec.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
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.eth1.accept_redirects = 0
net.ipv4.conf.eth1.rp_filter = 0
net.ipv4.conf.eth1.send_redirects = 0
net.ipv4.conf.eth2.accept_redirects = 0
net.ipv4.conf.eth2.rp_filter = 0
net.ipv4.conf.eth2.send_redirects = 0
net.ipv4.conf.ip_vti0.accept_redirects = 0
net.ipv4.conf.ip_vti0.rp_filter = 0
net.ipv4.conf.ip_vti0.send_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.conf.lo.rp_filter = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.ppp0.accept_redirects = 0
net.ipv4.conf.ppp0.rp_filter = 0
net.ipv4.conf.ppp0.send_redirects = 0



重启网络
systemctl restart network

安装配置防火墙

yum install firewalld
systemctl enable  firewalld
systemctl status  firewalld

firewall-cmd --permanent --add-service=ipsec
firewall-cmd --permanent --add-port=1701/udp
firewall-cmd --permanent --add-port=4500/udp
firewall-cmd --permanent --add-masquerade
firewall-cmd --reload



systemctl enable ipsec
systemctl enable xl2tpd


systemctl restart ipsec
systemctl restart xl2tpd


最后不要忘了那个 最开始的iptables


iptables -t nat -A POSTROUTING -s 172.31.39.0/24  -o eth0  -j MASQUERADE











分享到:
评论

相关推荐

    DUG 基于 AWS 搭建全球化高可用的广告系统及生态.pdf

    DUG公司基于亚马逊网络服务(AWS)搭建了一个全球化高可用的广告系统及其生态,这一做法在2018年上海技术峰会中被详细介绍。DUG公司,即Dotc United Group,通过高效利用AWS提供的服务,成功应对了大流量、高并发和...

    Amazon AWS 搭建及部署手册.docx

    Amazon AWS 搭建及部署手册.docx

    基于AWS搭建全球化的IT生态.pptx

    基于AWS搭建全球化的IT生态.pptx

    aws使用说明舸aws使用aws使用aws使用

    苍松吏用说明苍松吏用说明苍松吏用说明苍松吏用说明苍松吏用说明苍松吏用说明苍松吏用说明

    aws-iot-examples, 使用AWS物联网的例子( 物联网).zip

    aws-iot-examples, 使用AWS物联网的例子( 物联网) aws-iot-examples使用AWS物联网的例子( 物联网)mqttSample: 使用MQTT-over-WebSockets将web应用程序连接到AWS物联网的参考实现truckSimulator: 模拟因特网连接的...

    AWS CDA题库3 英文

    •能够使用 AWS 安全最佳实践编写代码(例如,代码中不使用私有密钥和访问密钥,而是使用 IAM 角色) •能够在 AWS 上编写、维护和调试代码模块 •熟练编写无服务器应用程序的代码 •了解在开发过程中使用容器的方法

    AWS虚拟机pem密钥的使用1

    在 linux 系统客户端若要登录 目标虚拟机,使用 xxx.pem 密钥对文件登录,使用以下命令:在 windows 上登录 linux 可用其他虚拟终端软件

    PPT中AWS图标

    在PPT演示文稿中使用AWS(Amazon Web Services)图标是一种有效的传达云技术概念和解决方案的方式。AWS作为全球领先的云计算服务平台,提供了丰富的服务,涵盖了计算、存储、数据库、分析、机器学习、安全等多个领域...

    AWS 官方PPT图标资源

    使用这套图标,您可以清晰地展示AWS云环境中的各种服务如何相互协作,构建出复杂的云架构。例如,你可以用EC2图标表示计算层,S3图标表示存储层,RDS图标代表数据库服务,通过Lambda图标展示无服务器计算,再结合VPC...

    小型IIS服务器(AWS.EXE) 本地快速搭建ASP服务器

    【标题】:“小型IIS服务器(AWS.EXE) 本地快速搭建ASP服务器” 【知识点详解】 在IT行业中,开发和测试Web应用程序时,通常需要一个Web服务器来运行和调试代码。IIS(Internet Information Services)是微软提供的...

    AWS官方文档:AWS入门

    通过这个“AWS入门”文档,用户将能够逐步了解AWS的基本架构和主要服务,掌握如何在云端搭建和管理项目,从而开启在AWS平台上的数字化之旅。学习这些内容不仅有助于个人技能提升,也是企业向云端迁移、实现业务扩展...

    Aws3.0正式版 一款简单的一键搭建服务器的小软件

    Aws3.0正式版。这是一款简单的一键搭建服务器的小软件。 Aws3.0正式版。这是一款简单的一键搭建服务器的小软件。Aws3.0正式版。这是一款简单的一键搭建服务器的小软件。Aws3.0正式版。这是一款简单的一键搭建服务器...

    AWS IAM与AWS组织集成使用教程.docx

    AWS IAM与AWS组织集成使用教程.docx

    Aws3.0正式版 这是一款简单的一键搭建服务器的小软件

    AWS3.0正式版是一款专为用户简化服务器搭建流程的小型软件,旨在提供一键式的解决方案。这款工具的主要目标用户可能是那些对云服务有一定需求但不熟悉复杂服务器配置过程的个人或小型企业。通过AWS3.0,用户可以快速...

    AWS Developer Associate 题库

    1. **AWS基础服务**:了解并能熟练使用AWS的核心服务,如EC2(弹性计算云)用于实例和计算,S3(简单存储服务)用于对象存储,RDS(关系数据库服务)用于托管数据库,以及DynamoDB(无服务器数据库)等。 2. **应用...

    在AWS中使用SAP

    5. 成本效益:通过AWS的按需付费模式,企业可以按照实际使用的计算资源付费,优化成本控制。 在信息安全方面,AWS强调的是安全可靠的云服务选择。AWS提供的安全服务包括物理安全、安全管理、人员安全、系统建设管理...

    learn-aws-lambda, 了解如何使用 AWS Lambda轻松创建无限可伸缩的Web服务.zip

    learn-aws-lambda, 了解如何使用 AWS Lambda轻松创建无限可伸缩的Web服务 知识库 了解在 LESS 时间和成本范围内使用 AWS Lambda创建可以扩展的微型服务比基于服务器的应用程序运行的成本高 。 电子邮件内容什么是 ...

    AWS 白皮书 — 产品.zip

    使用 AWS Config监控 Amazon ec2专用主机上的许可合规情况,pdf 使用 AWS WAF消除 OWASP定义的10大Web应用程序漏洞pdf 使用AWS 实施灾难恢复 使用AWS的备份和恢复方法pdf 使用 Amazon ElastiCache提高规模性能,pdf ...

    AWS基本使用01. AWS免费方案介绍

    [AWS][教學]_AWS基本使用#01._AWS免費方案介紹

Global site tag (gtag.js) - Google Analytics