searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

Centos7上使用strongswan搭建ipsec隧道

2024-11-14 09:41:54
13
0

机器

两台测试机器:
1)IP地址:192.168.1.44,内网地址:172.16.111.44
2)IP地址:192.168.1.55,内网地址:172.16.111.55

配置

安装strongswan

两台机器都需要:yum install -y strongswan

192.168.1.44的配置

/etc/strongswan/ipsec.conf 内容如下:

# ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup
# strictcrlpolicy=yes
# uniqueids = no

# Add connections here.

# Sample VPN connections

conn %default
authby=psk
auto=route
type=tunnel
compress=no
ikelifetime=86400s
lifetime=28800s
keyexchange=ikev1
ike=3des-sha1-modp768
esp=3des-md5

conn node-44
left=192.168.1.44
leftsubnet=172.16.111.0/24
leftid=@node-44
right=192.168.1.55
rightsubnet=172.16.111.0/24
rightid=@node-115
auto=start

/etc/strongswan/ipsec.secrets 内容如下:

# ipsec.secrets - strongSwan IPsec secrets file

@node-44 @node-115 : PSK "4TiF/Y0BMVP+vv1pIg6wcg=="

192.168.1.55的配置

/etc/strongswan/ipsec.conf 内容如下:

# ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup
	# strictcrlpolicy=yes
	# uniqueids = no

# Add connections here.

# Sample VPN connections

conn %default
     authby=psk
     auto=route
     type=tunnel
     compress=no
     ikelifetime=86400s
     lifetime=28800s
     keyexchange=ikev1
     ike=3des-sha1-modp768
     esp=3des-md5

conn node-44
     left=192.168.1.55
     leftsubnet=172.16.111.0/24
     leftid=@node-55
     right=192.168.1.44
     rightsubnet=172.16.111.0/24
     rightid=@node-44
     auto=start

/etc/strongswan/ipsec.secrets 内容如下

# ipsec.secrets - strongSwan IPsec secrets file
@node-55 @node-44 : PSK "4TiF/Y0BMVP+vv1pIg6wcg=="

查看状态

命令:strongswan statusall
如下:
image.png

192.168.1.55上 ping -c 1 172.16.111.44 即可以走ipsec隧道了。

0条评论
作者已关闭评论
rysf
5文章数
0粉丝数
rysf
5 文章 | 0 粉丝
原创

Centos7上使用strongswan搭建ipsec隧道

2024-11-14 09:41:54
13
0

机器

两台测试机器:
1)IP地址:192.168.1.44,内网地址:172.16.111.44
2)IP地址:192.168.1.55,内网地址:172.16.111.55

配置

安装strongswan

两台机器都需要:yum install -y strongswan

192.168.1.44的配置

/etc/strongswan/ipsec.conf 内容如下:

# ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup
# strictcrlpolicy=yes
# uniqueids = no

# Add connections here.

# Sample VPN connections

conn %default
authby=psk
auto=route
type=tunnel
compress=no
ikelifetime=86400s
lifetime=28800s
keyexchange=ikev1
ike=3des-sha1-modp768
esp=3des-md5

conn node-44
left=192.168.1.44
leftsubnet=172.16.111.0/24
leftid=@node-44
right=192.168.1.55
rightsubnet=172.16.111.0/24
rightid=@node-115
auto=start

/etc/strongswan/ipsec.secrets 内容如下:

# ipsec.secrets - strongSwan IPsec secrets file

@node-44 @node-115 : PSK "4TiF/Y0BMVP+vv1pIg6wcg=="

192.168.1.55的配置

/etc/strongswan/ipsec.conf 内容如下:

# ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup
	# strictcrlpolicy=yes
	# uniqueids = no

# Add connections here.

# Sample VPN connections

conn %default
     authby=psk
     auto=route
     type=tunnel
     compress=no
     ikelifetime=86400s
     lifetime=28800s
     keyexchange=ikev1
     ike=3des-sha1-modp768
     esp=3des-md5

conn node-44
     left=192.168.1.55
     leftsubnet=172.16.111.0/24
     leftid=@node-55
     right=192.168.1.44
     rightsubnet=172.16.111.0/24
     rightid=@node-44
     auto=start

/etc/strongswan/ipsec.secrets 内容如下

# ipsec.secrets - strongSwan IPsec secrets file
@node-55 @node-44 : PSK "4TiF/Y0BMVP+vv1pIg6wcg=="

查看状态

命令:strongswan statusall
如下:
image.png

192.168.1.55上 ping -c 1 172.16.111.44 即可以走ipsec隧道了。

文章来自个人专栏
文章 | 订阅
0条评论
作者已关闭评论
作者已关闭评论
0
0