neutron基础一(网络基本命令)基本命令,包括veth peer

Posted liuhongru

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了neutron基础一(网络基本命令)基本命令,包括veth peer相关的知识,希望对你有一定的参考价值。

  1. ip addr  
  2. ip link  
  3. tcpdump -i veth1 -e -v  
  4. route -n  
  5. ip route  
  6. arp  
  7. ethtool -S veth0  
  8. ip link add type veth  
  9. ip link set dev veth0 up  
  10. ip addr add dev veth0 192.168.3.1/29  
  11. ping -I veth0 192.168.3.2  


[[email protected] ~]# cat /proc/net/dev 
Inter-|   Receive                                                |  Transmit 
face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed 
  eth0: 5166799   58052    0    0    0     0          0         0    46248     356    0    0    0     0       0          0 
    lo:     340       4    0    0    0     0          0         0      340       4    0    0    0     0       0          0 
virbr0-nic:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0 
virbr0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0 
[[email protected] ~]# route -n 
Kernel IP routing table 
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 
0.0.0.0         192.168.128.1   0.0.0.0         UG    0      0        0 eth0 
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0 
192.168.128.0   0.0.0.0         255.255.240.0   U     0      0        0 eth0 
[[email protected] ~]# ip route 
default via 192.168.128.1 dev eth0 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
192.168.128.0/20 dev eth0  proto kernel  scope link  src 192.168.139.55 
[[email protected] ~]# cat /proc/net/route 
Iface   Destination     Gateway         Flags   RefCnt  Use     Metric  Mask            MTU     Window  IRTT                                                       
eth0    00000000        0180A8C0        0003    0       0       0       00000000        0       0       0                                                                               
virbr0  007AA8C0        00000000        0001    0       0       0       00FFFFFF        0       0       0                                                                             
eth0    0080A8C0        00000000        0001    0       0       0       00F0FFFF        0       0       0                                                                               
[[email protected] ~]# arp 
Address                  HWtype  HWaddress           Flags Mask            Iface 
localhost                ether   3c:8c:40:34:a9:28   C                     eth0 
localhost                ether   b0:83:fe:9a:d7:e0   C                     eth0 
[[email protected] ~]# ip neighbor 
192.168.128.1 dev eth0 lladdr 3c:8c:40:34:a9:28 REACHABLE 
192.168.137.27 dev eth0 lladdr b0:83:fe:9a:d7:e0 REACHABLE 
[[email protected] ~]# cat /proc/net/arp 
IP address       HW type     Flags       HW address            Mask     Device 
192.168.128.1    0x1         0x2         3c:8c:40:34:a9:28     *        eth0 
192.168.137.27   0x1         0x2         b0:83:fe:9a:d7:e0     *        eth0 
[[email protected] ~]# netstat -nltpu|grep sshd 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1377/sshd           
tcp6       0      0 :::22                   :::*                    LISTEN      1377/sshd           
[[email protected] ~]# ss -nltp|grep sshd 
LISTEN     0      128          *:22                       *:*                   users:(("sshd",pid=1377,fd=3)) 
LISTEN     0      128         :::22                      :::*                   users:(("sshd",pid=1377,fd=4)) 
[[email protected] ~]# cat /proc/net/tcp 
  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode                                                     
   0: 017AA8C0:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 15557 1 ffff880fe4540000 100 0 0 10 0                     
   1: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 10051 1 ffff880fe3820000 100 0 0 10 0                     
   2: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 27478 1 ffff880fe3878000 100 0 0 10 0                     
   3: 0100007F:0019 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 27743 1 ffff880fe3d18000 100 0 0 10 0                     
   4: 378BA8C0:0016 1B89A8C0:CD20 01 00000060:00000000 01:00000024 00000000     0        0 31998 4 ffff880fe5b70000 36 4 31 8 7                      
[[email protected] ~]# ip -s -s link 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 
    RX: bytes  packets  errors  dropped overrun mcast   
    340        4        0       0       0       0       
    RX errors: length   crc     frame   fifo    missed 
               0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    340        4        0       0       0       0       
    TX errors: aborted  fifo   window heartbeat 
               0        0       0       0       
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 
    link/ether 50:50:18:aa:80:17 brd ff:ff:ff:ff:ff:ff 
    RX: bytes  packets  errors  dropped overrun mcast   
    6137827    69361    0       0       0       0       
    RX errors: length   crc     frame   fifo    missed 
               0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    79639      583      0       0       0       0       
    TX errors: aborted  fifo   window heartbeat 
               0        0       0       0       
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    RX errors: length   crc     frame   fifo    missed 
               0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    0          0        0       0       0       0       
    TX errors: aborted  fifo   window heartbeat 
               0        0       0       0       
4: virbr0-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT qlen 500 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    RX errors: length   crc     frame   fifo    missed 
               0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    0          0        0       0       0       0       
    TX errors: aborted  fifo   window heartbeat 
               0        0       0       0       
[[email protected] ~]# ip address 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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 qlen 1000 
    link/ether 50:50:18:aa:80:17 brd ff:ff:ff:ff:ff:ff 
    inet 192.168.139.55/20 brd 192.168.143.255 scope global dynamic eth0 
       valid_lft 1433sec preferred_lft 1433sec 
    inet6 fe80::5250:18ff:feaa:8017/64 scope link 
       valid_lft forever preferred_lft forever 
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 
       valid_lft forever preferred_lft forever 
4: virbr0-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
[[email protected] ~]# watch -d ip -s -s link 

★★★★★★★★★★★★★★★★★★★★★ 
veth peer 


[[email protected] ~]# ip link add type veth 
[[email protected] ~]# 
[[email protected] ~]# 
[[email protected] ~]# ip link 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 
    link/ether 50:50:18:aa:80:17 brd ff:ff:ff:ff:ff:ff 
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
4: virbr0-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT qlen 500 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
5: [email protected]: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 
    link/ether 96:e2:e3:ed:1d:b9 brd ff:ff:ff:ff:ff:ff 
6: [email protected]: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 
    link/ether 72:7f:5a:c4:7d:1a brd ff:ff:ff:ff:ff:ff 
[[email protected] ~]# ip a 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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 qlen 1000 
    link/ether 50:50:18:aa:80:17 brd ff:ff:ff:ff:ff:ff 
    inet 192.168.139.55/20 brd 192.168.143.255 scope global dynamic eth0 
       valid_lft 1325sec preferred_lft 1325sec 
    inet6 fe80::5250:18ff:feaa:8017/64 scope link 
       valid_lft forever preferred_lft forever 
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 
       valid_lft forever preferred_lft forever 
4: virbr0-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
5: [email protected]: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN qlen 1000 
    link/ether 96:e2:e3:ed:1d:b9 brd ff:ff:ff:ff:ff:ff 
6: [email protected]: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN qlen 1000 
    link/ether 72:7f:5a:c4:7d:1a brd ff:ff:ff:ff:ff:ff 
[[email protected] ~]# ip link set dev veth1 up 
[[email protected] ~]# ip a 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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 qlen 1000 
    link/ether 50:50:18:aa:80:17 brd ff:ff:ff:ff:ff:ff 
    inet 192.168.139.55/20 brd 192.168.143.255 scope global dynamic eth0 
       valid_lft 1302sec preferred_lft 1302sec 
    inet6 fe80::5250:18ff:feaa:8017/64 scope link 
       valid_lft forever preferred_lft forever 
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 
       valid_lft forever preferred_lft forever 
4: virbr0-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
5: [email protected]: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 
    link/ether 96:e2:e3:ed:1d:b9 brd ff:ff:ff:ff:ff:ff 
6: [email protected]: <NO-CARRIER,BROADCAST,MULTICAST,UP,M-DOWN> mtu 1500 qdisc pfifo_fast state LOWERLAYERDOWN qlen 1000 
    link/ether 72:7f:5a:c4:7d:1a brd ff:ff:ff:ff:ff:ff 
[[email protected] ~]# ip a add dev veth0 192.168.3.1/29 
[[email protected] ~]# ip route 
default via 192.168.128.1 dev eth0 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
192.168.128.0/20 dev eth0  proto kernel  scope link  src 192.168.139.55 
[[email protected] ~]# ip a add dev veth1 192.168.3.2/29 
[[email protected] ~]# ip route 
default via 192.168.128.1 dev eth0 
192.168.3.0/29 dev veth1  proto kernel  scope link  src 192.168.3.2 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
192.168.128.0/20 dev eth0  proto kernel  scope link  src 192.168.139.55 
[[email protected] ~]# ip link set dev veth0 up 
[[email protected] ~]# ip addr 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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 qlen 1000 
    link/ether 50:50:18:aa:80:17 brd ff:ff:ff:ff:ff:ff 
    inet 192.168.139.55/20 brd 192.168.143.255 scope global dynamic eth0 
       valid_lft 1193sec preferred_lft 1193sec 
    inet6 fe80::5250:18ff:feaa:8017/64 scope link 
       valid_lft forever preferred_lft forever 
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 
       valid_lft forever preferred_lft forever 
4: virbr0-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500 
    link/ether 52:54:00:71:94:cc brd ff:ff:ff:ff:ff:ff 
5: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 
    link/ether 96:e2:e3:ed:1d:b9 brd ff:ff:ff:ff:ff:ff 
    inet 192.168.3.1/29 scope global veth0 
       valid_lft forever preferred_lft forever 
    inet6 fe80::94e2:e3ff:feed:1db9/64 scope link 
       valid_lft forever preferred_lft forever 
6: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 
    link/ether 72:7f:5a:c4:7d:1a brd ff:ff:ff:ff:ff:ff 
    inet 192.168.3.2/29 scope global veth1 
       valid_lft forever preferred_lft forever 
    inet6 fe80::707f:5aff:fec4:7d1a/64 scope link 
       valid_lft forever preferred_lft forever 
[[email protected] ~]# 
[[email protected] ~]# 
[[email protected] ~]# ip route 
default via 192.168.128.1 dev eth0 
192.168.3.0/29 dev veth1  proto kernel  scope link  src 192.168.3.2 
192.168.3.0/29 dev veth0  proto kernel  scope link  src 192.168.3.1 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
192.168.128.0/20 dev eth0  proto kernel  scope link  src 192.168.139.55 
[[email protected] ~]# ethtool -S veth0 
NIC statistics: 
     peer_ifindex: 6 
[[email protected] ~]# ethtool -S veth1 
NIC statistics: 
     peer_ifindex: 5 
[[email protected] ~]# 
     peer_ifindex: 5 
[[email protected] ~]# ping -I veth0 192.168.3.2 
PING 192.168.3.2 (192.168.3.2) from 192.168.3.1 veth0: 56(84) bytes of data. 
From 192.168.3.1 icmp_seq=1 Destination Host Unreachable 
From 192.168.3.1 icmp_seq=2 Destination Host Unreachable 
From 192.168.3.1 icmp_seq=3 Destination Host Unreachable 
From 192.168.3.1 icmp_seq=4 Destination Host Unreachable 
From 192.168.3.1 icmp_seq=5 Destination Host Unreachable 
From 192.168.3.1 icmp_seq=6 Destination Host Unreachable 
From 192.168.3.1 icmp_seq=7 Destination Host Unreachable 
From 192.168.3.1 icmp_seq=8 Destination Host Unreachable 
★★开另一个ssh 
[[email protected] ~]# tcpdump -i veth1 
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode 
listening on veth1, link-type EN10MB (Ethernet), capture size 65535 bytes 
07:21:39.312134 ARP, Request who-has localhost tell localhost, length 28 
07:21:40.312989 ARP, Request who-has localhost tell localhost, length 28 
07:21:41.314973 ARP, Request who-has localhost tell localhost, length 28 
[[email protected] ~]# 
[[email protected] ~]# 
[[email protected] ~]# 
[[email protected] ~]# tcpdump -i veth1 -v 
tcpdump: listening on veth1, link-type EN10MB (Ethernet), capture size 65535 bytes 
07:22:39.351507 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has localhost tell localhost, length 28 
07:22:40.352999 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has localhost tell localhost, length 28 
07:22:41.354977 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has localhost tell localhost, length 28 

[[email protected] ~]# tcpdump -i veth1 -e 
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode 
listening on veth1, link-type EN10MB (Ethernet), capture size 65535 bytes 
07:22:59.655361 96:e2:e3:ed:1d:b9 (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 42: Request who-has localhost tell localhost, length 28 
07:23:00.657021 96:e2:e3:ed:1d:b9 (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 42: Request who-has localhost tell localhost, length 28 
07:23:01.658978 96:e2:e3:ed:1d:b9 (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 42: Request who-has localhost tell localhost, length 28 

如果第一个窗口 
[[email protected] ~]# ping -I veth0 8.8.8.8 
PING 8.8.8.8 (8.8.8.8) from 192.168.3.1 veth0: 56(84) bytes of data. 
From 192.168.3.1 icmp_seq=1 Destination Host Unreachable 
From 192.168.3.1 icmp_seq=2 Destination Host Unreachable 
From 192.168.3.1 icmp_seq=3 Destination Host Unreachable 

则 
[[email protected] ~]# tcpdump -i veth1 -e -v 
tcpdump: listening on veth1, link-type EN10MB (Ethernet), capture size 65535 bytes 
07:23:45.375190 96:e2:e3:ed:1d:b9 (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 42: Ethernet (len 6), IPv4 (len 4), Request who-has google-public-dns-a.google.com tell localhost, length 28 
07:23:46.377023 96:e2:e3:ed:1d:b9 (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 42: Ethernet (len 6), IPv4 (len 4), Request who-has google-public-dns-a.google.com tell localhost, length 28 
07:23:47.378972 96:e2:e3:ed:1d:b9 (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 42: Ethernet (len 6), IPv4 (len 4), Request who-has google-public-dns-a.google.com tell localhost, length 28 

























































































































































































































































































以上是关于neutron基础一(网络基本命令)基本命令,包括veth peer的主要内容,如果未能解决你的问题,请参考以下文章

OpenStack——Neutron组件

OpenStack——Neutron组件

linux系统基本网络命令

openstack之Neutron网络虚拟化

测试需要了解的技术之基础篇一

openstack项目day24:VLAN模式