## router table router -> router ``` sender # sender eth # receiver # receiver eth # losses # 1 2 2 2 20 1 3 3 2 20 1 4 4 1 0 2 2 1 2 20 2 3 3 3 0 2 4 4 2 0 3 2 1 3 0 3 3 2 3 0 3 4 4 3 0 4 1 1 4 0 4 2 2 4 0 4 3 3 4 0 ``` router -> pc ``` sender # sender eth # receiver # receiver eth # losses # │ 1 1 1 1 0 │ 2 1 1 1 0 │ 2 1 2 1 0 │ 2 1 3 1 0 │ 3 1 3 1 0 ``` pc->pc ``` sender # sender eth # receiver # receiver eth # losses # 2 1 1 1 0 2 1 3 1 0 ``` pc->router ``` sender # sender eth # receiver # receiver eth # losses # 2 1 2 1 0 3 1 3 1 0 ``` ## Tcpdump output ping ``` tcpdump -i eth1 -e tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes 14:28:59.207532 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 23, length 64 14:28:59.207566 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 23, length 64 14:29:00.207639 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 24, length 64 14:29:00.207661 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 24, length 64 14:29:01.207750 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 25, length 64 14:29:01.207774 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 25, length 64 14:29:02.207867 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 26, length 64 14:29:02.207892 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 26, length 64 14:29:03.208087 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 27, length 64 14:29:03.208110 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 27, length 64 14:29:04.208230 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 28, length 64 14:29:04.208263 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 28, length 64 14:29:05.211944 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 29, length 64 14:29:05.211969 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 29, length 64 14:29:06.209458 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 30, length 64 14:29:06.209482 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 30, length 64 14:29:07.209566 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 31, length 64 14:29:07.209590 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 31, length 64 14:29:08.209683 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 32, length 64 14:29:08.209706 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 32, length 64 14:29:09.209803 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 33, length 64 14:29:09.209827 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 33, length 64 14:29:09.242521 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype ARP (0x0806), length 42: Request who-has 10.5.1.2 tell 10.5.1.1, length 28 14:29:09.242541 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype ARP (0x0806), length 42: Reply 10.5.1.2 is-at 00:16:3e:00:00:02 (oui Unknown), length 28 14:29:10.209897 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 34, length 64 14:29:10.209922 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 34, length 64 14:29:11.210041 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 35, length 64 14:29:11.210079 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 35, length 64 14:29:12.210112 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 36, length 64 14:29:12.210136 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 36, length 64 14:29:13.210241 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 37, length 64 14:29:13.210266 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 37, length 64 14:29:14.210353 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 38, length 64 14:29:14.210378 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 38, length 64 14:29:15.210490 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 39, length 64 14:29:15.210514 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 39, length 64 14:29:16.210574 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 40, length 64 14:29:16.210597 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.2 > 10.5.1.1: ICMP echo reply, id 8384, seq 40, length 64 14:29:17.210686 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 10.5.1.1 > 10.5.1.2: ICMP echo request, id 8384, seq 41, length 64 ``` ``` tcpdump -i eth1 -e tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes 14:18:42.413051 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 39, length 64 14:18:42.413085 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 39, length 64 14:18:43.413174 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 40, length 64 14:18:43.413199 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 40, length 64 14:18:44.413427 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 41, length 64 14:18:44.413450 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 41, length 64 14:18:45.413549 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 42, length 64 14:18:45.413573 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 42, length 64 14:18:46.413856 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 43, length 64 14:18:46.413879 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 43, length 64 14:18:46.650613 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype ARP (0x0806), length 42: Request who-has 172.16.1.100 tell 172.16.1.1, length 28 14:18:46.650631 00:16:3e:00:00:02 (oui Unknown) > 00:16:3e:00:00:08 (oui Unknown), ethertype ARP (0x0806), length 42: Reply 172.16.1.100 is-at 00:16:3e:00:00:02 (oui Unknown), length 28 14:18:47.413951 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 44, length 64 14:18:47.413975 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 44, length 64 14:18:48.414060 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 45, length 64 14:18:48.414084 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 45, length 64 14:18:49.414157 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 46, length 64 14:18:49.414179 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 46, length 64 14:18:50.031624 00:16:3e:00:00:02 (oui Unknown) > 33:33:00:00:00:02 (oui Unknown), ethertype IPv6 (0x86dd), length 70: fe80::216:3eff:fe00:2 > ip6-allrouters: ICMP6, router solicitation, length 16 14:18:50.414247 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 47, length 64 14:18:50.414268 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 47, length 64 14:18:51.414380 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 48, length 64 14:18:51.414404 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 48, length 64 14:18:52.414495 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 49, length 64 14:18:52.414518 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 49, length 64 14:18:53.414667 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 50, length 64 14:18:53.414689 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 50, length 64 14:18:54.414802 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 51, length 64 14:18:54.414831 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 51, length 64 14:18:55.414903 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 52, length 64 14:18:55.414931 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 52, length 64 14:18:56.415029 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 53, length 64 14:18:56.415056 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 53, length 64 14:18:57.415140 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 54, length 64 14:18:57.415167 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 54, length 64 14:18:58.415250 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 55, length 64 14:18:58.415277 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 55, length 64 14:18:59.415362 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 56, length 64 14:18:59.415389 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 56, length 64 14:19:00.415485 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 57, length 64 14:19:00.415513 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 57, length 64 14:19:01.415591 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 58, length 64 14:19:01.415618 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 58, length 64 14:19:02.415680 00:16:3e:00:00:08 (oui Unknown) > 00:16:3e:00:00:02 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.1 > 172.16.1.100: ICMP echo request, id 7117, seq 59, length 64 14:19:02.415703 00:16:3e:00:00:02 (oui Unknown) > 00:de:ad:be:ef:00 (oui Unknown), ethertype IPv4 (0x0800), length 98: 172.16.1.100 > 172.16.1.1: ICMP echo reply, id 7117, seq 59, length 64 ``` ## A103 ### router table router1 ``` ip route show 10.5.1.0/24 dev eth1 proto kernel scope link src 10.5.1.2 10.5.2.0/24 dev eth2 proto kernel scope link src 10.5.2.1 10.5.3.0/24 via 10.5.2.2 dev eth2 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.7 ``` pc1 ``` ip route 10.5.1.0/24 dev eth1 proto kernel scope link src 10.5.1.1 10.5.3.0/24 via 10.5.1.2 dev eth1 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.1 ``` router2 ``` ip route 10.5.1.0/24 via 10.5.2.1 dev eth2 10.5.2.0/24 dev eth2 proto kernel scope link src 10.5.2.2 10.5.3.0/24 dev eth1 proto kernel scope link src 10.5.3.2 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.12 ``` pc2 ``` root@pc2:~# ip route 10.5.1.0/24 via 10.5.3.2 dev eth1 10.5.3.0/24 dev eth1 proto kernel scope link src 10.5.3.1 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.3 ``` ## `ip` **`ip`** 是 IPRoute2 工具集中最常用的命令,能够管理和配置 IP 地址、路由、链路等多种网络参数。与旧版的 `ifconfig` 和 `route` 命令相比,`ip` 更加灵活和强大。 ### **`ip` 命令的常见用法** 1. **查看网络接口**: ```bash ip link show ``` 显示所有网络接口及其状态,类似于 `ifconfig`。 2. **启用或禁用网络接口**: ```bash sudo ip link set dev eth0 up # 启用接口 sudo ip link set dev eth0 down # 禁用接口 ``` 3. **添加/删除 IP 地址**: ```bash sudo ip address add 192.168.1.10/24 dev eth0 # 为 eth0 接口添加 IP 地址 sudo ip address del 192.168.1.10/24 dev eth0 # 从 eth0 接口删除 IP 地址 ``` 4. **显示路由表**: ```bash ip route show ``` 显示当前的路由表,类似于 `route` 命令。 5. **添加/删除路由**: ```bash sudo ip route add 192.168.1.0/24 via 192.168.1.1 # 添加路由条目 sudo ip route del 192.168.1.0/24 # 删除路由条目 ``` 6. **查看 ARP 表**: ```bash ip neighbor show ``` 显示 ARP 表,类似于 `arp -a`。