334.4 バーチャルプライベートネットワーク(VPN)|sakuzo_books (2024)


課題 334: ネットワークセキュリティ
334.4 バーチャルプライベートネットワーク(VPN)

LPIC303の試験範囲である主題331~335まであるうちの「334: ネットワークセキュリティ」から「334.4 バーチャルプライベートネットワーク(VPN)」についてのまとめ

  • 総重量:4

  • 説明:
    OpenVPN, IPsec, WireGuardについて、サイト間VPNでのリモートアクセスでの設定を行い、利用を熟知している。

  • 主要な知識範囲:

    • ブリッジ・ルーティングされたVPNの概念を理解している。

    • OpenVPN, IPsec, IKEv2, WIreGuardプロトコルの主な違いと概念を理解している。

    • OpenVPNサーバとクライアントを設定・操作する。

    • IPsecサーバとクライアントを、strongSwanを利用して設定・操作する。

    • WireGuardサーバとクライアントを設定・操作する。

  • 重要なファイル、用語、ユーティリティ:

    • /etc/openvpn/

    • openvpn

    • /etc/strongswan.conf

    • /etc/strongswan.d/

    • /etc/swanctl/swanctl.conf

    • /etc/swanctl/

    • swanctl

    • /etc/wireguard/

    • wg

    • ip

VPNの概念

  • Virtual Private Network(仮想閉域ネットワーク)

  • 暗号化された仮想的なネットワークを実現する

  • 「認証」と「暗号化」が重要

VPNの種類

VPNの接続形態(1)

  • site-to-sitevpn
    拠点間VPN
    拠点のVPN機器がVPNトンネルを構成するので、クライアントPCはVPNを使っていることを意識することはない

  • remote access vpn
    リモートアクセスVPN
    モバイルユーザーが利用する
    PCには専用のVPNクライアントをインストールして使うのが一般的
    なりすましや認証情報の漏洩といった脅威への対策としてOTP、MFAなどを併用する

VPNの接続形態(2)

  • ルート接続
    VPNクライアント側とVPNサーバー側でそれぞれ異なるネットワークアドレスを割り当ててルーティングよって相互通信を実現する

  • ブリッジ接続
    VPNクライアント側とVPNサーバー側で同じネットワークアドレスを割り当ててLayer2レベル相互通信を実現する

VPN接続の諸問題

NATが越えられない
VPNはプロトコルの性質上NAT/PAT環境では不具合が生じる場合があるので、HTTPSでも使われているSSL/TLSを使うSSTPやSSL-VPNを使ったり、NATトラバーサル、VPNパススルーといった機能を使うことで接続性を向上させることが可能になる。

Firewallが超えられない
VPNは様々なプロトコルを組み合わせて使われるので、Firewall設定の難易度は高くなる。
また、暗号化の過程で様々なヘッダが付加されるためMSS値やMTU値を通常より少ない値に調整しないと通信できない場合がある。

速度が出ない
通信するすべてのデータを暗号化/復号化処理をすることになるので、通信速度はPCスペックの影響を受けることになる

OpenVPN, IPsec, IKEv2, WireGuardプロトコルの主な違いと概念

OpenVPNの特徴

OpenVPNは業界標準であるSSL/TLSプロトコルを利用した、高機能のSSL VPNです。

IPSecの特徴

OSI参照モデルのネットワーク層(Layer3)で暗号化するプロトコル
- 認証と改ざん防止:AH(Authentication Header)
- 暗号化:ESP(Encapsulated Security Payload)
- 鍵交換:IKE(Internet Key Exchange protocol)
- 論理的な経路:SA(Security Association)
- SAD(Security Association Database)
- SPD(Security Policy Database)

IKEv2

IPSecでは共通鍵暗号方式を使っていることから安全に秘密鍵を交換する必要があるためIKEが使われることが多い。
IKEはInternet Key Exchange の略で、VPNに必要な共通鍵を安全に交換するためのプロトコル。

WireGuard

WireGuard is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPsec, while avoiding the massive headache.

参考

OpenVPNサーバとクライアントを設定・操作する

OpenVPNとは

SSL-VPNを実現するオープンソースソフトウェア

インストール

  • RockyLinux 9

[root@lpic303-rocky34 ~]#[root@lpic303-rocky34 ~]# dnf install openvpn[root@lpic303-rocky34 ~]#
  • Ubuntu 22.04

root@lpic303-ubuntu35:~#root@lpic303-ubuntu35:~# apt install openvpnroot@lpic303-ubuntu35:~#

設定ファイル

/etc/openvpn/*
/etc/openvpn/client/*
/etc/openvpn/server/*

設定ファイル:client.conf

SAMPLE
/usr/share/doc/openvpn/sample/sample-config-files/client.conf

  • ca<ファイル名>

  • cert<ファイル名>

  • key<ファイル名>

  • proto <tcp | udp>

  • cipher<暗号化方式>

  • remote <hostname | ipaddress> [port]

  • nobind
    特定のポート番号を使用したい場合は

  • dev <tun | tap>
    tun:ルート接続
    tap:ブリッジ接続

設定ファイル:server.conf

SAMPLE
/usr/share/doc/openvpn/sample/sample-config-files/server.conf

  • ca<ファイル名>

  • cert<ファイル名>

  • key<ファイル名>

  • keepalive<間隔><待ち時間>

  • port<ポート番号>

  • proto <tcp | udp>

  • push "route <宛先ネットワークアドレス>"

  • push "dhcp-option <DHCPオプション>"

  • server <ネットワークアドレス>

  • cipher<暗号化方式>

  • dev <tun | tap>
    tun:ルート接続
    tap:ブリッジ接続

コマンド

  • --daemon

  • --genkey--secret <鍵>

  • --mlock

  • --show-ciphers

  • --show-tls

  • --tls-timeout <秒>

  • --resolv-retry <秒>

参考

strongSwanを利用して設定・操作

strongSwanとは

IKEでVPNを実現するオープンソースソフトウェア
FreeS/WANプロジェクトから派生したプロジェクト
類似の派生プロジェクトにOpenswanがある

strongSwan is a comprehensive implementation of the Internet Key Exchange (IKE) protocols that allows securing IP traffic in policy- and route-based IPsec scenarios from simple to very complex.
↓↓↓Google翻訳↓↓↓
strongSwan は、インターネット キー交換 (IKE) プロトコルの包括的な実装であり、単純なものから非常に複雑なものまで、ポリシーベースおよびルートベースの IPsec シナリオで IP トラフィックを保護できます。

インストール

  • RockyLinux 9

[root@lpic303-rocky34 ~]#[root@lpic303-rocky34 ~]# dnf install strongswan[root@lpic303-rocky34 ~]#
  • Ubuntu 22.04

root@lpic303-ubuntu35:~#root@lpic303-ubuntu35:~# apt install strongswanroot@lpic303-ubuntu35:~#

構成要素

  • swanctl
    VICI(Versatile IKE Control Interface)を介してcharonデーモンを操作するCLIツール

  • charon
    IKEv2 デーモン

設定ファイル(RockyLinux9)

  • strongSwan
    /etc/strongswan/*
    /etc/strongswan/strongswan.conf
    /etc/strongswan/strongswan.d/charon/*.conf
    /etc/strongswan/strongswan.d/*.conf

  • swanctl
    VPN接続に関する設定
    /etc/strongswan/swanctl/*
    /etc/strongswan/swanctl/swanctl.conf

  • ipsec
    旧VPN接続に関する設定(Deprecated)
    /etc/strongswan/ipsec.conf
    /etc/strongswan/ipsec.secrets
    /etc/strongswan/ipsec.d/cacerts/*:認証局証明書
    /etc/strongswan/ipsec.d/certs/*:サーバー証明書
    /etc/strongswan/ipsec.d/private/*:認証局・サーバーの秘密鍵
    (補足)
    2019年にリリースされたstrongSwan5.8.0から "ipsec.conf" の内容は "swanctl.conf" に記述することになっているため "ipsec.conf" の使用は非推奨となっている。
    LPIC303-300がリリースされたのが2021年10月で、試験範囲にも "ipsec.conf" の記載がないことから、"swanctl.conf" について学習する必要があると推測される。

コマンド

  • /usr/sbin/charon-cmd
    IKEを使ったIPSec接続を設定するコマンド

[root@lpic303-rocky34 ~]#[root@lpic303-rocky34 ~]# charon-cmd --helpUsage: /usr/sbin/charon-cmd --help print this usage information and exit --version show version information and exit --debug <level> set the default log level (-1..4, default: 1) --host <hostname> DNS name or address to connect to --identity <identity> identity the client uses for the IKE exchange --eap-identity <eap-identity> identity the client uses for EAP authentication --xauth-username <xauth-username> username the client uses for XAuth authentication --remote-identity <identity> server identity to expect, defaults to host --cert <path> certificate for authentication or trust chain validation --rsa <path> RSA private key to use for authentication --p12 <path> PKCS#12 file with private key and certificates to use for authentication and trust chain validation --agent[=socket] use SSH agent for authentication. If socket is not specified it is read from the SSH_AUTH_SOCK environment variable --local-ts <subnet> additional traffic selector to propose for our side --remote-ts <subnet> traffic selector to propose for remote side --ike-proposal <proposal> a single IKE proposal to offer instead of the default --esp-proposal <proposal> a single ESP proposal to offer instead of the default --ah-proposal <proposal> a single AH proposal to offer instead of the default --profile <name> authentication profile to use, where name is one of: ikev2-pub, ikev2-eap, ikev2-pub-eap ikev1-pub[-am], ikev1-xauth[-am], ikev1-xauth-psk[-am], ikev1-hybrid[-am][root@lpic303-rocky34 ~]#
  • /usr/sbin/charon-systemd
    charonのsystemd用のプログラム

  • /usr/sbin/strongswan

[root@lpic303-rocky34 ~]#[root@lpic303-rocky34 ~]# strongswan --helpstrongswan command [arguments]Commands: start|restart [arguments] update|reload|stop up|down|route|unroute <connectionname> down-srcip <start> [<end>] status|statusall [<connectionname>] listalgs|listpubkeys|listcerts [--utc] listcacerts|listaacerts|listocspcerts [--utc] listacerts|listgroups|listcainfos [--utc] listcrls|listocsp|listplugins|listall [--utc] listcounters|resetcounters [name] leases [<poolname> [<address>]] rereadsecrets|rereadcacerts|rereadaacerts rereadocspcerts|rereadacerts|rereadcrls|rereadall purgecerts|purgecrls|purgeike|purgeocsp pki stroke versionRefer to the strongswan(8) man page for details.Some commands have their own man pages, e.g. pki(1).[root@lpic303-rocky34 ~]#
  • /usr/sbin/swanctl
    charonデーモンを操作するコマンド

[root@lpic303-rocky34 ~]#[root@lpic303-rocky34 ~]# swanctl --helpstrongSwan 5.9.10 swanctlloaded plugins: pkcs11 aesni aes des rc2 sha2 sha1 md4 md5 mgf1 random nonce x509 revocation constraints acert pubkey pkcs1 pkcs7 pkcs12 pgp dnskey sshkey pem openssl gcrypt pkcs8 fips-prf gmp curve25519 chapoly xcbc cmac hmac kdf ctr ccm gcm drbg newhope curlusage: swanctl --reload-settings (-r) reload daemon strongswan.conf swanctl --stats (-S) show daemon stats information swanctl --version (-v) show version information swanctl --log (-T) trace logging output swanctl --load-pools (-a) (re-)load pool configuration swanctl --load-creds (-s) (re-)load credentials swanctl --load-conns (-c) (re-)load connection configuration swanctl --load-authorities (-b) (re-)load authority configuration swanctl --load-all (-q) load credentials, authorities, pools and connections swanctl --flush-certs (-f) flush cached certificates swanctl --list-algs (-g) show loaded algorithms swanctl --list-pools (-A) list loaded pool configurations swanctl --list-certs (-x) list stored certificates swanctl --list-conns (-L) list loaded configurations swanctl --list-authorities (-B) list loaded authority configurations swanctl --list-pols (-P) list currently installed policies swanctl --monitor-sa (-m) monitor for IKE_SA and CHILD_SA changes swanctl --list-sas (-l) list currently active IKE_SAs swanctl --install (-p) install a trap or shunt policy swanctl --uninstall (-u) uninstall a trap or shunt policy swanctl --redirect (-d) redirect an IKE_SA swanctl --rekey (-R) rekey an SA swanctl --terminate (-t) terminate a connection swanctl --initiate (-i) initiate a connection swanctl --counters (-C) list or reset IKE event counters swanctl --help (-h) show usage information[root@lpic303-rocky34 ~]#

参考

WireGuardサーバとクライアントを設定・操作

WireGuardとは

VPNを実現するオープンソースソフトウェア
設定がシンプル

インストール

  • RockyLinux 9

[root@lpic303-rocky34 ~]#[root@lpic303-rocky34 ~]# dnf install wireguard-tools[root@lpic303-rocky34 ~]#
  • Ubuntu 22.04

root@lpic303-ubuntu35:~#root@lpic303-ubuntu35:~# apt install wireguardroot@lpic303-ubuntu35:~# apt install wireguard-toolsroot@lpic303-ubuntu35:~#

設定ファイル

/etc/wireguard/*

コマンド

[root@lpic303-rocky34 ~]#[root@lpic303-rocky34 ~]# wg --helpUsage: wg <cmd> [<args>]Available subcommands: show: Shows the current configuration and device information showconf: Shows the current configuration of a given WireGuard interface, for use with `setconf' set: Change the current configuration, add peers, remove peers, or change peers setconf: Applies a configuration file to a WireGuard interface addconf: Appends a configuration file to a WireGuard interface syncconf: Synchronizes a configuration file to a WireGuard interface genkey: Generates a new private key and writes it to stdout genpsk: Generates a new preshared key and writes it to stdout pubkey: Reads a private key from stdin and writes a public key to stdoutYou may pass `--help' to any of these subcommands to view usage.[root@lpic303-rocky34 ~]#
  • wg genkey
    秘密鍵を作成する

  • wg pubkey
    秘密鍵に対応する公開鍵を作成する

  • wg showconf
    設定を表示する
    リダイレクトして設定ファイルとして保存する
    設定ファイルは/etc/wireguard/<NIC名>.conf とする

  • wg-quick<NIC名>
    設定ファイルを読み取ってVPN接続を開始/終了する

参考

L2TPの知識

L2TPとは

  • Layer 2 Tunneling Protocol

  • 交渉、認証、通知、監視の機能を持つPPP(Point-to-Point Protocol)をデータリンク層(Layer2)でカプセル化するプロトコル

  • データの暗号化機能はないため、IPSecを併用する L2TP/IPSec が使われる

  • 1701/UDP を使う

コマンド

  • ip l2tp add tunnel

  • ip l2tp add session

  • ip l2tp del tunnel

  • ip l2tp del session

  • ip l2tp show tunnel

  • ip l2tp show session

参考

334.4 バーチャルプライベートネットワーク(VPN)|sakuzo_books (2024)

FAQs

プライベートVPNとは何ですか? ›

VPN(Virtual Private Network)とは、あるネットワークの中に、別のプライベートなネットワークを仮想的に作り出す技術のことです。 VPNによって1つのネットワークの中に個別の仮想的なネットワークを用意することで、各ユーザは擬似的に自分専用のネットワークがあるかのように通信を行うことが出来ます。

Google pixelのVPNをオフにするには? ›

VPN を無効にするには:
  1. スマートフォンの設定アプリを開きます。
  2. [ネットワークとインターネット] [VPN] [Google One VPN] をタップします。
  3. [VPN を使用する] をオフにします。

GoogleのVPN接続のやり方は? ›

Google One VPN をオンにする
  1. Google アカウントにログインしていることを確認します。
  2. Android デバイスで Google One アプリ を開きます。
  3. 画面下部の [特典] をタップします。
  4. VPN 特典を見つけて [詳細を表示] をタップします。
  5. VPN をオンにします。

ChromebookでVPNに接続するにはどうすればいいですか? ›

[設定]アプリを起動しておき、①[ネットワーク]にある②[接続を追加]をクリックする。 続いて③[OpenVPN/L2TPを追加]をクリック。 [VPNネットワークへの接続]画面が表示されるので、それぞれの項目を入力・選択し、最後に④[接続]をクリックする。

VPN接続サービスとは何ですか? ›

VPN接続とは、インターネット上に仮想の専用線を設定し、特定の人のみが利用できる専用ネットワークです。 専用のルーター間だけでなく、最近では端末間、アプリ単位で相互通信をおこなうことができます。

VPNクライアントはどのように保護されますか? ›

VPNクライアントはVPNプロトコルを使って、あなたのデバイスと選択したVPNサーバーの間に暗号化された「トンネル」を作ります。 その時点で、あなたとVPNサーバー間のすべてのオンライントラフィックは暗号化され、覗き見から保護されます

VPNは設定したほうがいいですか? ›

VPNを利用することで、インターネット接続時のセキュリティを高めることができます。 情報セキュリティ対策をしていない場合は、インターネット通信時に悪意の第三者によって情報を閲覧したり盗んだりしやすい状態になっています。 しかしVPNを使えば、やり取りするデータを簡単に閲覧・解読できないようにすることが可能です。

VPNを入れないとどうなる? ›

VPNを使用しない場合、通信自体を外部から除き見ることが可能で、特に公衆Wi-Fi(駅などにある無料Wi-Fi)は、不特定多数の人が同じネットワークで通信しているため、悪意のあるユーザがいれば、通信の内容を傍受することができてしまいます。

GoogleoneのVPNは日本でも使えますか? ›

Google OneのVPNは、2020年10月に提供が開始されたサービス。 日本でも2022年に利用可能となりました。 VPNというと、接続元を偽って海外のサービスを利用するために使われることもありますが、Google OneのVPNはそういった用途を想定したものではなく、セキュリティを高めるためのもの。

Google VPNが使える国はどこですか? ›

Google One VPNが利用できると地域
  • オーストリア
  • オーストラリア
  • ベルギー
  • カナダ
  • デンマーク
  • フィンランド
  • フランス
  • ドイツ
Feb 20, 2023

Google One VPNは中国でも使えますか? ›

Google Oneの提供対象ではない中国やロシアでは、Google One VPNも利用できません

パソコンでVPN接続するにはどうすればいいですか? ›

[Windows 設定] ページから VPN接続します。
  1. [スタート] > [設定] > [ネットワーク & インターネット> VPN] を選択します 。
  2. 使用する VPN 接続の横にある [接続] を選択 します。
  3. メッセージが表示されたら、ユーザー名とパスワード、またはその他のサインイン情報を入力します。

Chromebookで非公開ネットワークに接続するにはどうすればいいですか? ›

非公開ネットワークに接続する
  1. Chromebook で右下の時刻を選択します。
  2. Wi-Fi をオンにしてネットワークに接続します。
  3. ネットワークをもう一度選択して [設定] を開きます。
  4. [非公開ネットワーク] をオンにします。 この設定をオンにすると、非公開ネットワークを探して接続できるようになります。

VPNは繋ぎっぱなしにするべき? ›

「VPNには常時接続するべき?」という問いに一言で答えるのであれば、答えは「はい」です。 仮想プライベートネットワーク(VPN)に接続することで、オンラインセキュリティとプライバシーが確保され、盗聴やハッキングからデータが保護されるからです

VPNがダメな理由は何ですか? ›

VPN導入で発生しうる問題点

VPN導入でよくある問題点は、専用線から切り替えたことで通信の詰まりが発生してしまい通信速度が遅くなることです。 コストを下げるために専用線からVPNに切り替えた結果、仕事の効率が悪くなる、業務に支障をきたしてしまうなどがあっては、下がったコスト以上の損害が発生してしまいかねません。

VPNは常にオンにしたほうがいいですか? ›

VPNをオフにすると、セキュリティリスクやプライバシー侵害のリスクが高まってしまいます。 そのため、フリーWi-Fiなどのセキュリティリスクの高い環境や、決済情報などの大事な情報を送信する場合は、VPNをオン(常時接続)にしておくことがおすすめです

VPNはどこまで暗号化されますか? ›

接続先(WebサイトではなくVPNの接続先)との通信がすべて暗号化されるため、ブラウザ以外のアプリケーションなどの通信も暗号化されます。 VPN接続にはIDや事前共有キーの入力が求められることからわかる通り、限られた人しか接続できないこともポイントです。

VPN設定は必要ですか? ›

VPNの必要性は個人の状況とニーズに依存しますが、フリーWi-Fiを頻繁に利用する人やテレワークを行う人にとっては重要なセキュリティツールです。 ただし、VPNが必須であるわけではありません。 自宅でのインターネット利用や重要な情報の送信が少なければ、VPNは不要かもしれません。

VPN設定は違法ですか? ›

VPNの利用を違法としているのは、ロシア、ベラルーシ、北朝鮮、イラクで、中国も認可されたVPN利用以外は違法としている。 VPNの利用は合法であるものの、VPNを使って違法な行為や不道徳な行為などを禁止しているのが、エジプト、トルコ、アラブ首長国連邦。

VPNを許可するとどうなる? ›

では、VPNをオンにするとどうなるのでしょうか? 一言で言うと、VPNをオンにすることでインターネットトラフィックが暗号化され、第三者やサイバー犯罪者から個人情報を保護し、プライバシーとセキュリティを格段に向上させることができます

VPNとは何か?デメリットは? ›

VPNの導入には、「セキュアな通信環境が構築できる」「テレワークが導入しやすい」といったメリットがあります。 一方で「専用線に比べて安全、安定性が劣る場合がある」「適切なサービスを選ぶのが難しい」というデメリットも存在します。 自社の要件に適していないサービス内容では、適切なセキュリティ対策はできません。

VPNは何のために使用しますか? ›

VPNとは、インターネット上に特定の人だけが使える仮想の専用回線を構築する情報通信技術の1つです。 データの送受信間に仮想のトンネルを作り(トンネリング)、それを使って通信を行います。 トンネルは盗聴・改ざんといった脅威から情報を守ることが可能です。 さらに、送受信の「認証」を行い通信内容を「暗号化」します。

スマホでVPNとは何ですか? ›

VPNとは仮想プライベートネットワーク、日本語では仮想専用線とも呼ばれている、安全にデータ通信をするために開発された技術です。 インターネットとスマホやパソコンの間を、仮想専用線でトンネルのようにつなぐことで、悪意のある第三者からの侵入や攻撃を防ぎます。

Top Articles
Latest Posts
Article information

Author: Lidia Grady

Last Updated:

Views: 6271

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Lidia Grady

Birthday: 1992-01-22

Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

Phone: +29914464387516

Job: Customer Engineer

Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.