Linux IPSec操作手册
集成于Linux操作系统的IPSec实现

集成于Linux操作系统的IPSec实现
郭井龙;高翔
【期刊名称】《电子设计应用》
【年(卷),期】2003(000)012
【摘要】本文分析了Linux内核2.5.74中IPSec协议对数据的处理过程,包括数据被IPSec接管、处理的过程,以及IPSec对报文的发送、接收和转发过程,并通过对该过程的分析给出了其实现的总体思想和框架.
【总页数】3页(P57-59)
【作者】郭井龙;高翔
【作者单位】信息工程大学信息工程学院;信息工程大学信息工程学院
【正文语种】中文
【中图分类】TN91
【相关文献】
1.浅析GRE over IPSEC与IPSEC over GRE实现方法 [J], 过林吉
2.IPSec和L2TP集成的多安全连接技术研究及实现 [J], 李慧;李涛
3.基于IPv6嵌入式Linux操作系统IPSec协议的研究与设计 [J], 陈晓丹;苏利敏;薛永毅
4.在Windows 7、Windows Server 2008和Windows Vista中和用IPsec实现服务器隔离——连接安全规则首次集成到IPsec和防火墙功能中 [J], 肖欣(译)
5.吏用IPsec实现域隔离通过推送IPsec策略实现网络的安全划分 [J], Russell Smith; 黄思维(译者)
因版权原因,仅展示原文概要,查看原文内容请购买。
linux命令操作手册

linux命令操作手册一、文件操作1.1 创建文件:使用touch命令可以创建一个空文件,语法为“touch 文件名”。
1.2 编辑文件:使用文本编辑器(如vi、nano等)可以编辑文件,语法为“编辑器文件名”。
1.3 复制文件:使用cp命令可以复制文件,语法为“cp 源文件目标文件”。
1.4 移动文件:使用mv命令可以移动文件,语法为“mv 源文件目标目录”。
1.5 删除文件:使用rm命令可以删除文件,语法为“rm 文件名”。
二、目录操作2.1 创建目录:使用mkdir命令可以创建目录,语法为“mkdir 目录名”。
2.2 删除目录:使用rmdir命令可以删除目录,语法为“rmdir 目录名”。
2.3 移动目录:使用mv命令可以移动目录,语法为“mv 目录名目标目录”。
2.4 复制目录:使用cp命令可以复制目录,语法为“cp -r 源目录目标目录”。
三、文本操作3.1 查看文件内容:使用cat命令可以查看文件内容,语法为“cat 文件名”。
3.2 编辑文件内容:使用文本编辑器(如vi、nano等)可以编辑文件内容。
3.3 查找文本:使用grep命令可以查找文本,语法为“grep '查找内容' 文件名”。
3.4 替换文本:使用sed命令可以替换文本,语法为“sed 's/查找内容/替换内容/g' 文件名”。
四、压缩与解压4.1 压缩文件:使用tar命令可以压缩文件,语法为“tar -czvf 压缩文件名.tar.gz 源文件或目录名”。
4.2 解压文件:使用tar命令可以解压文件,语法为“tar -xzf 压缩文件名.tar.gz”。
五、文件查找5.1 查找文件:使用find命令可以查找文件,语法为“find 查找路径-name '文件名'”。
5.2 查找目录:使用find命令可以查找目录,语法为“find 查找路径-type d -name '目录名'”。
TransPort主模式IPsec IKEv1 VPN使用手册说明书

Quick Note 061Main Mode IPsec IKEv1 VPN from TransPort to StrongSwan using Preshared key22 August 20171Introduction (3)1.1Introduction (3)1.2Network Diagram (3)1.3Outline (4)1.4Assumptions (4)1.5Corrections (4)1.6Version (4)2TransPort Configuration (5)2.1Local Ethernet Interface Configuration (5)2.1WAN interface configuration (6)2.1Tunnel Configuration (7)2.1.1Phase 1 Settings (7)2.1.2Phase 2 settings (8)2.2Configure users (10)3StrongSwan Configuration (11)3.1Configure Ethernet Interfaces (11)3.1.1WAN Interface (11)3.1.2Local Interface (11)3.2Install StrongSwan (11)3.3Configure StrongSwan (13)3.3.1IPsec VPN Configuration (13)3.4Start/Restart the StrongSwan IPsec daemon (16)4Check Tunnel Status (17)4.1Digi TransPort (17)4.2StrongSwan (18)5Testing (19)5.1TransPort side (19)5.2StrongSwan side (19)6TransPort Configuration (20)1.1IntroductionThis document describes how to configure a VPN IPsec tunnel between a Digi TransPort WR to and a StrongSwan server using Main Mode, IKEv1 and pre-shared key authentication.1.2Network DiagramTransPort WR RouterStrongSwan1.3OutlineThis guide details the steps involved in configuring a Digi TransPort router to act as an IPsec VPN client to a StrongSwan appliance configured as an IPsec VPN server using Main Mode, IKEv1 and pre-shared key authentication. This example as sumes that both equipment’s are not behind a NAT box.1.4AssumptionsThis guide has been written for use by technically competent personnel with a good understanding of the communications technologies used in the product and of the requirements for their specific application. It also assumes a basic ability to access and navigate a Digi TransPort router and configure it with basic routing functionsThis application note applies to:Model: Digi TransPort WR11/21/31/41/44Firmware versions:WR21: 5.2.17.10 and laterConfiguration: This document assumes that the devices are set to their factory default configurations. Most configuration commands are shown only if they differ from the factory default. Please note: This application note has been specifically rewritten for the specified firmware versions and later but will work on earlier versions of firmware. Please contact ********************* if your require assistance in upgrading the firmware of the TransPort WR routers.1.5CorrectionsRequests for corrections or amendments to this application note are welcome and should be addressed to: ********************* Requests for new application notes can be sent to the same address.1.6Version2.1Local Ethernet Interface ConfigurationNavigate to Configuration – Network > Interfaces > Ethernet > Ethernet 02.1WAN interface configurationIn this example, the mobile interface will be used as the WAN interface on which the IPsec tunnel will be established.Navigate to:Configuration – Network > Interfaces > MobilePlease note: If required, enter a SIM PIN and Username/Password for this SIM card and APN.2.1Tunnel ConfigurationOpen a web browser to the IP address of the TransPort WR21 router. 2.1.1Phase 1 SettingsNavigate to:Configuration – Network > Virtual Private Network (VPN) >IKE > IKE 02.1.2Phase 2 settingsNavigate to:Configuration – Network > Virtual Private Network (VPN) > IPsec > IPsec 0 – 9 > IPsec 0Click Apply2.2Configure usersNavigate to Configuration - Security > Users > User 0-9 > User 9Here the pre-shared key is configured using the WAN IP address of the StrongSwan. The username value should therefore match the Peer ID set in the IPsec configuration above:3.1Configure Ethernet Interfaces3.1.1WAN InterfaceConfigure the WAN interface for the StrongSwan Server. In this example, the Ethernet interface used for WAN is called ens33root@ubuntu:/home/digi# ifconfig ens33 192.168.1.118root@ubuntu:/home/digi# ifconfig ens33 netmask 255.255.255.0root@ubuntu:/home/digi# route add default gw 192.168.1.254 ens333.1.2Local InterfaceConfigure the Local interface for the StrongSwan Server. In this example, the Ethernet interface used for LAN is called enx00249b09ef56root@ubuntu:/home/digi# ifconfig enx00249b09ef56 100.10.10.2root@ubuntu:/home/digi# ifconfig enx00249b09ef56 netmask 255.255.255.03.2Install StrongSwanDepending on the Linux distribution, the installation of StrongSwan might defer. In this document, Ubuntu is used. Please refer to for further installation instructions. The easiest way t o install StrongSwan is via the “apt-get install strongswan” CLI command:digi@ubuntu:~$ sudo apt-get install strongswanReading package lists... DoneBuilding dependency treeReading state information... DoneThe following additional packages will be installed:libstrongswan libstrongswan-standard-plugins strongswan-charonstrongswan-libcharon strongswan-starterSuggested packages:libstrongswan-extra-plugins libcharon-extra-pluginsThe following NEW packages will be installed:libstrongswan libstrongswan-standard-plugins strongswan strongswan-charon strongswan-libcharon strongswan-starter0 upgraded, 6 newly installed, 0 to remove and 59 not upgraded.Need to get 3,731 kB of archives.After this operation, 16.1 MB of additional disk space will be used.Do you want to continue? [Y/n] yGet:1 /ubuntu xenial-updates/main amd64 libstrongswan amd64 5.3.5-1ubuntu3.4 [1,398 kB]Get:2 /ubuntu xenial-updates/main amd64 strongswan-libcharon amd64 5.3.5-1ubuntu3.4 [1,241 kB]Get:3 /ubuntu xenial-updates/main amd64 strongswan-starter amd64 5.3.5-1ubuntu3.4 [742 kB]Get:4 /ubuntu xenial-updates/main amd64 strongswan-charon amd64 5.3.5-1ubuntu3.4 [55.6 kB]Get:5 /ubuntu xenial-updates/main amd64libstrongswan-standard-plugins amd64 5.3.5-1ubuntu3.4 [267 kB]Get:6 /ubuntu xenial-updates/main amd64strongswan all 5.3.5-1ubuntu3.4 [27.1 kB]Fetched 3,731 kB in 12s (307 kB/s) Preconfiguring packages ...Selecting previously unselected package libstrongswan.(Reading database ... 175214 files and directories currently installed.) Preparing to unpack .../libstrongswan_5.3.5-1ubuntu3.4_amd64.deb ...Unpacking libstrongswan (5.3.5-1ubuntu3.4) ...Selecting previously unselected package strongswan-libcharon.Preparing to unpack .../strongswan-libcharon_5.3.5-1ubuntu3.4_amd64.deb ... Unpacking strongswan-libcharon (5.3.5-1ubuntu3.4) ...Selecting previously unselected package strongswan-starter.Preparing to unpack .../strongswan-starter_5.3.5-1ubuntu3.4_amd64.deb ... Unpacking strongswan-starter (5.3.5-1ubuntu3.4) ...Selecting previously unselected package strongswan-charon.Preparing to unpack .../strongswan-charon_5.3.5-1ubuntu3.4_amd64.deb ... Unpacking strongswan-charon (5.3.5-1ubuntu3.4) ...Selecting previously unselected package libstrongswan-standard-plugins. Preparing to unpack .../libstrongswan-standard-plugins_5.3.5-1ubuntu3.4_amd64.deb ...Unpacking libstrongswan-standard-plugins (5.3.5-1ubuntu3.4) ...Selecting previously unselected package strongswan.Preparing to unpack .../strongswan_5.3.5-1ubuntu3.4_all.deb ...Unpacking strongswan (5.3.5-1ubuntu3.4) ...Processing triggers for man-db (2.7.5-1) ...Setting up libstrongswan (5.3.5-1ubuntu3.4) ...Setting up strongswan-libcharon (5.3.5-1ubuntu3.4) ...Setting up strongswan-starter (5.3.5-1ubuntu3.4) ...Setting up strongswan-charon (5.3.5-1ubuntu3.4) ...Setting up libstrongswan-standard-plugins (5.3.5-1ubuntu3.4) ...Setting up strongswan (5.3.5-1ubuntu3.4) ...Please note: All commands have to be used in elevated or super user mode. For ease of configuration, this document will use the root user (not recommended). In most case, using “sudo” in front of each commands will provide the expected result.3.3Configure StrongSwan3.3.1IPsec VPN ConfigurationThe IPsec configuration of StrongsWan is done via 2 main files (when using pre-shared keys as in this example):-ipsec.conf : Used for Phase 1 (IKE) and Phase 2 IPsec configuration-ipsec.secrets : Used for pre-shared keysIn this example, the following Phase 1 settings will be used:-AES (128 bit)-SHA 1-MODP Group 2-Main ModeIn this example, the following Phase 2 settings will be used:-AES (128 bit)-SHA 1-No PFS-ID Types : IPv4-Preshared Keys3.3.1.1ipsec.confEdit the ipsec.conf file using a text editor such as vi: config setupconn %defaultikelifetime=60mkeylife=20mrekeymargin=3mkeyingtries=%foreverkeyexchange=ikev1authby=secretconn peer1-peer2left=192.168.1.118leftsubnet=100.10.10.0/24leftfirewall=yesright=%anyrightallowany=yesrightsubnet=10.0.0.0/24auto=startcloseaction=restartike=aes128-sha1-modp1024esp=aes128-sha1type=tunnelkeyingtries=%forevertype :wq to save and close3.3.1.2ipsec.secretsEdit the ipsec.secrets file using a text editor such as vi:192.168.1.118 : PSK "digidigi"192.168.1.23 : PSK "digidigi"type :wq to save and close3.4Start/Restart the StrongSwan IPsec daemonOnce the files are modified, the changes will only take effect after reloading the StrongSwan daemon. To do so, issue the following command:root@ubuntu:/home/digi# ipsec restartStopping strongSwan IPsec...Starting strongSwan 5.3.5 IPsec [starter]...4.1Digi TransPortNavigate to Management – Connections > Virtual Private Networking (VPN) > IPsec > IPsec Tunnels > IPsec Tunnels 0 – 9 > IPsec Tunnels 0-9Via CLI:sastatCommand: sastatCommand resultIPsec SAs (total:1). Eroute 0 -> 49Outbound V1 SAsSPI Eroute Peer IP Rem. subnet Loc. subnet TTL KBytes Left VIPc3b444ae 0 192.168.1.118 100.10.10.0/24 10.0.0.0/24 28648 0 N/AInbound V1 SAsSPI Eroute Peer IP Rem. subnet Loc. subnet TTL KBytes Left VIP6eb46719 0 192.168.1.118 100.10.10.0/24 10.0.0.0/24 28648 0 N/AOutbound V2 SAsList EmptyInbound V2 SAsList EmptyOK4.2StrongSwanroot@ubuntu:/home/digi# ipsec statusallStatus of IKE charon daemon (strongSwan 5.3.5, Linux 4.10.0-28-generic,x86_64):uptime: 29 seconds, since Aug 22 06:25:17 2017malloc: sbrk 1486848, mmap 0, used 344640, free 1142208worker threads: 11 of 16 idle, 5/0/0/0 working, job queue: 0/0/0/0, scheduled: 3loaded plugins: charon test-vectors aes rc2 sha1 sha2 md4 md5 random nonce x509 revocation constraints pubkey pkcs1 pkcs7 pkcs8 pkcs12 pgp dnskey sshkey pem openssl fips-prf gmp agent xcbc hmac gcm attr kernel-netlink resolve socket-default connmark stroke updownListening IP addresses:192.168.1.118100.10.10.2Connections:peer1-peer2: 192.168.1.118...%any,0.0.0.0/0,::/0 IKEv1peer1-peer2: local: [192.168.1.118] uses pre-shared key authenticationpeer1-peer2: remote: uses pre-shared key authenticationpeer1-peer2: child: 100.10.10.0/24 === 10.0.0.0/24 TUNNELSecurity Associations (1 up, 0 connecting):peer1-peer2[1]: ESTABLISHED 22 seconds ago,192.168.1.118[192.168.1.118]...192.168.1.23[192.168.1.23]peer1-peer2[1]: IKEv1 SPIs: 6eb06982e84e8679_i 208d286522e19369_r*, pre-shared key reauthentication in 54 minutespeer1-peer2[1]: IKE proposal:AES_CBC_128/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024peer1-peer2{1}: INSTALLED, TUNNEL, reqid 1, ESP SPIs: cc5e3c54_i 6eb4671a_o peer1-peer2{1}: AES_CBC_128/HMAC_SHA1_96, 0 bytes_i, 0 bytes_o, rekeying in 15 minutespeer1-peer2{1}: 100.10.10.0/24 === 10.0.0.0/24To simply test the tunnel, generate a ping from each side of the tunnel and ping the remote end’s ethernet interface.5.1TransPort sideCommand: ping 100.10.10.2 –e0Command resultPinging Addr [100.10.10.2]sent PING # 1PING receipt # 1 : response time 0.00 secondsIface: PPP 1Ping StatisticsSent : 1Received : 1Success : 100 %Average RTT : 0.00 secondsOK5.2StrongSwan sideroot@ubuntu:/home/digi# ping 10.0.0.1PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.64 bytes from 10.0.0.1: icmp_seq=1 ttl=250 time=2.30 ms64 bytes from 10.0.0.1: icmp_seq=2 ttl=250 time=1.30 ms64 bytes from 10.0.0.1: icmp_seq=3 ttl=250 time=1.56 ms64 bytes from 10.0.0.1: icmp_seq=4 ttl=250 time=1.28 ms64 bytes from 10.0.0.1: icmp_seq=5 ttl=250 time=1.35 ms64 bytes from 10.0.0.1: icmp_seq=6 ttl=250 time=1.38 ms^C--- 10.0.0.1 ping statistics ---6 packets transmitted, 6 received, 0% packet loss, time 5010msrtt min/avg/max/mdev = 1.287/1.532/2.304/0.358 mseth 0 IPaddr "10.0.0.1"addp 0 enable ONlapb 0 ans OFFlapb 0 tinact 120lapb 1 tinact 120lapb 3 dtemode 0lapb 4 dtemode 0lapb 5 dtemode 0lapb 6 dtemode 0ip 0 cidr ONdef_route 0 ll_ent "ppp"def_route 0 ll_add 1eroute 0 descr "StrongSwan"eroute 0 peerip "192.168.1.118" eroute 0 peerid "192.168.1.118" eroute 0 ourid "192.168.1.23" eroute 0 ouridtype 3eroute 0 locip "10.0.0.0"eroute 0 locmsk "255.255.255.0" eroute 0 locipifadd 1eroute 0 remip "100.10.10.0" eroute 0 remmsk "255.255.255.0" eroute 0 ESPauth "SHA1"eroute 0 ESPenc "AES"eroute 0 authmeth "PRESHARED" eroute 0 nosa "TRY"eroute 0 autosa 2eroute 0 enckeybits 128dhcp 0 respdelms 500dhcp 0 mask "255.255.255.0"dhcp 0 gateway "192.168.1.1"dhcp 0 DNS "192.168.1.1"sntp 0 server "" ppp 0 timeout 300ppp 1 name "W-WAN"ppp 1 phonenum "*98*1#"ppp 1 username "username"ppp 1 epassword "KD5lSVJDVVg=" ppp 1 IPaddr "0.0.0.0"ppp 1 timeout 0ppp 1 do_nat 2ppp 1 ipsec 1ppp 1 use_modem 1ppp 1 aodion 1ppp 1 autoassert 1ppp 1 r_chap OFFppp 3 defpak 16ppp 4 defpak 16web 0 prelogin_info ONike 0 encalg "AES"ike 0 keybits 128ike 0 authalg "SHA1"ike 0 ikegroup 2ike 0 noresp ONike 0 deblevel 4ike 0 debug ONana 0 anon ONana 0 l2on OFFana 0 l3on OFFana 0 xoton OFFana 0 lapdon 0ana 0 lapbon 0ana 0 ikeon ONana 0 logsize 45cmd 0 unitid "ss%s>"cmd 0 cmdnua "99"cmd 0 hostname "digi.router"cmd 0 asyled_mode 2cmd 0 tremto 1200cmd 0 rcihttp ONuser 0 access 0user 1 name "username"user 1 epassword "KD5lSVJDVVg="user 1 access 0user 2 access 0user 3 access 0user 4 access 0user 5 access 0user 6 access 0user 7 access 0user 8 access 0user 9 name "192.168.1.118"user 9 epassword "PDZxU0FFQFU="user 9 access 4local 0 transaccess 2sslsvr 0 certfile "cert01.pem"sslsvr 0 keyfile "privrsa.pem"ssh 0 hostkey1 "privSSH.pem"ssh 0 nb_listen 5ssh 0 v1 OFFcloud 0 clientconn ONcloud 0 ssl ONOKPage | 21。
Linux IPSec操作手册

Linux IPSec操作手册IPSec操作手册第一部分: OpenSSL生成证书首先需要一个根证书,然后用这个根证书来下发“子证书”。
1,找一台Linux PC, 首先切换目录,到 /etc/pki/tls/misc,openssl的脚本在这里。
2,生成根证书: ./CA -newca输入pass phrase,后面签发的时候会用到,类似一个密码 CA证书的路径在/etc/pki/CA/cacert.pem3,生成server私有密钥:openssl genrsa -out server.key 20484,生成服务器证书请求:openssl req -new -key server.key -out server.csr5,把server.crt文件改名成newreq.pem,然后用CA来签证就可以了 mv server.csr newreq.pem ./CA �Csign6,把newcert.pem改名成server.pem mv newcert.pem server.pem 这就是server的证书。
7,重复3-6步,生成client的证书和私钥。
8,将 server.key 和 server.pem 和 cacert.pem复制到FC1080,其中server.key 和server.pem import到Local Certificates中,cacert.pem import到Trusted CA 中(只需导入证书部分,描述部分不用导入)在Linux PC上,新建/var/cert 目录,将client.pem, client.key, cacert.pem复制到 /var/cert/目录下。
9,在Linux PC的 /var/cert/目录下执行下列命令:ln -s cacert.pem $(openssl x509 -noout -hash -in cacert.pem).0这个命令是生成一个hash link,如果没有此hash link,后面将无法建立IPSec通道至此两台主机的证书分发工作已经完成。
Centos7 搭建IPSEC上的L2TP服务器

2
ipsec
l2tp
[root@]#cd /etc/ipsec.d/ [root@]#vi l2tp_psk.conf conn L2TP-PSK-NAT rightsubnet=vhost:%priv also=L2TP-PSK-noNAT conn L2TP-PSK-noNAT authby=secret pfs=no auto=add keyingtries=3 dpddelay=30 dpdtimeout=120 dpdaction=clear rekey=no ikelifetime=8h
[OK]
[OK]
[OK] [OK] [OK] [OK] [N/A] [OK] [OK] [OK] [OK] [OK] [OK]
nat_traversal=yes 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 # For example connections, see your distribution's documentation directory, # or https:///wiki/ # # There is also a lot of information in the manual page, "man ipsec.conf" # # It is best to add your IPsec connections as separate files in /etc/ipsec. d/ include /etc/ipsec.d/*.conf
IPSec使用方法:配置和启用IPSec的步骤详解(三)

IPSec使用方法:配置和启用IPSec的步骤详解IPSec(Internet Protocol Security)是一种常用的网络安全协议,用于保护网络通信的安全性和完整性。
通过对数据进行加密和认证,IPSec确保了数据在网络传输过程中的保密性和防篡改能力。
本文将详细介绍IPSec的配置和启用步骤,帮助读者了解如何使用IPSec 来保护网络通信的安全。
一、IPSec的概述IPSec协议是在网络层实现的安全协议,它通过对IP数据包进行加密和认证,确保数据在传输过程中的安全性。
IPSec使用了多种加密和认证算法,如DES、3DES、AES等,同时还支持两种模式:传输模式和隧道模式。
传输模式适用于通信双方在同一网络中,而隧道模式则适用于需要跨越不同网络的通信。
二、IPSec的配置步骤以下是IPSec的配置步骤:1. 确定加密和认证算法:首先,需要确定使用哪种加密和认证算法来保护通信。
常用的算法有DES、3DES和AES,认证算法可以选择MD5或SHA。
2. 配置密钥管理:IPSec需要使用密钥来进行加密和认证,因此需要配置密钥管理。
可以选择手动配置密钥,也可以使用自动密钥交换协议(IKE)来自动分发密钥。
3. 配置安全策略:安全策略定义了哪些流量需要被保护,以及如何进行保护。
可以根据需要定义多个安全策略,每个策略可以有不同的加密和认证算法。
4. 配置IPSec隧道:如果需要跨越不同网络的通信,需要配置IPSec隧道。
隧道配置包括隧道模式、本地和远程网关地址,以及相应的加密和认证算法。
5. 启用IPSec:完成配置后,需要启用IPSec来保护通信。
启用IPSec的方式可以是在路由器或网络防火墙上配置相应的规则,也可以在主机上使用IPSec客户端软件。
三、IPSec的启用步骤以下是IPSec的启用步骤:1. 检查设备支持:首先,需要检查网络设备是否支持IPSec。
大多数现代路由器、防火墙和操作系统都已经支持IPSec,但仍需确保设备支持。
centos ipsec 参数

centos ipsec 参数CentOS IPsec 参数IPsec是一种网络协议,用于在互联网上提供安全的数据传输。
CentOS是一种常用的Linux操作系统,支持IPsec协议。
本文将介绍CentOS上IPsec的参数设置。
1. IPsec简介IPsec是Internet Protocol Security的缩写,是一种用于保护网络通信安全的协议。
它通过对通信数据进行加密和认证来防止数据在传输过程中被窃听、篡改或伪造。
2. 安装IPsec在CentOS上安装IPsec,可以使用以下命令:```sudo yum install -y libreswan```这将安装libreswan软件包,它是一个开源的IPsec实现。
3. IPsec参数配置IPsec的参数配置文件位于/etc/ipsec.d/目录下。
可以使用文本编辑器打开该目录下的ipsec.conf文件进行配置。
3.1 配置连接在ipsec.conf文件中,可以配置多个连接。
每个连接的配置以conn开头,后面跟着连接的名称。
例如:```conn myvpn```可以使用不同的名称来区分不同的连接。
3.2 配置本地和远程地址在连接配置中,需要指定本地和远程的IP地址。
例如:```left=192.168.1.100right=203.0.113.10```其中left表示本地地址,right表示远程地址。
3.3 配置加密算法IPsec支持多种加密算法。
可以在连接配置中指定加密算法。
例如:```ike=aes256-sha256-modp2048esp=aes256-sha256```其中ike表示IKE阶段的加密算法,esp表示ESP阶段的加密算法。
3.4 配置预共享密钥预共享密钥用于进行身份验证和密钥交换。
可以在连接配置中指定预共享密钥。
例如:```authby=secret```然后在/etc/ipsec.d/目录下创建一个名为ipsec.secrets的文件,其中包含预共享密钥的配置。
Linux系统的虚拟私有网络(VPN)配置指南

Linux系统的虚拟私有网络(VPN)配置指南虚拟私有网络(Virtual Private Network,简称VPN)是一种在公共网络上建立安全连接的技术,它可以在不安全的网络中创建一个安全的通信通道,用于保护数据传输的安全性和隐私。
在Linux系统中配置VPN可以实现远程访问、跨网络访问等功能。
本文将介绍Linux系统中配置VPN的步骤和方法。
1. 选择合适的VPN协议VPN协议有多种选择,常见的有OpenVPN、PPTP、L2TP等。
在选择协议时需考虑网络环境和安全性需求。
本文以OpenVPN为例进行配置。
2. 安装和配置VPN服务器a. 在Linux系统上安装OpenVPN软件:打开终端,输入以下命令安装OpenVPN软件。
```$ sudo apt-get update$ sudo apt-get install openvpn```b. 配置OpenVPN服务器:创建一个新的配置文件,例如“server.conf”。
```$ sudo nano /etc/openvpn/server.conf```c. 在配置文件中添加以下内容:```port 1194 # VPN服务器监听端口号proto udp # 使用UDP协议dev tun # 使用虚拟隧道设备ca /etc/openvpn/ca.crt # VPN服务器的CA证书cert /etc/openvpn/server.crt # VPN服务器的证书key /etc/openvpn/server.key # VPN服务器的私钥dh /etc/openvpn/dh2048.pem # Diffie-Hellman密钥交换server 10.8.0.0 255.255.255.0 # VPN虚拟IP地址段ifconfig-pool-persist ipp.txt # IP地址保存文件路径push "redirect-gateway def1 bypass-dhcp" # 所有客户端的网络流量通过VPNpush "dhcp-option DNS 8.8.8.8" # DNS解析使用Google Public DNS push "dhcp-option DNS 8.8.4.4"keepalive 10 120 # 心跳包设置comp-lzo # 数据压缩user nobody # 以nobody用户运行group nogroup # 以nogroup组运行persist-key # 保存密钥persist-tun # 保存虚拟隧道status openvpn-status.log # 日志文件路径verb 3 # 日志输出级别```d. 保存并退出配置文件。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
IPSec操作手册
第一部分: OpenSSL生成证书
首先需要一个根证书,然后用这个根证书来下发“子证书”。
1,找一台Linux PC, 首先切换目录,到/etc/pki/tls/misc,openssl的脚本在这里。
2,生成根证书:
./CA -newca
输入pass phrase,后面签发的时候会用到,类似一个密码
CA证书的路径在/etc/pki/CA/cacert.pem
3,生成server私有密钥:
openssl genrsa -out server.key 2048
4,生成服务器证书请求:
openssl req -new -key server.key -out server.csr
5,把server.crt文件改名成newreq.pem,然后用CA来签证就可以了
mv server.csr newreq.pem
./CA –sign
6,把newcert.pem改名成server.pem
mv newcert.pem server.pem
这就是server的证书。
7,重复3-6步,生成client的证书和私钥。
8,将server.key 和server.pem 和cacert.pem复制到FC1080,其中server.key和server.pem import到Local Certificates中,cacert.pem import到Trusted CA 中(只需导入证书部分,描述部分不用导入)
在Linux PC上,新建/var/cert 目录,将client.pem, client.key, cacert.pem复制到
/var/cert/目录下。
9,在Linux PC的/var/cert/目录下执行下列命令:
ln -s cacert.pem $(openssl x509 -noout -hash -in cacert.pem).0
这个命令是生成一个hash link,如果没有此hash link,后面将无法建立IPSec通道
至此两台主机的证书分发工作已经完成。
下面开始配置setkey和racoon的工作。
第二部分:配置racoon.conf和setkey.conf.
PC1的setkey.conf
flush;
spdflush;
spdadd 172.16.12.164/32 172.16.12.169/32 any -P out ipsec esp/transport/172.16.12.164-172.16.12.169/require;
spdadd 172.16.12.169/32 172.16.12.164/32 any -P in ipsec esp/transport/172.16.12.169-172.16.12.164/require;
PC1的racoon.conf
path pre_shared_key "/var/psk.txt";
path certificate "/var/cert";
remote 172.16.12.169 {
exchange_mode main;
lifetime time 3600 sec;
proposal_check obey;
verify_cert on;
my_identifier asn1dn;
peers_identifier asn1dn;
certificate_type x509 "server.cert" "server.priv";
proposal {
encryption_algorithm 3des;
hash_algorithm md5;
authentication_method rsasig;
dh_group modp1024;
}
}
sainfo address 172.16.12.164/32 any address 172.16.12.169/32 any {
lifetime time 3600 sec;
encryption_algorithm 3des;
authentication_algorithm hmac_md5;
compression_algorithm deflate;
}
PC2的setkey.conf
flush;
spdflush;
spdadd 172.16.12.169/32 172.16.12.164/32 any -P out ipsec esp/transport/172.16.12.169-172.16.12.164/require;
spdadd 172.16.12.164/32 172.16.12.169/32 any -P in ipsec esp/transport/172.16.12.164-172.16.12.169/require;
PC2的racoon.conf
path pre_shared_key "/var/psk.txt";
path certificate "/var/cert";
remote 172.16.12.169 {
exchange_mode main;
lifetime time 3600 sec;
proposal_check obey;
verify_cert on;
my_identifier asn1dn;
peers_identifier asn1dn;
certificate_type x509 "client.pem" "client.key";
proposal {
encryption_algorithm 3des;
hash_algorithm md5;
authentication_method rsasig;
dh_group modp1024;
}
}
sainfo address 172.16.12.164/32 any address 172.16.12.169/32 any {
lifetime time 3600 sec;
encryption_algorithm 3des;
authentication_algorithm hmac_md5;
compression_algorithm deflate;
}
第三部分:防火墙规则,这里指的是tunnel方式需要的防火墙规则(上面两部分是点对点方式的配置),其中tunnel的local subnet为192.168.1.0/24, remote subnet为192.168.2.0/24 iptables –I INPUT -p esp -j ACCEPT #接受ESP包
iptables –I INPUT -p udp --dport 500 -j ACCEPT #接受racoon的listening port进包
iptables –I INPUT -p udp --dport 4500 -j ACCEPT #接受racoon的listening port进包iptables -t nat -I POSTROUTING -s 192.168.1.0/24 -d 192.168.2.0/24 -j ACCEPT #进入tunnel的数据不进行NAT转换
iptables –I FORWARD -s 192.168.2.0/24 -d 192.168.1.0/24 -j ACCEPT #tunnel中的回包需要ACCEPT
FAQ
1. 17 (modp6144), or 18 (modp8192) 会失败的原因
Timing is Everything
ISAKMP errors like "phase2 negotiation failed due to time up waiting for phase1" or "phase1 negotiation failed due to time up" could be caused by long cipher initialization times, especially on older hardware.
2. pre-shared-key 会失败的原因
很大可能是key文件的权限不是600造成的。
可以用racoon –F –f raccoon.conf前台运行看看原因
3.其他会失败的原因
注意设备的当前时间,如果时间不对,很可能会导致证书失效。