无浮动IP的虚机出公网流量路径

女主宣言

通过Neutron构建网络时涉及的知识点比较广,虚拟化网络实施上又具有非常大的灵活性,这往往会让刚接触的同学摸不着头脑。本文特意对"无浮动IP的虚机出公网流量路径"这一场景进行分享,该场景的链路相对比较长,涉及到的知识点比较全,没有硬件厂商的绑定,具有通用性,同时对涉及到的组件和知识点进行简要介绍,希望能给对虚拟化网络感兴趣的同学一些帮助。

PS:丰富的一线技术、多元化的表现形式,尽在“360云计算”,点关注哦!

1

拓扑和流量路径

拓扑:

本场景流量路径:

流量路径是图中U字顺序, 具体实现和社区版有些区别。

2

网络知识点回顾

对VLAN/VXLAN,DVR,OSPF,ARP,OVS, namespace,bridge这些关键字比较熟悉的同学,阅读起来可能会比较轻松,如果不熟悉也不必担心,我们会在这部分回顾一下这些基础的知识点,然后在第三部分分步抓包加深理解。

OSI七层模型

在本次我们重点关注L2数据链路层和L3网络层这2层。

VLAN报文格式

基于802.1Q的VLAN帧格式。

  • VLAN ID取值范围为1~4094。

  • LAN 一个LAN表示一个广播域,LAN中的所有成员都会收到LAN中1个成员发出的广播包 VLAN 表示 Virutal LAN。一个带有 VLAN 功能的交换机能够同时处于多个 LAN 中。

  • Access类型的端口只能属于1个VLAN。

  • Trunk类型的端口可以属于多个VLAN,可以接收和发送多个VLAN的报文。

VXLAN报文格式

VXLAN是将以太网报文封装在UDP传输层上的一种隧道转发模式(ovs默认使用4798)。

  • VXLAN 在 VTEP间建立隧道,通过 Layer 3 网络(外部网络)传输封装后的 Layer 2 数据,最外层的 IP/UDP 协议报文用来在底层网络上传输。

  • 中间是VXLAN 头部,vtep 接受到报文之后,去除前面的 IP/UDP 协议部分,根据这部分来处理vxlan 的逻辑,主要是根据VNI 发送到最终的虚拟机。

  • 最里面是原始的报文,也就是虚拟机看到的报文内容。

  • 封装会增加50Bytes的overhead。

ARP(Address Resolution Protocol )

ARP协议是用来将IP地址解析为MAC地址的协议,分为:

  • 静态ARP

  • 免费arp

            IP地址冲突检测。

            用于通告一个新的MAC地址。

  • 动态arp

            动态ARP通过广播ARP请求和单播ARP应答这两个过程完成地址解析。

            网桥/网卡自动学习,维护生命周期。

  • proxy arp

常用命令:

ip neigh/ arp -n
ovs-appctl fdb/show br-int
brctl showmacs <bridge_name>

策略路由(PBR)

可以依据用户自定义的策略进行报文转发。

Tips:

  • 默认表0, 32766(默认main), 32767 3个优先级已被占用。

  • 数值越小优先级别越高。

网络namespace

用来实现隔离的一套机制,不同 namespace 中的资源之间彼此不可见 namespace中拥有独立的网络栈(网卡、路由转发表、iptables)。一个设备(Linux Device)只能位于1个namespace中。不同namespace中的设备可以利用veth pair进行桥接。

常见namespace:fip-xxx、qrouter-xxx、snat-xxx、qdhcp-xxx。

命令:

ip netns # 查看
ip netns exec ns1  ip addr # 执行命令

Neutron基本概念

网络:隔离的 L2 域,可以是虚拟、逻辑或交换。

子网:隔离的 L3 域,IP 地址段。其中每个机器有一个 IP,同一个子网的主机彼此 L3 可见。

端口:网络上虚拟、逻辑或交换端口。所有这些实体都是虚拟的,拥有自动生成的唯一标识id,支持CRUD功能,并在数据库中跟踪记录状态。

OVS(Openvswitch)

Openvswitch是一个虚拟交换软件。

一个虚拟交换机主要有2个作用:

  • 传递虚拟机之间的流量。

  • 实现虚拟机与外界网络的通讯。

OVS网桥:

  • br-int:bridge-integration,综合网桥,常用于表示实现主要内部网络功能的网桥。

  • br-ex:bridge-external,外部网桥,通常表示负责跟外部网络通信的网桥。

  • br-tun: bridge-tunnel,隧道网桥。

OVS流表:

   匹配:

  • 数值越大优先级越高。

  • 根据端口号匹配。

  • 根据来源MAC/目的MAC匹配。

  • 根据协议来下匹配。

   动作:

  • NORMAL(普通二层交互)。

  • resubmit。

  • output到某个端口。

  • drop。

  • learn。

  • 修改mac, 打/剥离vlan/tunnel。

Iptables

表(tables)提供特定的功能,内置的表: nat, filter, mangle。链(chains)是数据包传播的路径。

  • 自定义chain没有自定义策略。

  • 动作执行完以后,就不再继续匹配其他同链的规则动作了。

  • 策略由不同的规则(rule)串联而成, 规则的本质是对进入的IP报文进行说明。

  • 匹配(符合什么条件):nterface/目的地址/源地址/协议/状态/...

  • 动作(做什么处理):accept、drop、reject、return(继续父链的调用处的下一条)、DNAT(--to-destination)、SNAT。

DVR 分布式虚拟路由

目的: 降低网络节点的负载。

核心解决方式:

  • 通过流表规则解决多个路由器mac冲突的问题。

  • 让本地的请求找到本地的路由器(ARP)。

  • 要避免路由器的接口mac 地址直接暴露到外部网络上, 通过流表拦截此MAC。

  • 从 neutron server 上申请唯一 MAC 地址,通过流表替换进出流量的MAC地址。

说明:

  • 分布到多个计算节点上的 qrouter 的interface 的 MAC 地址都相同。

  • OVS flows 需要更新来支持 DVR。

  • 虚拟机启动时port转为active时,会rpc通知neutron agent更新规则。

  • 南北SNAT流量依然需要经过网络节点。

  • 有floating IP的南北流量直接从compute节点流出。

  • 公司内的DVR和社区版有些区别。

  • Neutron L2 Agent承担使用iptables维护链和规则的任务。

  • L3 agent iptables subnet之间的路由服务。

neutron DVR部署设置:

  • 网络节点和计算节点都部署L2和L3 agent。

  • compute dvr 为 dvr,network节点为 dvr_snat。

  • l2_population = True。

  • router_distributed = True。

OSPF

Open Shortest Path First 开放式最短路径优先,OSPF通过路由器之间通告网络接口的状态来建立链路状态数据库,生成最短路径树,每个OSPF路由器使用这些最短路径构造路由表。

作用:

  • 通告虚拟机的浮动IP。

  • 通告VPC公网互联的SNAT IP。

neutron-l3-agent启动fip-xxx的namespace和接入交换机运行ospf协议。

常用命令

tcpdump # 抓包
ovs-appctl fdb/show br-int # 查看ovs mac表
ip rule list # 查看策略列表
ip route list table table_name # 查看某个策略路由
ovs-ofctl dump-ports-desc br-int # 查看网桥端口
ovs-ofctl dump-flows br-int # 查看流表
brctl showmacs <bridge> # 查看linux网桥学习到的mac
ovs-appctl fdb/show br-int  # 查看OVS网桥学习到的mac

3

各节点抓包记录

结合第二部分的基础概念,下来我们按照流量路径顺序抓包来加深印象。

虚拟机内部抓包

[root@Server-be9f76b6 ~]# tcpdump -i eth0 icmp -nnee
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
17:23:29.858571 fa:16:3e:b2:ef:af > fa:16:3e:06:d8:7b, ethertype IPv4 (0x0800), length 142: 192.168.1.7 > 8.8.8.8: ICMP echo request, id 60691, seq 53781, length 108
17:23:29.892335 fa:16:3e:d1:d8:49 > fa:16:3e:b2:ef:af, ethertype IPv4 (0x0800), length 110: 8.8.8.8 > 192.168.1.7: ICMP echo reply, id 60691, seq 53781, length 76
[root@Server-be9f76b6 ~]# ip r l
169.254.169.254 via 192.168.1.1 dev eth0  proto static
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.7
default via 192.168.1.1 dev eth0  proto static
[root@Server-be9f76b6 ~]# ip r g 8.8.8.8
8.8.8.8 via 192.168.1.1 dev eth0  src 192.168.1.7
    cache  mtu 1450 hoplimit 64
[root@Server-be9f76b6 ~]# traceroute -n 8.8.8.8
 1  192.168.1.1  0.178 ms  0.209 ms  0.135 ms
 2  192.168.1.6  0.355 ms  0.352 ms  0.340 ms
 3  169.254.96.33  0.558 ms  0.546 ms  0.531 ms
 4  10.206.221.193  1.459 ms  2.400 ms  1.967 ms
 5  10.206.223.56  1.458 ms 10.206.223.60  1.407 ms 10.206.223.62  1.880 ms
 6  10.206.223.62  2.370 ms 10.206.223.60  2.279 ms  1.749 ms
 (略)
[root@Server-be9f76b6 ~]# ip neigh
192.168.1.6 dev eth0 lladdr fa:16:3e:d1:d8:49 STALE
192.168.1.2 dev eth0 lladdr fa:16:3e:93:a3:f2 STALE
192.168.1.1 dev eth0 lladdr fa:16:3e:06:d8:7b REACHABLE

计算节点抓tap口流量


[root@w07 ~]# tcpdump -i tap2ab77d0f-99 -nnee
listening on tap2ab77d0f-99, link-type EN10MB (Ethernet), capture size 262144 bytes
17:16:11.866127 fa:16:3e:b2:ef:af > fa:16:3e:06:d8:7b, ethertype IPv4 (0x0800), length 142: 192.168.1.7 > 8.8.8.8: ICMP echo request, id 60691, seq 53368, length 108
17:16:11.899884 fa:16:3e:d1:d8:49 > fa:16:3e:b2:ef:af, ethertype IPv4 (0x0800), length 110: 8.8.8.8 > 192.168.1.7: ICMP echo reply, id 60691, seq 53368, length 76
[root@w07 ~]# brctl show
bridge name bridge id       STP enabled interfaces
qbr134a0c76-2f      8000.3286bc9479d4   no      qvb134a0c76-2f
                            tap134a0c76-2f
qbr2ab77d0f-99      8000.966e9ba8b1fc   no      qvb2ab77d0f-99
                            tap2ab77d0f-99
qbr5a70c226-ca      8000.a602f52928ba   no      qvb5a70c226-ca
                            tap5a70c226-ca
qbr8e2a2b2f-ea      8000.ea797eb5b738   no      qvb8e2a2b2f-ea
                            tap8e2a2b2f-ea
[root@w07 ~]# brctl showmacs qbr2ab77d0f-99
port no mac addr        is local?   ageing timer
  1 46:4f:72:0f:95:bf   no        23.98
  1 96:6e:9b:a8:b1:fc   yes        0.00
  1 96:6e:9b:a8:b1:fc   yes        0.00
  2 fa:16:3e:b2:ef:af   no         0.06
  1 fa:16:3e:d1:d8:49   no         0.06
  2 fe:16:3e:b2:ef:af   yes        0.00
  2 fe:16:3e:b2:ef:af   yes        0.00

br-int


[root@w07 ~]# ovs-vsctl show
...
    Bridge br-int
        fail_mode: secure
...
        Port "qvo2ab77d0f-99"
            tag: 10
            Interface "qvo2ab77d0f-99"
        Port "qr-178fc8e2-fd"
            tag: 10
            Interface "qr-178fc8e2-fd"
                type: internal
...
[root@w07 ~]# ovs-appctl fdb/show br-int
 port  VLAN  MAC                Age
   45    10  fa:16:3e:95:02:b6    4
   40    10  fa:16:3e:06:d8:7b    0
    1    10  fa:16:3e:d1:d8:49    0
   23     1  fa:16:3e:4d:50:f1    0
   47     1  fa:16:3e:78:e7:8a    0
   41    10  fa:16:3e:b2:ef:af    0
   24     1  fa:16:3e:0c:69:32    0

在qrouter-xxx的namespace抓包


[root@w07 ~]# ip netns exec qrouter-c4d4b760-41b9-45e1-a607-d054da99c479 tcpdump -i qr-178fc8e2-fd -nnee
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on qr-178fc8e2-fd, link-type EN10MB (Ethernet), capture size 262144 bytes
17:28:46.130180 fa:16:3e:b2:ef:af > fa:16:3e:06:d8:7b, ethertype IPv4 (0x0800), length 142: 192.168.1.7 > 8.8.8.8: ICMP echo request, id 60691, seq 54121, length 108
17:28:46.130209 fa:16:3e:06:d8:7b > fa:16:3e:d1:d8:49, ethertype IPv4 (0x0800), length 142: 192.168.1.7 > 8.8.8.8: ICMP echo request, id 60691, seq 54121, length 108
[root@w07 ~]# ip netns exec qrouter-c4d4b760-41b9-45e1-a607-d054da99c479 ip rule list
0:  from all lookup local
32766:  from all lookup main
32767:  from all lookup default
3232235777: from 192.168.1.1/24 lookup 3232235777
[root@w07 ~]# ip netns exec qrouter-c4d4b760-41b9-45e1-a607-d054da99c479 ip r s t 3232235777
default via 192.168.1.6 dev qr-178fc8e2-fd
[root@w07 ~]# ip netns exec qrouter-c4d4b760-41b9-45e1-a607-d054da99c479 ip neigh
192.168.1.7 dev qr-178fc8e2-fd lladdr fa:16:3e:b2:ef:af PERMANENT
192.168.1.13 dev qr-178fc8e2-fd lladdr fa:16:3e:b6:fb:42 PERMANENT
192.168.1.6 dev qr-178fc8e2-fd lladdr fa:16:3e:d1:d8:49 PERMANENT
192.168.1.10 dev qr-178fc8e2-fd lladdr fa:16:3e:95:02:b6 PERMANENT
192.168.1.3 dev qr-178fc8e2-fd lladdr fa:16:3e:a9:38:b7 PERMANENT
192.168.1.2 dev qr-178fc8e2-fd lladdr fa:16:3e:93:a3:f2 PERMANENT

计算节点br-tun网桥和流表


[root@w07 ~]# ovs-vsctl  show
76001df8-48a5-4185-8de4-a035fc4b2d72
    Bridge br-tun
        fail_mode: secure
        Port "vxlan-0ace6b9c"
            Interface "vxlan-0ace6b9c"
                type: vxlan
                options: {df_default="true", in_key=flow, local_ip="10.206.107.238", out_key=flow, remote_ip="10.206.107.156"}
...
[root@w07 ~]# netstat -nlup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:111             0.0.0.0:*                           12153/rpcbind
udp        0      0 127.0.0.1:323           0.0.0.0:*                           1047/chronyd
udp        0      0 0.0.0.0:874             0.0.0.0:*                           12153/rpcbind
udp        0      0 0.0.0.0:4789            0.0.0.0:*                           -
[root@w07 ~]# ovs-appctl fdb/show br-tun
 port  VLAN  MAC                Age

计算节点eth2抓包


[root@w07 ~]# tcpdump -i eth2 udp -nnee
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth2, link-type EN10MB (Ethernet), capture size 262144 bytes
17:35:05.742902 b4:96:91:5a:31:78 > 5c:c9:99:60:e0:3c, ethertype IPv4 (0x0800), length 192: 10.206.107.238.58650 > 10.206.107.156.4789: VXLAN, flags [I] (0x08), vni 103
fa:16:3f:13:77:c5 > fa:16:3e:d1:d8:49, ethertype IPv4 (0x0800), length 142: 192.168.1.7 > 8.8.8.8: ICMP echo request, id 60691, seq 54500, length 108
17:35:05.776442 5c:c9:99:60:e0:3c > b4:96:91:5a:31:78, ethertype IPv4 (0x0800), length 160: 10.206.107.156.56414 > 10.206.107.238.4789: VXLAN, flags [I] (0x08), vni 103
fa:16:3e:d1:d8:49 > fa:16:3e:b2:ef:af, ethertype IPv4 (0x0800), length 110: 8.8.8.8 > 192.168.1.7: ICMP echo reply, id 60691, seq 54500, length 76
[root@w07 ~]# ip neigh | grep "5c:c9:99:60:e0:3c"
10.206.107.193 dev eth2 lladdr 5c:c9:99:60:e0:3c REACHABLE

网络节点eth2抓包


[root@w02 ~]# tcpdump -i eth2 udp and host 10.206.107.238  -nnee
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth2, link-type EN10MB (Ethernet), capture size 262144 bytes
17:37:16.969152 5c:c9:99:db:69:c9 > b4:96:91:5a:32:54, ethertype IPv4 (0x0800), length 192: 10.206.107.238.58650 > 10.206.107.156.4789: VXLAN, flags [I] (0x08), vni 103
fa:16:3f:13:77:c5 > fa:16:3e:d1:d8:49, ethertype IPv4 (0x0800), length 142: 192.168.1.7 > 8.8.8.8: ICMP echo request, id 60691, seq 54631, length 108
17:37:17.002678 b4:96:91:5a:32:54 > 5c:c9:99:db:69:c9, ethertype IPv4 (0x0800), length 160: 10.206.107.156.56414 > 10.206.107.238.4789: VXLAN, flags [I] (0x08), vni 103
fa:16:3e:d1:d8:49 > fa:16:3e:b2:ef:af, ethertype IPv4 (0x0800), length 110: 8.8.8.8 > 192.168.1.7: ICMP echo reply, id 60691, seq 54631, length 76
17:37:17.970994 5c:c9:99:db:69:c9 > b4:96:91:5a:32:54, ethertype IPv4 (0x0800), length 192: 10.206.107.238.58650 > 10.206.107.156.4789: VXLAN, flags [I] (0x08), vni 103
[root@w02 ~]# ip neigh | grep -E "5c:c9:99:db:69:c9"
10.206.107.129 dev eth2 lladdr 5c:c9:99:db:69:c9 REACHABLE
[root@w02 ~]# netstat -nlup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:45492           0.0.0.0:*                           1630/haproxy
udp        0      0 0.0.0.0:111             0.0.0.0:*                           787644/rpcbind
udp        0      0 127.0.0.1:323           0.0.0.0:*                           794/chronyd
udp        0      0 0.0.0.0:871             0.0.0.0:*                           787644/rpcbind
udp        0      0 0.0.0.0:4789            0.0.0.0:*                           -
udp        0      0 0.0.0.0:8472            0.0.0.0:*                           -

网络节点br-tun网桥和流表


[root@w02 ~]# ovs-vsctl show
c67632e5-75ed-4f73-b4ab-cf32f95a8770
...
    Bridge br-tun
        fail_mode: secure
        Port br-tun
            Interface br-tun
                type: internal
        Port "vxlan-0ace6bee"
            Interface "vxlan-0ace6bee"
                type: vxlan
                options: {df_default="true", in_key=flow, local_ip="10.206.107.156", out_key=flow, remote_ip="10.206.107.238"}
...

网络节点br-int网桥和流表


[root@w02 ~]# ovs-appctl fdb/show br-int
 port  VLAN  MAC                Age
    1    20  fa:16:3e:95:02:b6   28
    1    20  fa:16:3e:b2:ef:af    7
   74    20  fa:16:3e:d1:d8:49    0

snat-xxx的namespace抓包


[root@w02 ~]# ip netns  exec snat-c4d4b760-41b9-45e1-a607-d054da99c479 ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    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
2: rfp-c4d4b760-4@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether 36:66:d5:bf:5e:e0 brd ff:ff:ff:ff:ff:ff
    inet 169.254.96.32/31 scope global rfp-c4d4b760-4
       valid_lft forever preferred_lft forever
    inet 112.65.210.200/32 brd 112.65.210.200 scope global rfp-c4d4b760-4
       valid_lft forever preferred_lft forever
125: sg-499291dc-d8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether fa:16:3e:d1:d8:49 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.6/24 brd 192.168.1.255 scope global sg-499291dc-d8
       valid_lft forever preferred_lft forever
[root@w02 ~]# ip netns  exec snat-c4d4b760-41b9-45e1-a607-d054da99c479 ip r l
default via 169.254.96.33 dev rfp-c4d4b760-4
169.254.96.32/31 dev rfp-c4d4b760-4  proto kernel  scope link  src 169.254.96.32
192.168.1.0/24 dev sg-499291dc-d8  proto kernel  scope link  src 192.168.1.6
[root@w02 ~]# ip netns  exec snat-c4d4b760-41b9-45e1-a607-d054da99c479 ip neigh
192.168.1.7 dev sg-499291dc-d8 lladdr fa:16:3e:b2:ef:af REACHABLE
169.254.96.33 dev rfp-c4d4b760-4 lladdr 82:99:8f:5a:6b:ec DELAY
192.168.1.10 dev sg-499291dc-d8 lladdr fa:16:3e:95:02:b6 STALE
[root@w02 ~]# ip netns exec snat-47c9415f-f30a-4a7c-820d-b7322a064f20 iptables -t nat -S
...
-A neutron-l3-agent-POSTROUTING ! -i rfp-47c9415f-f ! -o rfp-47c9415f-f -m conntrack ! --ctstate DNAT -j ACCEPT
-A neutron-l3-agent-snat -o rfp-47c9415f-f -j SNAT --to-source 112.65.210.208
-A neutron-l3-agent-snat -m mark ! --mark 0x2/0xffff -m conntrack --ctstate DNAT -j SNAT --to-source 112.65.210.208
...

网络节点fip-xxx的namespace


[root@w02 ~]# ip netns exec fip-4617ac50-7b34-4b05-811d-b2afc741d446 ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    ...
4: fpr-c4d4b760-4@fpr-3bbebb1a-5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether 82:99:8f:5a:6b:ec brd ff:ff:ff:ff:ff:ff
    inet 169.254.96.33/31 scope global fpr-c4d4b760-4
       valid_lft forever preferred_lft forever
124: fip-vif.103: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether fa:17:3e:f7:cd:bc brd ff:ff:ff:ff:ff:ff
    inet 10.206.221.195/26 brd 10.206.221.255 scope global fip-vif.103
       valid_lft forever preferred_lft forever
[root@w02 ~]# ip netns exec fip-4617ac50-7b34-4b05-811d-b2afc741d446 netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:2601          0.0.0.0:*               LISTEN      2063367/zebra
tcp        0      0 127.0.0.1:2604

网络节点br-ex网桥


[root@w02 ~]# ovs-vsctl show
c67632e5-75ed-4f73-b4ab-cf32f95a8770
...
    Bridge br-ex
        Port "fip-vif.103"
            tag: 103
            Interface "fip-vif.103"
                type: internal
        Port br-ex
            Interface br-ex
                type: internal
        Port "eth3"
            Interface "eth3"
    ovs_version: "2.5.5"
[root@w02 ~]# ovs-appctl fdb/show br-ex
 port  VLAN  MAC                Age
    1     0  5c:c9:99:60:d2:6e  171
    1   103  fa:17:3e:a7:81:25    8
    5   103  fa:17:3e:f7:cd:bc    0
    1   103  5c:c9:99:60:d2:71    0
    ...

网络节点eth3端口


[root@w02 ~]# tcpdump -i eth3 icmp -nnee
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth3, link-type EN10MB (Ethernet), capture size 262144 bytes
17:54:36.698733 fa:17:3e:f7:cd:bc > 5c:c9:99:60:d2:71, ethertype 802.1Q (0x8100), length 146: vlan 103, p 0, ethertype IPv4, 112.65.210.200 > 8.8.8.8: ICMP echo request, id 60691, seq 55669, length 108
17:54:36.732114 5c:c9:99:60:d2:71 > fa:17:3e:f7:cd:bc, ethertype 802.1Q (0x8100), length 114: vlan 103, p 0, ethertype IPv4, 8.8.8.8 > 112.65.210.200: ICMP echo reply, id 60691, seq 55669, length 76

本文流量路径和社区版本有一些区别,如果对网络感兴趣,建议还是根据实际情况,结合用到的各个知识点自己绘制一次流量路径,再碰到其他的使用场景也就能举一反三了。

360云计算

由360云平台团队打造的技术分享公众号,内容涉及数据库、大数据、微服务、容器、AIOps、IoT等众多技术领域,通过夯实的技术积累和丰富的一线实战经验,为你带来最有料的技术分享

virsh命令是用于管理拟机的命令行工具。要给机配置IP地址,可以按照以下步骤进行操作: 1. 首先,使用virsh命令连接到宿主机的hypervisor。可以使用以下命令连接到本地的QEMU/KVM hypervisor: ``` virsh connect qemu:///system ``` 2. 接下来,使用virsh命令创建一个拟网络,例如名为virbr0的桥接网络。假设我们要为机分配IP地址的范围为192.168.122.2到192.168.122.254,子网掩码为255.255.255.0,可以使用以下命令创建拟网络: ``` virsh net-create <<EOF <network> <name>virbr0</name> <forward mode='nat'/> <bridge name='virbr0' stp='off' delay='0'/> <ip address='192.168.122.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.122.2' end='192.168.122.254'/> </dhcp> </ip> </network> EOF ``` 3. 创建完拟网络后,可以使用virsh命令创建一个拟机,并将其连接到拟网络。例如,使用以下命令创建名为vm1的拟机: ``` virt-install --network network=virbr0,model=virtio --name vm1 --ram 2048 --vcpus 2 --disk path=/path/to/disk.img,size=10 --graphics none --location /path/to/os.iso --extra-args 'console=ttyS0,115200n8 serial' ``` 4. 拟机创建完成后,可以使用virsh命令为机配置静态IP地址。首先,通过以下命令获取拟机的域ID: ``` virsh list --all ``` 然后,使用以下命令配置机的静态IP地址,假设拟机的域ID为1,IP地址为192.168.122.100,可以使用以下命令: ``` virsh domifaddr 1 --domain vm1 --source agent --interface vnet0 --xml ``` 以上就是使用virsh命令配置拟机IP地址的步骤。使用virsh命令进行拟机的管理和配置可以提高拟机的灵活性和可控性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值