Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ICTSC2022 問題解説まとめ から ICTSC2019 本選 問題解説まとめ までのリンクを WordPress 側に寄せた #7

Merged
merged 4 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 13 additions & 81 deletions src/content/blog/wordpress/2020030116003099.md
Original file line number Diff line number Diff line change
@@ -1,125 +1,73 @@
---
title: "VPNが繋がらない"
description: "VPNが繋がらない"
tags: [ICTSC2019,問題解説]
tags: [ICTSC2019, 問題解説]
pubDate: 2020-03-01T16:00:27
slug: "2020/03/01/VPNが繋がらない"
slug: "2020/03/01/vpnが繋がらない"
draft: false
renderer: "html"
sticky: false
---


<p>問題を解いていただきありがとうございました!</p>



<h2 id="%E5%95%8F%E9%A1%8C%E6%96%87">問題文&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#%E5%95%8F%E9%A1%8C%E6%96%87"></a>&nbsp;</h2>



<h3 id="%E6%A6%82%E8%A6%81">概要&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#%E6%A6%82%E8%A6%81"></a>&nbsp;</h3>



<p>あなたのクラスメイトのA君は、Ciscoルーターである<code>RT</code>とUbuntuサーバーである<code>Server</code>間でIPIP over ipsecの検証をしていました。 しかし、設定を変更していると<code>RT</code>と<code>Server</code>間の疎通ができなくなってしまいました。<br>A君の代わりに、<code>RT</code>と<code>Server</code>のIPIP over ipsecの設定を修正し疎通できるようにして下さい。</p>



<figure class="wp-block-image"><img decoding="async" src="https://wiki.icttoracon.net/attachment/5e4aa98f2f8d9c005abff757" alt="topology.png.webp"/></figure>



<ul><li>RT<ul><li>Cisco CSR 1000v</li><li>IPアドレス<ul><li>gi1 192.168.14.10/24</li><li>tun0 10.50.0.1/30</li></ul></li></ul></li><li>Server<ul><li>Ubuntu 18.04</li><li>ipsec: strongswan</li><li>IPアドレス<ul><li>eth0 192.168.14.20/24</li><li>tun0 10.50.0.2/30</li></ul></li></ul></li></ul>



<h3 id="%E5%88%9D%E6%9C%9F%E7%8A%B6%E6%85%8B">初期状態&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#%E5%88%9D%E6%9C%9F%E7%8A%B6%E6%85%8B"></a>&nbsp;</h3>



<ul><li>RT, Server間で通信が行えない<ul><li>RTから&nbsp;<code>ping 10.50.0.2</code>&nbsp;をしても応答がない</li><li>Serverから&nbsp;<code>ping 10.50.0.1</code>&nbsp;をしても応答がない</li></ul></li></ul>



<h3 id="%E7%B5%82%E4%BA%86%E7%8A%B6%E6%85%8B">終了状態&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#%E7%B5%82%E4%BA%86%E7%8A%B6%E6%85%8B"></a>&nbsp;</h3>



<ul><li>RT, Server間で通信が行える<ul><li>RTから&nbsp;<code>ping 10.50.0.2</code>&nbsp;をして応答がある</li><li>Serverから&nbsp;<code>ping 10.50.0.1</code>をして応答がある</li></ul></li><li>IPIP over ipsecでトンネリング及び暗号化がされている</li><li>設定が永続化されており、再起動後も自動で疎通ができる状態になっている</li></ul>



<h2 id="%E6%8E%A1%E7%82%B9%E5%9F%BA%E6%BA%96">採点基準&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#%E6%8E%A1%E7%82%B9%E5%9F%BA%E6%BA%96"></a>&nbsp;</h2>



<ul><li>RTとServer間の通信でき、暗号化されている (80%)<ul><li>RT -&gt; Server&nbsp;<code>ping 10.50.0.2</code>&nbsp;(40%)</li><li>Server -&gt; RT&nbsp;<code>ping 10.50.0.1</code>&nbsp;(40%)</li></ul></li><li>上記を満たしており、トンネリングにはIPIPのみを用いている (20%)<ul><li>ipsecでトンネリングやその他のトンネリングはNG</li></ul></li></ul>



<h2 id="%E8%A7%A3%E8%AA%AC">解説&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#%E8%A7%A3%E8%AA%AC"></a>&nbsp;</h2>



<p>RTとServerのそれぞれの設定が間違っていることによるトラブルでした。 具体的には以下の3つの原因が上げられます。</p>



<ul><li>strongswanの設定で<code>auto=add</code>になっている</li><li>ipsecの通信モードが異なっている</li><li>ikeのバージョンが異なっている</li></ul>



<h3 id="%E5%8E%9F%E5%9B%A0">原因&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#%E5%8E%9F%E5%9B%A0"></a>&nbsp;</h3>



<h4 id="strongswan%E3%81%AE%E8%A8%AD%E5%AE%9A%E3%81%A7auto%3Dadd%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B">strongswanの設定で<code>auto=add</code>になっている&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#strongswan%E3%81%AE%E8%A8%AD%E5%AE%9A%E3%81%A7auto%3Dadd%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B"></a>&nbsp;</h4>



<p><code>auto=add</code>を設定したとき、strongswanは起動時設定の読み込みのみを行います。そのため、手動で接続しなければトンネルを張ることができません。 そこで、<code>start</code>または<code>route</code>を設定することによって接続を自動で行うようにします。</p>



<p><code>start</code>と<code>route</code>は以下のように動作します。</p>



<ul><li><code>start</code>&nbsp;サービス起動時にトンネルを張る</li><li><code>route</code>&nbsp;通信時にトンネルを張る</li></ul>



<h4 id="ipsec%E3%81%AE%E9%80%9A%E4%BF%A1%E3%83%A2%E3%83%BC%E3%83%89%E3%81%8C%E7%95%B0%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B">ipsecの通信モードが異なっている&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#ipsec%E3%81%AE%E9%80%9A%E4%BF%A1%E3%83%A2%E3%83%BC%E3%83%89%E3%81%8C%E7%95%B0%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B"></a>&nbsp;</h4>



<p>strongswanではipsecの通信モードを<code>type=transport</code>とtransportモードに設定していますが、RTでは<code>mode tunnel</code>&nbsp;とtunnelモードになっていました。</p>



<p>今回の構成では、IPIP over ipsecを行っているのでトンネリングはIPIPが担当します。そのため、ipsecではトンネリングする必要が無いのでRTの設定を<code>mode transport</code>に設定します。</p>



<h4 id="ike%E3%81%AE%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E3%81%8C%E7%95%B0%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B">ikeのバージョンが異なっている&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#ike%E3%81%AE%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E3%81%8C%E7%95%B0%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B"></a>&nbsp;</h4>



<p>上記の問題を解決したあと、RTからServerへpingを送ってみると、接続が確立され疎通が取れていることが確認できます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre><code>RT#ping 10.50.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.50.0.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
</code></pre></div>


<p>しかし、接続を確立していない状態でServerからRTへpingを送ってみると接続が確立されず疎通が取れません。</p>


<div class="wp-block-syntaxhighlighter-code "><pre><code>user@Server:~$ sudo systemctl restart strongswan
user@Server:~$ ping -c 1 10.50.0.1
PING 10.50.0.1 (10.50.0.1) 56(84) bytes of data.
Expand All @@ -128,56 +76,40 @@ PING 10.50.0.1 (10.50.0.1) 56(84) bytes of data.
1 packets transmitted, 0 received, 100% packet loss, time 0ms
</code></pre></div>


<p>RTは設定からikev1を利用していることがわかります。 strongswanの設定では、<code>keyexchange=ike</code>というように指定されています。strongswanでは、<code>ike</code>を指定した場合、接続の開始時にikev2を提案します。しかし、受信時にはいずれかのバージョンをacceptします。<br>そのため、RTからServerでは接続できでも、ServerからRTはできないという状態になっていました。 今回の構成ではikeのバージョンを指定されていないので、楽に修正ができるikev1に合わせます。 strongswanの設定を、<code>keyexchange=ikev1</code>に変更します。</p>



<h3 id="%E4%BF%AE%E6%AD%A3%E5%BE%8C%E3%81%AE%E8%A8%AD%E5%AE%9A">修正後の設定&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#%E4%BF%AE%E6%AD%A3%E5%BE%8C%E3%81%AE%E8%A8%AD%E5%AE%9A"></a>&nbsp;</h3>



<h4 id="RT%E3%81%AE%E8%A8%AD%E5%AE%9A">RTの設定&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#RT%E3%81%AE%E8%A8%AD%E5%AE%9A"></a>&nbsp;</h4>



<p>RTの設定は以下のようになります。(<code>show run</code>&nbsp;一部抜粋)</p>


<div class="wp-block-syntaxhighlighter-code "><pre><code>crypto ipsec transform-set TS_IPSEC esp-aes esp-sha256-hmac
<div class="wp-block-syntaxhighlighter-code "><pre><code>crypto ipsec transform-set TS_IPSEC esp-aes esp-sha256-hmac
mode transport
</code></pre></div>


<h4 id="Server(strongswan)%E3%81%AE%E8%A8%AD%E5%AE%9A">Server(strongswan)の設定&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#Server(strongswan)%E3%81%AE%E8%A8%AD%E5%AE%9A"></a>&nbsp;</h4>



<p>Serverのstrongswanの設定(<code>/etc/ipsec.conf</code>)は以下のようになります。</p>


<div class="wp-block-syntaxhighlighter-code "><pre><code># ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup

conn RT
authby=secret
left=192.168.14.20
leftid=192.168.14.20
right=192.168.14.10
rightid=192.168.14.10
auto=start
type=transport
keyexchange=ikev1
ike=aes-sha256-modp3072
esp=aes-sha256
authby=secret
left=192.168.14.20
leftid=192.168.14.20
right=192.168.14.10
rightid=192.168.14.10
auto=start
type=transport
keyexchange=ikev1
ike=aes-sha256-modp3072
esp=aes-sha256
</code></pre></div>


<h3 id="%E5%8F%82%E8%80%83%E6%96%87%E7%8C%AE">参考文献&nbsp;<a href="https://wiki.icttoracon.net/ictsc2019/problems/inagaki:strongswan/blog/#%E5%8F%82%E8%80%83%E6%96%87%E7%8C%AE"></a>&nbsp;</h3>



<ul><li><a href="https://www.cisco.com/c/ja_jp/support/docs/ip/internet-key-exchange-ike/117258-config-l2l.html">Cisco IOS と strongSwan 間の IKEv1/IKEv2 設定例</a></li><li><a href="https://wiki.strongswan.org/projects/strongswan/wiki/ConnSection">strongSwan User Documentation &#8211; Configuration Files &#8211; ipsec.conf Reference</a></li><li><a href="http://shomi3023.com/2018/03/26/post-1654/">shomiの備忘録 &#8211; [strongSwan]autoパラメータの違いについて確認した(add/start/route/ignore)</a></li><li><a href="https://www.infraexpert.com/study/ipsec6.html">ネットワークエンジニアとして &#8211; IPsec &#8211; Transport mode / Tunnel mode</a></li><li><a href="https://www.infraexpert.com/study/ipsec11.html">ネットワークエンジニアとして &#8211; IPsec IKE Phase 2 &#8211; Cisco Configuration</a></li></ul>
Loading