• ovs流表机制(四)用vxlan实现同网段通信


    [root@kunpeng82 devuser]# ovs-vsctl show
    25581fe4-f414-4c0a-a9eb-5d04cc658c0c
        Bridge "vswitch0"
            Port "tap3_br"
                Interface "tap3_br"
            Port "vswitch0"
                Interface "vswitch0"
                    type: internal
            Port "tap0_br"
                Interface "tap0_br"
        ovs_version: "2.12.0"
    1、现在在kunpen82节点上配置vxlan
    ovs-vsctl add-port vswitch0 vxlan1 -- set interface vxlan1 type=vxlan options:remote_ip=10.10.18.216 options:key=flow

    [root@kunpeng82 devuser]# ovs-vsctl show
    25581fe4-f414-4c0a-a9eb-5d04cc658c0c
    Bridge "vswitch0"
    Port "tap3_br"
    Interface "tap3_br"
    Port "vswitch0"
    Interface "vswitch0"
    type: internal
    Port "vxlan1"
    Interface "vxlan1"
    type: vxlan
    options: {key=flow, remote_ip="10.10.18.216"}
    Port "tap0_br"
    Interface "tap0_br"
    ovs_version: "2.12.0"

    [root@kunpeng82 devuser]# ovs-ofctl dump-flows vswitch0
    cookie=0x0, duration=776.819s, table=0, n_packets=32, n_bytes=2464, priority=0 actions=NORMAL

    [root@kunpeng82 devuser]# ovs-vsctl get Interface tap3_br ofport
    2
    [root@kunpeng82 devuser]# ovs-vsctl get Interface vxlan1 ofport
    3

    [root@kunpeng82 devuser]# ovs-vsctl get Interface tap0_br ofport
    1

    2、新建一个节点ovs216

    [root@ovs216 ~]# cat test1.sh
    ip netns add ns1
    ip link add tap0 type veth peer name tap0_br
    ip link set tap0 netns ns1
    ovs-vsctl add-br vswitch0
    ip netns exec ns1 ip link set tap0 up
    ip netns exec ns1 ip link set lo up
    ip link set tap0_br up

    
    

    ip netns exec ns1 ip addr add 192.168.1.210/24 dev tap0
    ip netns exec ns1 route add -net 192.168.1.0 netmask 255.255.255.0 dev tap0

    
    

    ovs-vsctl add-port vswitch0 tap0_br

    
    

    ovs-vsctl add-port vswitch0 vxlan1 -- set interface vxlan1 type=vxlan options:remote_ip=10.10.16.81 options:key=flow

    
    

    [root@ovs216 ~]# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
    valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether fa:16:3e:0a:1e:35 brd ff:ff:ff:ff:ff:ff
    inet 10.10.18.216/24 brd 10.10.18.255 scope global noprefixroute dynamic eth0
    valid_lft 65736sec preferred_lft 65736sec
    inet6 fe80::f816:3eff:fe0a:1e35/64 scope link
    valid_lft forever preferred_lft forever
    3: tap0_br@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UP group default qlen 1000
    link/ether be:31:dc:c3:35:36 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::bc31:dcff:fec3:3536/64 scope link
    valid_lft forever preferred_lft forever
    5: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 02:3a:c8:96:dc:3b brd ff:ff:ff:ff:ff:ff
    6: vswitch0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP group default qlen 1000
    link/ether 12:a3:09:cc:11:49 brd ff:ff:ff:ff:ff:ff
    7: vxlan_sys_4789: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65000 qdisc noqueue master ovs-system state UNKNOWN group default qlen 1000
    link/ether 0e:f2:38:5c:be:4c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::cf2:38ff:fe5c:be4c/64 scope link
    valid_lft forever preferred_lft forever


    [root@ovs216
    ~]# ovs-vsctl show 0608fdfe-ab3f-41d8-a439-b0dba68f452b Bridge "vswitch0" Port "vxlan1" Interface "vxlan1" type: vxlan options: {key=flow, remote_ip="10.10.16.82"} Port "tap0_br" Interface "tap0_br" Port "vswitch0" Interface "vswitch0" type: internal ovs_version: "2.12.0"

    [root@ovs216 ~]# ovs-ofctl dump-flows vswitch0
    cookie=0x0, duration=13327.894s, table=0, n_packets=32, n_bytes=1896, priority=0 actions=NORMAL

    
    

    [root@ovs216 ~]# ovs-vsctl get Interface vxlan1 ofport
    2

    [root@ovs216 ~]# ovs-vsctl get Interface tap0_br ofport
    1

     

    [root@ovs216 ~]# ip netns exec ns1 ping 192.168.1.200
    PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data.
    64 bytes from 192.168.1.200: icmp_seq=1 ttl=64 time=0.731 ms
    64 bytes from 192.168.1.200: icmp_seq=2 ttl=64 time=0.291 ms
    ^C
    --- 192.168.1.200 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1028ms
    rtt min/avg/max/mdev = 0.291/0.511/0.731/0.220 ms


    ping通
    [root@kunpeng82 devuser]# ovs-vsctl list interface tap3_br
    _uuid               : 9fe5705c-f864-42e9-87e1-671062bba462
    admin_state         : up
    bfd                 : {}
    bfd_status          : {}
    cfm_fault           : []
    cfm_fault_status    : []
    cfm_flap_count      : []
    cfm_health          : []
    cfm_mpid            : []
    cfm_remote_mpids    : []
    cfm_remote_opstate  : []
    duplex              : full
    error               : []
    external_ids        : {}
    ifindex             : 8
    ingress_policing_burst: 0
    ingress_policing_rate: 0
    lacp_current        : []
    link_resets         : 0
    link_speed          : 10000000000
    link_state          : up
    lldp                : {}
    mac                 : []
    mac_in_use          : "52:85:e1:a0:f2:69"
    mtu                 : 1500
    mtu_request         : []
    name                : "tap3_br"
    ofport              : 2
    ofport_request      : []
    options             : {}
    other_config        : {}
    statistics          : {collisions=0, rx_bytes=3498, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_over_err=0, rx_packets=47, tx_bytes=3918, tx_dropped=0, tx_errors=0, tx_packets=53}
    status              : {driver_name=veth, driver_version="1.0", firmware_version=""}
    type                : ""
  • 相关阅读:
    AUDIOqueue 为什么会播放一段时间就听不到声音
    逆序一位数数组求和
    求数组中两数之和等于target的两个数的下标
    iOS获取崩溃日志
    如何看iOS崩溃日志
    关于iOS刷新UI需要在主线程执行
    iOS内置麦克风选择方法
    贝叶斯深度学习-概述
    空间统计(Spatial Statistics)学习笔记(一)— 概述
    重采样技术—Bootstrap
  • 原文地址:https://www.cnblogs.com/dream397/p/12626646.html
Copyright © 2020-2023  润新知