0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【2024年08月版】Linux namespace 体験メモ【初学者向け、教育資料、namespace】

Last updated at Posted at 2024-08-31

はじめに

Linux の namespace機能を使って仮想的なネットワーク接続を体験するメモ

初学者向け

Linux 1台でできるので、お手軽にネットワークの基礎を学べます

環境準備

  • Ubuntu22.04などのLinuxを1台準備します

手順

  • 2つのPCを同一のセグメント(10.11.12.0/24)に配置します
  • 2つのPC間でPingのやり取りができることを確認します
sudo ip netns add testns01
sudo ip netns add testns02
sudo ip netns list
sudo ip link add testns02-veth0 type veth peer name testns01-veth0
sudo ip link
sudo ip link set testns01-veth0 netns testns01
sudo ip link set testns02-veth0 netns testns02
sudo ip netns exec testns01 ip link
sudo ip netns exec testns02 ip link
sudo ip netns exec testns01 ip a add 10.11.12.1/24 dev testns01-veth0
sudo ip netns exec testns02 ip a add 10.11.12.2/24 dev testns02-veth0
sudo ip netns exec testns01 ip link set testns01-veth0 up
sudo ip netns exec testns02 ip link set testns02-veth0 up
sudo ip netns exec testns01 ip link set lo up
sudo ip netns exec testns02 ip link set lo up
sudo ip netns exec testns01 ping 10.11.12.2
sudo ip netns exec testns02 ping 10.11.12.1
sudo ip netns exec testns01 ping 10.11.12.1
sudo ip netns exec testns02 ping 10.11.12.2

さいごに

かんたんでしたね

関連リンク

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?