1. 程式人生 > 實用技巧 >容器網路專題(一)

容器網路專題(一)

本期重點 認識

veth - Virtual Ethernet Device

The veth devices are virtual Ethernet devices. They can act as tunnels between network namespaces to create a bridge to a physical network device in another namespace, but can also be used as standalone network devices.

像隧道一樣連線 不同的 netns 。隧道中不會對資料包進行修改

自核心3.8以後 linux 定義了6大名稱空間

UTS 主機和域名

IPC 訊號量、訊息佇列和共享內容

PID 程序編號

network 網路裝置、網路棧、埠等

mount 掛載點(檔案系統)

user 使用者和使用者組

clone() setns() unshare() 三個 系統函式定義了 名稱空間三個基礎操作

veth 與其中 network ns 緊密相關

實操

ip link add veth0 type veth peer name veth1
ip link list
ip link set dev veth0 up
ip link set dev veth1 up
ifconfig
ifconfig  veth0 172.13
.0.1/24 ifconfig ip netns add song ip link set veth1 netns song ifconfig