涛子 - 简单就是美

成单纯魁增,永继振国兴,克复宗清政,广开家必升

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  428 随笔 :: 0 文章 :: 19 评论 :: 22万 阅读

host01

# podman run -d --name container1 alpine:latest /bin/sh -c "while true; do sleep 3600; done"
# podman run -d --name container2 alpine:latest /bin/sh -c "while true; do sleep 3600; done"

# podman inspect --format '{{.NetworkSettings.IPAddress}}' container1
10.88.0.5
# podman inspect --format '{{.NetworkSettings.IPAddress}}' container2
10.88.0.6

host02

# podman run -d --name container1 alpine:latest /bin/sh -c "while true; do sleep 3600; done"
# podman run -d --name container2 alpine:latest /bin/sh -c "while true; do sleep 3600; done"

# podman inspect --format '{{.NetworkSettings.IPAddress}}' container1
10.88.0.2
# podman inspect --format '{{.NetworkSettings.IPAddress}}' container2
10.88.0.3

ping

host1

# podman exec -it container1 sh
ping 10.88.0.2

host1 create ovs bridge & a veth pair

# ovs-vsctl add-br br-int
# ovs-vsctl show
537902fd-0a24-44f5-bcb9-9155fd18c7c4
    Bridge br-int
        Port br-int
            Interface br-int
                type: internal
    ovs_version: "2.12.0"

# ip link add veth0 type veth peer name veth1

# ovs-vsctl add-port br-int veth1

# brctl addif cni-podman0 veth0

# ip link set veth1 up
# ip link set veth0 up
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:25:66:c8 brd ff:ff:ff:ff:ff:ff
3: cni-podman0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether f6:7c:c9:e6:9c:a4 brd ff:ff:ff:ff:ff:ff
7: veth0faccefd@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master cni-podman0 state UP mode DEFAULT group default 
    link/ether 16:58:99:23:9d:ba brd ff:ff:ff:ff:ff:ff link-netns cni-25bfae2e-3338-bab3-ed63-ab93e40a26a5
8: veth72aa311e@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master cni-podman0 state UP mode DEFAULT group default 
    link/ether 2a:9d:b1:0c:f9:d8 brd ff:ff:ff:ff:ff:ff link-netns cni-251f4712-29e8-e5fc-6e0b-150307cd351a
9: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 16:c0:ed:6a:80:70 brd ff:ff:ff:ff:ff:ff
10: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 36:ba:2b:43:b9:49 brd ff:ff:ff:ff:ff:ff
11: veth1@veth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UP mode DEFAULT group default qlen 1000
    link/ether 8a:1a:4b:b3:dd:33 brd ff:ff:ff:ff:ff:ff
12: veth0@veth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master cni-podman0 state UP mode DEFAULT group default qlen 1000
    link/ether aa:65:f7:84:05:03 brd ff:ff:ff:ff:ff:ff

host2 create ovs bridge & a veth pair

# ovs-vsctl add-br br-int
# ip link add veth0 type veth peer name veth1
# ovs-vsctl add-port br-int veth1
# brctl addif cni-podman0 veth0
# ip link set veth1 up
# ip link set veth0 up

GRE tunnel between host1 & host2

host1
# ovs-vsctl add-port br-int gre0 -- set interface gre0 type=gre options:remote_ip=10.0.0.2

host2
# ovs-vsctl add-port br-int gre0 -- set interface gre0 type=gre options:remote_ip=10.0.0.1

# ovs-vsctl show
537902fd-0a24-44f5-bcb9-9155fd18c7c4
    Bridge br-int
        Port "veth1"
            Interface "veth1"
        Port br-int
            Interface br-int
                type: internal
        Port "gre0"
            Interface "gre0"
                type: gre
                options: {remote_ip="10.0.0.2"}
    ovs_version: "2.12.0"

# brctl show
bridge name	bridge id		STP enabled	interfaces
cni-podman0		8000.f67cc9e69ca4	no		veth0
							veth0faccefd
							veth72aa311e

test

host1
# podman exec -it container1 sh
ping 10.88.0.2
posted on   北京涛子  阅读(126)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示