neutron基础一(网络基本命令)

[b]基本命令,包括veth peer[/b]
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


# [color=red]cat /proc/net/dev[/color]
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
# [color=red]route -n[/color]
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
# [color=red]ip route[/color]
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
#[color=red] cat /proc/net/route[/color]
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
# [color=red]arp[/color]
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
# [color=red]ip neighbor[/color]
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
# 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
# [color=red]netstat -nltpu|grep sshd[/color]
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1377/sshd
tcp6 0 0 :::22 :::* LISTEN 1377/sshd
# [color=red]ss -nltp|grep sshd[/color]
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1377,fd=3))
LISTEN 0 128 :::22 :::* users:(("sshd",pid=1377,fd=4))
# [color=red]cat /proc/net/tcp[/color]
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
# [color=red]ip -s -s link[/color]
1: lo: 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: 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: 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: 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
# [color=red]ip address[/color]
1: lo: 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: 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: 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: 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
# watch -d ip -s -s link

[color=darkred][b]★★★★★★★★★★★★★★★★★★★★★[/b][/color]
veth peer


# [color=red]ip link add type veth[/color]
#
#
# [color=red]ip link[/color]
1: lo: 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: 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: 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: 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: 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: 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
# [color=red]ip a[/color]
1: lo: 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: 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: 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: 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: 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: mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 72:7f:5a:c4:7d:1a brd ff:ff:ff:ff:ff:ff
# [color=red]ip link set dev veth1 up[/color]
# ip a
1: lo: 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: 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: 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: 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: 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: mtu 1500 qdisc pfifo_fast state LOWERLAYERDOWN qlen 1000
link/ether 72:7f:5a:c4:7d:1a brd ff:ff:ff:ff:ff:ff
#[color=red] ip a add dev veth0 192.168.3.1/29[/color]
#[color=red] ip route[/color]
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
# [color=red]ip a add dev veth1 192.168.3.2/29[/color]
# [color=red]ip route[/color]
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
# [color=red]ip link set dev veth0 up[/color]
#[color=red] ip addr[/color]
1: lo: 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: 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: 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: 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: 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: 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
#
#
# [color=red]ip route[/color]
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
# [color=red]ethtool -S veth0[/color]
NIC statistics:
peer_ifindex: 6
# [color=red]ethtool -S veth1[/color]
NIC statistics:
peer_ifindex: 5
#
peer_ifindex: 5
# [color=red]ping -I veth0 192.168.3.2[/color]
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
# [color=red]tcpdump -i veth1[/color]
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
#
#
#
#[color=red] tcpdump -i veth1 -v[/color]
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

# [color=red]tcpdump -i veth1 -e[/color]
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

[b]如果第一个窗口[/b]
# [color=red]ping -I veth0 8.8.8.8[/color]
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


# [color=red]tcpdump -i veth1 -e -v[/color]
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

你可能感兴趣的:(linux,neutron,linux,neutron)