-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from traPtitech/feat/chapter4
第四部(インターネット構築講習会)を移植
- Loading branch information
Showing
26 changed files
with
2,921 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { DefaultTheme } from 'vitepress' | ||
import { sidebarItems } from './sidebar' | ||
|
||
export const chapter4SidebarItems: DefaultTheme.SidebarItem[] = [ | ||
{ | ||
text: '第四部', | ||
items: [{ text: 'はじめに', link: '/chapter4/0_index' }, ...sidebarItems] | ||
} | ||
] |
14 changes: 14 additions & 0 deletions
14
docs/.vitepress/sidebarConfigs/chapters/chapter4/sidebar.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { DefaultTheme } from 'vitepress' | ||
export const sidebarItems: DefaultTheme.SidebarItem[] = [ | ||
{ text: 'Docs', link: '/chapter4/docs' }, | ||
{ text: '1. IP Address', link: '/chapter4/1_ip_address' }, | ||
{ text: '2. NAT', link: '/chapter4/2_nat' }, | ||
{ text: '3. Routing 1', link: '/chapter4/3_routing_1' }, | ||
{ text: '4. Routing 2', link: '/chapter4/4_routing_2' }, | ||
{ text: '5. DHCP', link: '/chapter4/5_dhcp' }, | ||
{ text: '6. IP Tunneling', link: '/chapter4/6_ip_tunneling' }, | ||
{ text: '7. BGP', link: '/chapter4/7_bgp' }, | ||
{ text: '8. DNS 1', link: '/chapter4/8_dns_1' }, | ||
{ text: '9. DNS 2', link: '/chapter4/9_dns_2' }, | ||
{ text: '10. DNS 3', link: '/chapter4/10_dns_3' } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ Windows: `Winキー + Shift + S`を押すと、矩形選択でスクリーンシ | |
|
||
## WSL の導入(Windows を使っている人のみ) | ||
|
||
すでに WSL をインストールしている方はこの手順は飛ばして大丈夫です。 | ||
すでに WSL をインストールしている方はこの手順を飛ばして大丈夫です。 | ||
|
||
WSL は Windows 上で Linux を動かすための仕組みで、`Windows Subsystem for Linux`の略です。 | ||
|
||
|
@@ -34,7 +34,7 @@ Homebrew とは、様々なアプリケーションをインストールしや | |
|
||
## VSCode の導入 | ||
|
||
すでに VSCode をインストールしている方はこの手順は飛ばして大丈夫です。 | ||
すでに VSCode をインストールしている方はこの手順を飛ばして大丈夫です。 | ||
|
||
以下のサイトから使用している OS に合った VSCode のインストーラーをダウンロードして、それを実行してインストールしてください。 | ||
|
||
|
@@ -66,7 +66,7 @@ https://golang.org/doc/install | |
|
||
Mac のタブを選択し、ダウンロードページに飛んで自分のアーキテクチャの pkg をダウンロード=>インストーラ起動で設定完了です。 | ||
|
||
もしくはHomebrewがすでにインストールされている人は、`brew install [email protected]`を実行することでも導入できます。 | ||
もしくは Homebrew がすでにインストールされている人は、`brew install [email protected]`を実行することでも導入できます。 | ||
|
||
::: info | ||
M1/M2 Mac の人は Apple macOS (ARM64) を、Intel Mac の人は Apple macOS (x86-64) を選択してください。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 初めに | ||
|
||
第四部では、仮想的に接続された機器の設定を通して、インターネットが動くのに必要な要素技術を実用的な形で学習します。 | ||
|
||
1969 年にその原型となった ARPANET が誕生して以来、インターネットは今や生活のあらゆる場面に登場し、社会インフラの一部となりました。 | ||
この講習会では、インターネットを支える技術のなかでも識別子の扱いや経路制御、名前解決などに注目して掘り下げていきます。(前提知識は特に要求しません) | ||
|
||
各講義は作業の背景知識となる**Lesson**と、実際に手を動かしてネットワークの設定をする**Assignment**で構成されています。 | ||
|
||
長年かけて発展してきたインターネットの技術を網羅的に扱う都合上、Lesson にはあまり詳しい内容は書かないので各自で積極的に調べるようにしてください。 | ||
|
||
この資料は過去に[インターネット構築講習会](https://github.com/hijiki51/InternetArchLecture)として開催されたものを移植したものです。 | ||
|
||
## 環境構築 | ||
- 動作環境 | ||
- Ubuntu 20.04 LTS | ||
- GCP e2-micro | ||
- vCPU x2 | ||
- memory 1GB | ||
|
||
Exec this script: | ||
`curl https://raw.githubusercontent.com/hijiki51/InternetArchLecture/main/setup/setup.sh | bash` | ||
|
||
|
||
### 再起動時の設定 | ||
現状 docker と bridge の接続がコンテナの停止によって切断されてしまう。 | ||
そのため、コンテナを再起動したときには以下の手順で復旧作業を行う。 | ||
|
||
#### サーバー | ||
```sh | ||
$ ovs-vsctl list-ports br-r4-server | xargs -IXXX ovs-vsctl del-port br-r4-server XXX | ||
$ ovs-vsctl list-ports br-rEX-server | xargs -IXXX ovs-vsctl del-port br-rEX-server XXX | ||
$ nic_full_reset | ||
$ seq 1 3 | xargs -IXXX ovs-docker add-port br-r4-server ens4 sXXX | ||
$ ovs-docker add-port br-rEX-server ens4 sEX | ||
``` | ||
|
||
#### 各ルーター | ||
```sh | ||
$ config | ||
$ load | ||
$ commit | ||
$ save | ||
$ exit | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Chapter8: DNS 3 | ||
|
||
この章ではルートネームサーバーとリゾルバについて学びます。 | ||
|
||
[[toc]] | ||
|
||
## Lesson | ||
|
||
### リゾルバ | ||
|
||
今までは手動で名前解決をしていましたが、普段インターネットを利用する際には「リゾルバ」がその役割を担ってくれます。 | ||
リゾルバは一般に「フルリゾルバ」と「スタブリゾルバ」の 2つで構成されています。 | ||
|
||
スタブリゾルバは各デバイスに存在し、フルリゾルバへ向けて「再帰問い合わせ」を投げ、その結果を受け取ります。 | ||
|
||
フルリゾルバは、スタブリゾルバから再帰問い合わせ(Recursive request)を受けてネームサーバーに反復問い合わせ(Iterative request)をし、ドメイン名を解決します。 | ||
|
||
反復問い合わせは、複数回の非再帰問い合わせ(Non-recursive request)をすることを指します。 | ||
|
||
非再帰問い合わせは、ネームサーバーのローカルにある情報だけで応答します。応答結果は次の 5 つのいずれかになります。 | ||
- 完全なドメイン名が存在するとき: ドメイン名の指定レコード | ||
- そのドメインが別のネームサーバーに移譲されていることがわかっているとき: 移譲先のドメイン名(NS レコードの RDATA) | ||
- そのドメインにエイリアス(CNAME レコード)が存在するとき: エイリアス元のドメイン名(CNAME レコードの RDATA) | ||
- ドメイン名が存在しないとき: NXDOMAIN | ||
- 完全なドメイン名が存在するが、指定レコードが存在しないとき: NODATA | ||
|
||
フルリゾルバのアルゴリズムは次のようになります。 | ||
1. キャッシュを確認し、もし存在したらその結果を返す。 | ||
2. ローカルの情報から、問い合わせを投げるのに適切なネームサーバー群を選択する。 | ||
3. 選択したネームサーバー群にそのうちのどれか 1 つが応答を返すまで問い合わせを投げる | ||
4. 応答結果を分析する | ||
1. ドメイン名の指定レコードが帰ってきたら、その結果をキャッシュし、スタブリゾルバに返す | ||
2. NS レコードが帰ってきたら、その結果をキャッシュし、2.に戻る | ||
3. CNAME レコードが帰ってきたら、その結果をキャッシュし、探索対称のドメイン名を変更したうえで 1.に戻る | ||
4. それ以外の結果(エラー)が帰ってきた場合、そのネームサーバーを選択したネームサーバー群から除外し、3.に戻る | ||
|
||
このようにフルリゾルバとスタブリゾルバを分離することで、キャッシュを共有できるようになり、より効率的に名前解決ができます。 | ||
:::tip | ||
bind9 にはフルリゾルバの機能もあります | ||
::: | ||
## Assignment | ||
|
||
### 1. ルートネームサーバーを設定してみよう | ||
ルートネームサーバーに問い合わるように設定してみよう。 | ||
::: details ヒント1 | ||
`named.conf.default-zones`を見るといいでしょう | ||
::: | ||
::: details ヒント2 | ||
`bind9 ルートネームサーバー 設定`などで調べるといいでしょう | ||
::: | ||
|
||
::: details 答え | ||
|
||
`/usr/share/dns/root.hints`\ | ||
追記もしくは書き換える。 | ||
|
||
``` | ||
. 3600000 NS NS.ROOT. | ||
NS.ROOT. 3600000 A {ルートネームサーバーの Global IP} | ||
``` | ||
|
||
::: | ||
|
||
### 2. リゾルバを使って名前解決してみよう | ||
1.で立てたフルリゾルバをつかって s1~s3 のサーバーのいずれかから名前解決をしてみて下さい。 | ||
|
||
::: details ヒント | ||
スタブリゾルバの設定は`/etc/resolv.conf`に書くことができます。 | ||
::: | ||
|
||
::: details 答え | ||
`/etc/resolv.conf` | ||
|
||
``` | ||
nameserver {ルートネームサーバーの Global IP} | ||
``` | ||
::: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
|
||
# Chapter1: IP Address | ||
|
||
この章では TCP/IP でノードの識別子として用いられる IP アドレスに関する基礎知識とその設定を学びます。 | ||
|
||
[[toc]] | ||
|
||
## Lesson | ||
|
||
### Internet | ||
|
||
*The Internet*は、ARPANET と呼ばれる 4 つのノードを接続した小さなネットワークから発展し、今では全世界を接続する巨大なコンピューターネットワークのことを指します。 | ||
|
||
インターネットの構造は、根本的には ARPANET の時代と変化しておらず、ネットワークとネットワークが接続されることで形成されています。 | ||
|
||
数台の機器によって構成される小さなネットワーク同士が接続し、組織内のネットワークを構成し、組織同士のネットワークが接続することで地域のネットワークが形成されます。 | ||
そして地域のネットワーク同士が接続され、最終的には世界中を結ぶ*The Internet*が形作られます。 | ||
このように、インターネットは階層的な構造を持っています。 | ||
|
||
### TCP/IP | ||
|
||
TCP/IP(Internet protocol suite)は、インターネットを含む多くのコンピューターネットワークに置いて標準的に用いられる通信プロトコルのセットです。 | ||
|
||
![TCP/IP(DARPAモデル)](assets/TCP_IP.png) | ||
|
||
IP アドレスは TCP/IP の Internet Protocol において各ノードを識別するために用いられる識別子で、今回は IPv4 を使用します。 | ||
|
||
IPv4 アドレスは 32bit の数値で表され、ネットワークを指定する**ネットワーク部**(上位)とそのネットワーク内の機器を指定する**ホスト部**(下位)に分けられます。 | ||
通常は 32bit を 8bit ずつにドット`(.)`で区切って、10 進法表記したものが用いられ、上位から何 bit がネットワーク部にあたるかを`/`の後に表記します(この値をサブネットマスクという)。 | ||
|
||
|
||
- `172.16.254.1 = 10101100.00010000.11111110.00000001`\ | ||
- `172.16.254.1/24 = 10101100.00010000.11111110(←ここまでネットワーク部).00000001` | ||
|
||
::: info | ||
- ホスト部がすべて 0 のアドレスは**ネットワークアドレス**として予約済み | ||
- ホスト部がすべて1のアドレスは**ブロードキャストアドレス**として予約済み | ||
- 127.0.0.1 は**ループバックアドレス**として予約済み | ||
::: | ||
## Assignment | ||
|
||
割り当てられたネットワークの構成については[docs](docs.md)を参照してください。 | ||
|
||
### 1. rEXとr1の間でpingによる疎通確認ができるようにしてみよう | ||
|
||
::: details ヒント1 | ||
|
||
`ping`は ICMP を使用したネットワークの診断プログラムです。 | ||
ICMP は「エラー通知」や「制御メッセージ」を転送するためのプロトコルで、IP 上で動作します。 | ||
そのため、IP 上での通信を行える必要があります。 | ||
|
||
直接接続された NIC 同士は互いを認識できますが、初期状態では IP アドレスが割り振られていないことに注意しましょう。 | ||
::: | ||
|
||
::: details ヒント2 | ||
|
||
最初に決める必要があるのは、rEX の eth10 と r1 の eth12 に割り振るネットワークの範囲です。 | ||
この場合、ネットワークの大きさは`.0/30`で良いでしょう。 | ||
::: | ||
|
||
::: details ヒント3 | ||
|
||
「VyOS IP アドレス設定」などで検索してみると良いでしょう。 | ||
::: | ||
|
||
::: details 答え | ||
|
||
[rEX] | ||
```sh | ||
root@hijiki51-60000:/# attach rEX | ||
minion@rEX:/$ config | ||
[edit] | ||
minion@rEX# set interfaces ethernet eth10 address 192.168.XXX.1/30 | ||
[edit] | ||
minion@rEX# commit | ||
[edit] | ||
minion@rEX# save | ||
Done | ||
[edit] | ||
minion@rEX# exit | ||
exit | ||
minion@rEX:/$ exit | ||
exit | ||
``` | ||
|
||
[r1] | ||
```sh | ||
root@hijiki51-60000:/home/hijiki51# attach r1 | ||
minion@r1:/$ config | ||
[edit] | ||
minion@r1# set interfaces ethernet eth12 address 192.168.XXX.2/30 | ||
[edit] | ||
minion@r1# commit | ||
[edit] | ||
minion@r1# save | ||
Done | ||
[edit] | ||
minion@r1# exit | ||
exit | ||
minion@r1:/$ exit | ||
exit | ||
``` | ||
|
||
::: |
Oops, something went wrong.