Home
Packages
Forums
Wiki
GitLab
Security
AUR
Download
コンテンツにスキップ
メインメニュー
メインメニュー
サイドバーに移動
非表示
案内
メインページ
目次
コミュニティに貢献
最近の出来事
おまかせ表示
特別ページ
交流
ヘルプ
貢献
最近の更新
最近の議論
新しいページ
統計
リクエスト
ArchWiki
検索
検索
表示
アカウント作成
ログイン
個人用ツール
アカウント作成
ログイン
VPN over SSHのソースを表示
ページ
議論
日本語
閲覧
ソースを閲覧
履歴を表示
ツール
ツール
サイドバーに移動
非表示
操作
閲覧
ソースを閲覧
履歴を表示
全般
リンク元
関連ページの更新状況
ページ情報
表示
サイドバーに移動
非表示
←
VPN over SSH
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、次のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
[[Category: Virtual Private Network]] [[Category:Secure Shell]] [[en:VPN over SSH]] [[pt:VPN over SSH]] {{Related articles start}} {{Related|ネットワーク設定}} {{Related|ルーター}} {{Related|Secure Shell}} {{Related articles end}} SSH 経由で Virtual Private Network をセットアップする方法は複数あります。ときとして役に立つことはありますが、通常の VPN を完全に置き換えることはできないので注意してください。詳しくは [http://sites.inka.de/bigred/devel/tcp-tcp.html] を参照。 == badvpn の tun2socks を使う == {{Note|badvpn プロジェクトは 2022 年 8 月に廃止されており、最新の安定版リリースは 2015 年 4 月のものです}} {{Pkg|badvpn}}は、VPN 関連の様々なユースケースに対応したユーティリティの集合体です。 === Start SSH dynamic SOCKS proxy === First, we will set up a normal SSH dynamic socks proxy like usual: $ ssh -TND 4711 <your_user>@<SSH_server> === badvpn とトンネルインターフェイスをセットアップする === Afterwards, we can go ahead with setting up the TUN. # ip tuntap add dev tun0 mode tun user <your_local_user> # ip addr replace 10.0.0.1/24 dev tun0 # badvpn-tun2socks --tundev tun0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr localhost:4711 Now you have a working local {{Ic|tun0}} interface which routes all traffic going into it through the SOCKS proxy you set up earlier. === Get traffic into the tunnel === All that's left to do now is to set up a local route to get some traffic into it. Let us set up a route that routes all traffic into it. We will need three routes: # Route that goes to the SSH server that we use for the tunnel with a low metric. # Route for DNS server (because tun2socks does not do UDP which is necessary for DNS) with a low metric. # Default route for all other traffic with a higher metric than the other routes. The idea behind setting the metrics specifically is because we need to ensure that the route picked to the SSH server is always direct because otherwise it would go back into the SSH tunnel which would cause a loop and we would lose the SSH connection as a result. Apart from that, we need to set an explicit DNS route because tun2socks does not tunnel UDP (required for DNS). We also need a new default route with a lower metric than your old default route so that traffic goes into the tunnel at all. With all of that said, let us get to work: # ip route add <IP_of_SSH_server> via <IP_of_original_gateway> metric 5 # ip route add <IP_of_DNS_server> via <IP_of_original_gateway> metric 5 # ip route add default via 10.0.0.2 metric 6 Now all traffic (except for DNS and the SSH server itself) should go through {{Ic|tun0}}. == OpenSSH 内蔵のトンネリング == OpenSSH には TUN/TAP サポートが組み込まれており {{ic|-w<local-tun-number>:<remote-tun-number>}} で使用します。ここではレイヤー3 (point-to-point) TUN トンネルを作る方法を説明します。レイヤー2 (ethernet) TAP トンネルを作成することも可能です。 === systemd-networkd を使って tun インターフェイスを作成 === 以下のファイルを作成してください: {{hc|/etc/systemd/network/vpn.netdev|2= [NetDev] Name=tun5 Kind=tun [Tun] User=vpn Group=network }} {{hc|/etc/systemd/network/vpn.network|2= [Match] Name=tun5 [Address] Address=192.168.200.2/24 }} 作成したら {{ic|systemd-networkd.service}} を[[再起動]]して有効化してください。 {{ic|ip tunnel}} コマンドで tun インターフェイスを管理することができます。 ==== SSH コマンドでインターフェイスを作成 ==== SSH は両方のインターフェイスを自動的に作成しますが、接続が確立した後に IP とルーティングを設定する必要があります: $ ssh -o PermitLocalCommand=yes \ -o LocalCommand="sudo ifconfig tun5 192.168.244.2 pointopoint 192.168.244.1 netmask 255.255.255.0" \ -o ServerAliveInterval=60 \ -w 5:5 vpn@example.com \ 'sudo ifconfig tun5 192.168.244.1 pointopoint 192.168.244.2 netmask 255.255.255.0; echo tun0 ready' === SSH の起動 === $ ssh -f -w5:5 vpn@example.com -i ~/.ssh/key "sleep 1000000000" あるいは NAT を使用している場合、keep-alive オプションを追加します: $ ssh -f -w5:5 vpn@example.com \ -o ServerAliveInterval=30 \ -o ServerAliveCountMax=5 \ -o TCPKeepAlive=yes \ -i ~/.ssh/key "sleep 1000000000" === トラブルシューティング === * ssh に tun インターフェイスへアクセス・作成する権限が必要です。tun インターフェイスや {{ic|/dev/net/tun}} の所有者を確認してください。 * シングルマシンではなくネットワークにアクセスしたい場合は IP パケットフォワーディング、ルーティング、両方のファイアウォールを設定する必要があります。 == PPP over SSH を使う == [[pppd]] を使用することで簡単に SSH サーバー経由のトンネルを作成できます: # pppd updetach noauth silent nodeflate pty "/usr/bin/ssh root@remote-gw /usr/sbin/pppd nodetach notty noauth" ipparam vpn 10.0.8.1:10.0.8.2 VPN が確立されたら、トラフィックを転送することができます。内部ネットワークにアクセスするには: # ip route add 192.168.0.0/16 via 10.0.8.2 暗号化されていないネットワークでの通信を保護するために、全てのインターネット通信をトンネル経由で転送するには、通常のゲートウェイ経由で SSH サーバーのルーティングを追加します: # ip route add <remote-gw> via <current default gateway> それから、デフォルトのルーティングをトンネルで置き換えてください: # ip route replace default via 10.0.8.2 === ヘルパースクリプト === [https://github.com/halhen/pvpn pvpn] は {{ic|pppd}} over SSH を使うためのラッパースクリプトです。{{AUR|pvpn}} パッケージでインストールできます。 == 参照 == * {{AUR|sshuttle-git}} - [[python]] トンネル
このページで使用されているテンプレート:
テンプレート:AUR
(
ソースを閲覧
)
テンプレート:Hc
(
ソースを閲覧
)
テンプレート:Ic
(
ソースを閲覧
)
テンプレート:Note
(
ソースを閲覧
)
テンプレート:Pkg
(
ソースを閲覧
)
VPN over SSH
に戻る。
検索
検索
VPN over SSHのソースを表示
話題を追加