LoginSignup
18
14

More than 1 year has passed since last update.

IPsec環境構築手順

Last updated at Posted at 2018-06-07

最新版は以下に記載しています。
https://hana-shin.hatenablog.com/entry/2023/03/05/222401

#0 はじめに
仮想マシン4台を使って、IPsecの環境を構築してみます。
トンネルモードを使った、LAN間接続(Site-to-Site)です。

#1 環境
##1.1 ネットワーク構成
VMware Workstation 14 Player上の仮想マシン(4台)を使いました。
ルータ間(router1<->router2)の通信をIPsecで暗号化します。

各ネットワークを以下のように呼びます。
192.168.10.0/24 => ネットワーク1
192.168.20.0/24 => ネットワーク2
192.168.30.0/24 => ネットワーク3

                                     |<--- IPsec --->|

           192.168.10.0/24            192.168.20.0/24           192.168.30.0/24
+- client -+              +- router1 -+             +- router2 -+              +- server -+
|          |              |           |             |           |              |          |
|          |              |           |             |           |              |          |
|          | .10      .20 |           | .10     .20 |           | .10      .20 |          |
|        eth1 ---------- eth1       eth2 --------- eth1        eth2 --------- eth1        |
|          |              |           |             |           |              |          |
|          |              |           |             |           |              |          |
|          |              |           |             |           |              |          |
+-- eth0 --+              +--- eth0 --+             +--- eth0 --+              +-- eth0 --+
     | .20                      | .30                     | .40                     | .50
     |                          |                         |                         |
-------------------------------------------------------------------------------------------
             192.168.3.0/24

##1.2 仮想マシンのOS版数
各仮想マシンのOS版数は以下のとりです。

[root@client ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

[root@client ~]# uname -r
3.10.0-693.el7.x86_64

#2 ネットワークの設定

##2.0 firewalldの停止(暫定対処)
本来なら、動かすべきです。
しかし、firewalldを動かすと、クライアント(client)からサーバ(server)にパケットが届きません。
firewalldによるパケットフォワーディングの設定方法が良くわかりません。

今は、pluto(鍵管理デーモン)やカーネルのIPsec処理部の動作概要を把握したいので、
とりあえず、firewalldは停止しました。設定方法が判明次第、追記したいと思います。

router1
[root@router1 ~]# systemctl stop firewalld.service
router2
[root@router2 ~]# systemctl stop firewalld.service

##2.1 NetworkManagerの停止
ここでは、NetworkManagerを停止した状態でIPsec環境を構築しました。
各仮想マシンのIPアドレスや経路情報は、下記ファイルに静的に設定しました。
/etc/sysconfig/network-scripts/ifcfg-*
/etc/sysconfig/network-scripts/route-*

client
[root@client ~]# systemctl stop NetworkManager
[root@client ~]# systemctl disable NetworkManager
router1
[root@router1 ~]# systemctl stop NetworkManager
[root@router1 ~]# systemctl disable NetworkManager
router2
[root@router2 ~]# systemctl stop NetworkManager
[root@router2 ~]# systemctl disable NetworkManager
server
[root@server ~]# systemctl stop NetworkManager
[root@server ~]# systemctl disable NetworkManager

##2.2 ルーティング機能の有効化
ルーティング機能のカーネルパラメータを有効にしました。
これ以外のカーネルパラメータも設定しました。それらは、5.2を参照ください。

router1
[root@router1 ~]# vi /etc/sysctl.d/90-ipsec.conf
[root@router1 ~]# cat /etc/sysctl.d/90-ipsec.conf
net.ipv4.ip_forward = 1
router2
[root@router2 ~]# vi /etc/sysctl.d/90-ipsec.conf
[root@router2 ~]# cat /etc/sysctl.d/90-ipsec.conf
net.ipv4.ip_forward = 1

##2.3 ルーティングテーブルの設定
ルーティングテーブルを設定します。

client
[root@client ~]# cat /etc/sysconfig/network-scripts/route-eth1
192.168.30.0/24 via 192.168.10.20 dev eth1
192.168.20.0/24 via 192.168.10.20 dev eth1
router1
[root@router1 ~]# cat /etc/sysconfig/network-scripts/route-eth2
192.168.30.0/24 via 192.168.20.20 dev eth2
router2
[root@router2 ~]# cat /etc/sysconfig/network-scripts/route-eth1
192.168.10.0/24 via 192.168.20.10 dev eth1
server
[root@server ~]# cat /etc/sysconfig/network-scripts/route-eth1
192.168.10.0/24 via 192.168.30.10 dev eth1
192.168.20.0/24 via 192.168.30.10 dev eth1

#3 ネットワークの状態確認

##3.1 ルーティングテーブルの確認

client
[root@client ~]# ip r
default via 192.168.3.1 dev eth0
192.168.3.0/24 dev eth0 proto kernel scope link src 192.168.3.20
192.168.10.0/24 dev eth1 proto kernel scope link src 192.168.10.10
192.168.20.0/24 via 192.168.10.20 dev eth1
192.168.30.0/24 via 192.168.10.20 dev eth1
router1
[root@router1 ~]# ip r
default via 192.168.3.1 dev eth0
192.168.3.0/24 dev eth0 proto kernel scope link src 192.168.3.30
192.168.10.0/24 dev eth1 proto kernel scope link src 192.168.10.20
192.168.20.0/24 dev eth2 proto kernel scope link src 192.168.20.10
192.168.30.0/24 via 192.168.20.20 dev eth2
router2
[root@router2 ~]# ip r
default via 192.168.3.1 dev eth0
192.168.3.0/24 dev eth0 proto kernel scope link src 192.168.3.40
192.168.10.0/24 via 192.168.20.10 dev eth1
192.168.20.0/24 dev eth1 proto kernel scope link src 192.168.20.20
192.168.30.0/24 dev eth2 proto kernel scope link src 192.168.30.10
server
[root@server ~]# ip r
default via 192.168.3.1 dev eth0
192.168.3.0/24 dev eth0 proto kernel scope link src 192.168.3.50
192.168.10.0/24 via 192.168.30.10 dev eth1
192.168.20.0/24 via 192.168.30.10 dev eth1
192.168.30.0/24 dev eth1 proto kernel scope link src 192.168.30.20

##3.2 クライアントからサーバまでの経路確認
宛先をサーバとするtracerouteコマンドをクライアントで実行します。
ネットワーク1,2,3を通過していることがわかります。
なお、tracerouteの使い方は、ここ(tracerouteコマンドの使い方)を参照してください。

[root@client ~]# traceroute 192.168.30.20
traceroute to 192.168.30.20 (192.168.30.20), 30 hops max, 60 byte packets
 1  192.168.10.20 (192.168.10.20)  0.454 ms  20.689 ms  20.597 ms
 2  192.168.20.20 (192.168.20.20)  20.547 ms  1.855 ms  1.793 ms
 3  192.168.30.20 (192.168.30.20)  1.572 ms !X  1.569 ms !X  2.252 ms !X

#4 libreswanの設定

##4.1 libreswanのインストール
router1とrouter2にlibreswanパッケージをインストールします。

router1
[root@router1 ~]# yum -y install libreswan
[root@router1 ~]# ipsec --version
Linux Libreswan 3.23 (netkey) on 3.10.0-693.el7.x86_64
router2
[root@router2 ~]# yum -y install libreswan
[root@router2 ~]# ipsec --version
Linux Libreswan 3.23 (netkey) on 3.10.0-693.el7.x86_64

##4.2 PSK(Pre Shared Key)の設定
認証方式として、PSKを使います。router1とrouter2で同じキー(net1)を設定します。
指定するアドレスは、IPsecを実行するインタフェースのアドレスになります。

router1
[root@router1 ~]# vi /etc/ipsec.d/net1.secrets
[root@router1 ~]# cat /etc/ipsec.d/net1.secrets
192.168.20.10 192.168.20.20 : PSK "net1"
router2
[root@router2 ~]# vi /etc/ipsec.d/net1.secrets
[root@router2 ~]# cat /etc/ipsec.d/net1.secrets
192.168.20.10 192.168.20.20 : PSK "net1"

##4.3 libreswanの定義ファイル編集
libreswanの定義ファイルは下記にあります。今回は特に編集せず、そのまま使用しました。

router1
[root@router1 ~]# ls /etc/ipsec.conf
/etc/ipsec.conf
router2
[root@router2 ~]# ls /etc/ipsec.conf
/etc/ipsec.conf

##4.4 IPsecコネクションの定義
暗号化の対象とするネットワークの定義をします。
ネットワーク1とネットワーク3でやりとりする通信を暗号化の対象にするための設定をしました。
また、DPD(Dead Peer Detection)を有効にしました。

router1
[root@router1 ~]# vi/etc/ipsec.d/net1.conf
[root@router1 ~]# cat /etc/ipsec.d/net1.conf
conn net1
     left=192.168.20.10
     leftsubnet=192.168.10.0/24
     right=192.168.20.20
     rightsubnet=192.168.30.0/24
     auto=start
     authby=secret
     dpddelay=10
     dpdtimeout=5
     dpdaction=restart
router2
[root@router2 ~]# vi /etc/ipsec.d/net1.conf
[root@router2 ~]# cat /etc/ipsec.d/net1.conf
conn net1
     left=192.168.20.20
     leftsubnet=192.168.30.0/24
     right=192.168.20.10
     rightsubnet=192.168.10.0/24
     auto=start
     authby=secret
     dpddelay=10
     dpdtimeout=5
     dpdaction=restart

##4.5 サービスの起動
libreswanのサービスを起動します。
サービスを起動すると、plutoという鍵交換のプロセスが動き出します。

router1
[root@router1 ~]# systemctl start ipsec
[root@router1 ~]# ps -C pluto -o comm,args,pid,ppid
COMMAND         COMMAND                        PID   PPID
pluto           /usr/libexec/ipsec/pluto --   5139      1
router2
[root@router2 ~]# systemctl start ipsec
[root@router2 ~]# ps -C pluto -o comm,args,pid,ppid
COMMAND         COMMAND                        PID   PPID
pluto           /usr/libexec/ipsec/pluto --   2690      1

#5 設定ファイルの確認
ipsec verifyコマンドを使って、設定ファイルが正しく設定できたかどうかを確認します。
以下はチェック項目が全てOKとなったときのものです。
初めてipsec verifyを実行すると、10章のような結果が出力されると思います。
そのような場合、指示にしたがって設定を変更してください。

router1
[root@router1 ~]# ipsec verify
Verifying installed system and configuration files

Version check and ipsec on-path                         [OK]
Libreswan 3.23 (netkey) on 3.10.0-693.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                              [OBSOLETE]
  003 WARNING: using a weak secret (PSK)
Checking 'ip' command                                   [OK]
Checking 'iptables' command                             [OK]
Checking 'prelink' command does not interfere with FIPS [OK]
Checking for obsolete ipsec.conf options                [OK]
router2
[root@router2 ~]# ipsec verify
Verifying installed system and configuration files

Version check and ipsec on-path                         [OK]
Libreswan 3.23 (netkey) on 3.10.0-693.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                              [OBSOLETE]
  003 WARNING: using a weak secret (PSK)
Checking 'ip' command                                   [OK]
Checking 'iptables' command                             [OK]
Checking 'prelink' command does not interfere with FIPS [OK]
Checking for obsolete ipsec.conf options                [OK]

#6 カーネルパラメータの設定
ipsec verifyコマンドでNGと判定された項目を以下のように設定しました。
また、それ以外に、下記2項目を設定しました。
・ルーティング機能の有効化(ip_forward=1)
・arp_ignore=1の設定(ARP requestのTarget IPがARP requestを受信したインタフェースの場合だけARP replyを返信する)

router1
[root@router1 ~]# cat /etc/sysctl.d/90-ipsec.conf
net.ipv4.ip_forward = 1

net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.eth1.arp_ignore = 1
net.ipv4.conf.eth2.arp_ignore = 1

net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.eth1.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0

net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.eth1.accept_redirects = 0
net.ipv4.conf.eth2.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0

net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.eth0.rp_filter=0
net.ipv4.conf.eth1.rp_filter=0
net.ipv4.conf.eth2.rp_filter=0
net.ipv4.conf.lo.rp_filter=0
router2
[root@router2 ~]# cat /etc/sysctl.d/90-ipsec.conf
net.ipv4.ip_forward = 1

net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.eth1.arp_ignore = 1
net.ipv4.conf.eth2.arp_ignore = 1

net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.eth1.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0

net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.eth1.accept_redirects = 0
net.ipv4.conf.eth2.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0

net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.eth0.rp_filter=0
net.ipv4.conf.eth1.rp_filter=0
net.ipv4.conf.eth2.rp_filter=0
net.ipv4.conf.lo.rp_filter=0

#7 IPsecの確認
##7.1 IKEの動作確認

ルータ2のサービスを再起動してみます。

router2
[root@router2 ~]# systemctl start ipsec

ISAKMPパケット(UDPの500番ポート)のやりとりが確認できます。

router1
[root@router1 ~]# tcpdump -i eth2 udp port 500 -nn -p
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth2, link-type EN10MB (Ethernet), capture size 262144 bytes
21:15:18.477776 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 2/others ? inf[E]
21:15:18.478629 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 2/others ? inf[E]
21:15:18.520535 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 2/others ? inf[E]
21:15:18.523521 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 2/others ? inf[E]
21:15:20.310834 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 1 I ident
21:15:20.311256 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 1 R ident
21:15:20.316799 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 1 I ident
21:15:20.321152 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 1 R ident
21:15:20.328220 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 1 I ident[E]
21:15:20.329241 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 1 R ident[E]
21:15:20.334948 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 2/others I oakley-quick[E]
21:15:20.346890 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 2/others R oakley-quick[E]
21:15:20.464316 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 2/others I oakley-quick[E]

ISAKMPパケット(UDPの500番ポート)のやりとりが確認できます。

router2
[root@router2 ~]# tcpdump -i eth1 udp port 500 -nn -p
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
21:15:18.476064 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 2/others ? inf[E]
21:15:18.477980 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 2/others ? inf[E]
21:15:18.519780 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 2/others ? inf[E]
21:15:18.521714 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 2/others ? inf[E]
21:15:20.309378 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 1 I ident
21:15:20.310444 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 1 R ident
21:15:20.315329 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 1 I ident
21:15:20.320318 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 1 R ident
21:15:20.326597 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 1 I ident[E]
21:15:20.328496 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 1 R ident[E]
21:15:20.333542 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 2/others I oakley-quick[E]
21:15:20.346200 IP 192.168.20.10.500 > 192.168.20.20.500: isakmp: phase 2/others R oakley-quick[E]
21:15:20.462916 IP 192.168.20.20.500 > 192.168.20.10.500: isakmp: phase 2/others I oakley-quick[E]

##7.2 SPI(Security Parameter Index)の確認

router1
[root@router1 ~]# ip xfrm state
src 192.168.20.20 dst 192.168.20.10
        proto esp spi 0x7405235c reqid 16389 mode tunnel
        replay-window 32 flag af-unspec
        auth-trunc hmac(sha1) 0xcfe7d85ba73a533cab494d9cc937834797e16cd2 96
        enc cbc(aes) 0xbcdcc4a5d2993e9999978552efd9563e
        anti-replay context: seq 0x16, oseq 0x0, bitmap 0x003fffff
src 192.168.20.10 dst 192.168.20.20
        proto esp spi 0x0e2c6b60 reqid 16389 mode tunnel
        replay-window 32 flag af-unspec
        auth-trunc hmac(sha1) 0xa6c79c8bd020d6cdb1a4329ac4e2f192e3bc3bb1 96
        enc cbc(aes) 0x138a316fa61472252a3f38b2f4cfa28b
        anti-replay context: seq 0x0, oseq 0x39, bitmap 0x00000000
src 192.168.20.20 dst 192.168.20.10
        proto esp spi 0x181f0d2a reqid 16389 mode tunnel
        replay-window 32 flag af-unspec
        auth-trunc hmac(sha1) 0xea61426a2e9b544b45e59d1f9f55f3a2ea133c65 96
        enc cbc(aes) 0x371d035d0eac99c64f4751d4bb466127
        anti-replay context: seq 0x0, oseq 0x0, bitmap 0x00000000
src 192.168.20.10 dst 192.168.20.20
        proto esp spi 0xa64e0ec6 reqid 16389 mode tunnel
        replay-window 32 flag af-unspec
        auth-trunc hmac(sha1) 0xfcdc28fd3cc6f546e8b0356333121a6ac42331a7 96
        enc cbc(aes) 0x6df2093d2242c81ab45fd74655d67046
        anti-replay context: seq 0x0, oseq 0x0, bitmap 0x00000000
router2
[root@router2 ~]# ip xfrm state
src 192.168.20.10 dst 192.168.20.20
        proto esp spi 0x0e2c6b60 reqid 16389 mode tunnel
        replay-window 32 flag af-unspec
        auth-trunc hmac(sha1) 0xa6c79c8bd020d6cdb1a4329ac4e2f192e3bc3bb1 96
        enc cbc(aes) 0x138a316fa61472252a3f38b2f4cfa28b
        anti-replay context: seq 0x39, oseq 0x0, bitmap 0xffffffff
src 192.168.20.20 dst 192.168.20.10
        proto esp spi 0x7405235c reqid 16389 mode tunnel
        replay-window 32 flag af-unspec
        auth-trunc hmac(sha1) 0xcfe7d85ba73a533cab494d9cc937834797e16cd2 96
        enc cbc(aes) 0xbcdcc4a5d2993e9999978552efd9563e
        anti-replay context: seq 0x0, oseq 0x16, bitmap 0x00000000
src 192.168.20.10 dst 192.168.20.20
        proto esp spi 0xa64e0ec6 reqid 16389 mode tunnel
        replay-window 32 flag af-unspec
        auth-trunc hmac(sha1) 0xfcdc28fd3cc6f546e8b0356333121a6ac42331a7 96
        enc cbc(aes) 0x6df2093d2242c81ab45fd74655d67046
        anti-replay context: seq 0x0, oseq 0x0, bitmap 0x00000000
src 192.168.20.20 dst 192.168.20.10
        proto esp spi 0x181f0d2a reqid 16389 mode tunnel
        replay-window 32 flag af-unspec
        auth-trunc hmac(sha1) 0xea61426a2e9b544b45e59d1f9f55f3a2ea133c65 96
        enc cbc(aes) 0x371d035d0eac99c64f4751d4bb466127
        anti-replay context: seq 0x0, oseq 0x0, bitmap 0x00000000

##6.3 暗号化通信の確認

宛先をサーバとするpingを実行します。

client
[root@client ~]# ping -c 1 192.168.30.20

クライアント側では、ICMPパケットが観測されていることがわかります。

client
[root@client ~]# tcpdump -i eth1 icmp -n -p
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
21:34:24.034484 IP 192.168.10.10 > 192.168.30.20: ICMP echo request, id 1404, seq 1, length 64
21:34:24.036186 IP 192.168.30.20 > 192.168.10.10: ICMP echo reply, id 1404, seq 1, length 64

ルータのインタフェース(eth2)でESPパケットが観測されていることがわかります。

router1
[root@router1 ~]# tcpdump -i eth2 esp -n -p
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth2, link-type EN10MB (Ethernet), capture size 262144 bytes
21:34:24.033401 IP 192.168.20.10 > 192.168.20.20: ESP(spi=0xa4e9e751,seq=0x1), length 132
21:34:24.034573 IP 192.168.20.20 > 192.168.20.10: ESP(spi=0x46d082c3,seq=0x1), length 132

ルータのインタフェース(eth1)でESPパケットが観測されていることがわかります。

router2
[root@router2 ~]# tcpdump -i eth1 esp -n -p
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
21:34:24.034662 IP 192.168.20.10 > 192.168.20.20: ESP(spi=0xa4e9e751,seq=0x1), length 132
21:34:24.035452 IP 192.168.20.20 > 192.168.20.10: ESP(spi=0x46d082c3,seq=0x1), length 132

サーバ側では、暗号化通信が復号され、ICMPパケットが観測されていることがわかります。

server
[root@server ~]# tcpdump -i eth1 icmp -n -p
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
21:34:24.035200 IP 192.168.10.10 > 192.168.30.20: ICMP echo request, id 1404, seq 1, length 64
21:34:24.035266 IP 192.168.30.20 > 192.168.10.10: ICMP echo reply, id 1404, seq 1, length 64

#10 ipsec verify実行結果(NG項目ありのとき)

[root@router1 ~]# ipsec verify
Verifying installed system and configuration files

Version check and ipsec on-path                         [OK]
Libreswan 3.23 (netkey) on 3.10.0-693.el7.x86_64
Checking for IPsec support in kernel                    [OK]
 NETKEY: Testing XFRM related proc values
         ICMP default/send_redirects                    [NOT DISABLED]

  Disable /proc/sys/net/ipv4/conf/*/send_redirects or NETKEY will act on or cause sending of bogus ICMP redirects!

         ICMP default/accept_redirects                  [NOT DISABLED]

  Disable /proc/sys/net/ipv4/conf/*/accept_redirects or NETKEY will act on or cause sending of bogus ICMP redirects!

         XFRM larval drop                               [OK]
Pluto ipsec.conf syntax                                 [OK]
Two or more interfaces found, checking IP forwarding    [OK]
Checking rp_filter                                      [ENABLED]
 /proc/sys/net/ipv4/conf/all/rp_filter                  [ENABLED]
 /proc/sys/net/ipv4/conf/default/rp_filter              [ENABLED]
 /proc/sys/net/ipv4/conf/eth0/rp_filter                 [ENABLED]
 /proc/sys/net/ipv4/conf/eth1/rp_filter                 [ENABLED]
 /proc/sys/net/ipv4/conf/eth2/rp_filter                 [ENABLED]
 /proc/sys/net/ipv4/conf/ip_vti0/rp_filter              [ENABLED]
  rp_filter is not fully aware of IPsec and should be disabled
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                              [OBSOLETE]
  003 WARNING: using a weak secret (PSK)
Checking 'ip' command                                   [OK]
Checking 'iptables' command                             [OK]
Checking 'prelink' command does not interfere with FIPS [OK]
Checking for obsolete ipsec.conf options                [OK]

ipsec verify: encountered 15 errors - see 'man ipsec_verify' for help
[root@router1 ~]#

#Z 参考
Configuration examples
Linux Kernel における IPsec

18
14
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
14