- ip addr
- ip link
- tcpdump -i veth1 -e -v
- route -n
- ip route
- arp
- ethtool -S veth0
- ip link add type veth
- ip link set dev veth0 up
- ip addr add dev veth0 192.168.3.1/29
- ping -I veth0 192.168.3.2
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]# ss -nltp|grep sshd
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1377,fd=3))
LISTEN 0 128 :::22 :::* users:(("sshd",pid=1377,fd=4))
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]# watch -d ip -s -s link
★★★★★★★★★★★★★★★★★★★★★
veth peer
[root@centos7 ~]# ip link add type veth
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]# 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: veth0@veth1: <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: veth1@veth0: <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
[root@centos7 ~]# 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: veth0@veth1: <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: veth1@veth0: <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
[root@centos7 ~]# ip link set dev veth1 up
[root@centos7 ~]# 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: veth0@veth1: <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: veth1@veth0: <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
[root@centos7 ~]# ip a add dev veth0 192.168.3.1/29
[root@centos7 ~]# 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
[root@centos7 ~]# ip a add dev veth1 192.168.3.2/29
[root@centos7 ~]# 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
[root@centos7 ~]# ip link set dev veth0 up
[root@centos7 ~]# 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: veth0@veth1: <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: veth1@veth0: <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
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]# 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
[root@centos7 ~]# ethtool -S veth0
NIC statistics:
peer_ifindex: 6
[root@centos7 ~]# ethtool -S veth1
NIC statistics:
peer_ifindex: 5
[root@centos7 ~]#
peer_ifindex: 5
[root@centos7 ~]# 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
[root@centos7 ~]# 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
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]# 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
[root@centos7 ~]# 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
如果第一个窗口
[root@centos7 ~]# 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
则
[root@centos7 ~]# 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