{"id":211095,"date":"2021-02-20T08:38:41","date_gmt":"2021-02-20T00:38:41","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=211095"},"modified":"2021-02-04T14:29:59","modified_gmt":"2021-02-04T06:29:59","slug":"linux-route-check","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-route-check.html","title":{"rendered":"Linux\u7f51\u7edc\u8def\u7531\u7b80\u4ecb-\u67e5\u770b\u7f51\u7edc\u8def\u7531"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u672c\u6587\u5bf9\u7528\u4e8e\u7406\u89e3\u7b80\u5355\u73af\u5883\u7684Linux\u8ba1\u7b97\u673a\u7684\u8def\u7531\u8fdb\u884c\u4e86\u975e\u5e38\u7b80\u77ed\u7684\u4ecb\u7ecd\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n linux \u67e5\u770b\u7f51\u7edc\u8def\u7531<\/strong><\/div>\n \u8fde\u63a5\u5230\u7f51\u7edc\u7684\u6bcf\u53f0\u8ba1\u7b97\u673a\u5728\u79bb\u5f00\u672c\u5730\u4e3b\u673a\u65f6\u90fd\u9700\u8981\u9488\u5bf9\u7f51\u7edcTCP \/ IP\u6570\u636e\u5305\u7684\u67d0\u79cd\u8def\u7531\u8bf4\u660e\u3002 \u8fd9\u901a\u5e38\u975e\u5e38\u7b80\u5355\uff0c\u56e0\u4e3a\u5927\u591a\u6570\u7f51\u7edc\u73af\u5883\u90fd\u975e\u5e38\u7b80\u5355\uff0c\u5e76\u4e14\u79bb\u5f00\u6570\u636e\u5305\u53ea\u6709\u4e24\u79cd\u9009\u62e9\u3002 \u6240\u6709\u6570\u636e\u5305\u90fd\u53d1\u9001\u5230\u672c\u5730\u7f51\u7edc\u4e0a\u7684\u8bbe\u5907\u6216\u5176\u4ed6\u8fdc\u7a0b\u7f51\u7edc\u4e0a\u3002<\/p>\n \u786e\u4fdd\u5c06\u201c\u672c\u5730\u201d\u7f51\u7edc\u5b9a\u4e49\u4e3a\u672c\u5730\u4e3b\u673a\u6240\u5728\u7684\u903b\u8f91\u7f51\u7edc\uff0c\u901a\u5e38\u4e5f\u5b9a\u4e49\u4e3a\u7269\u7406\u7f51\u7edc\u3002 \u4ece\u903b\u8f91\u4e0a\u8bb2\uff0c\u8fd9\u662f\u6307\u5728\u5176\u4e2d\u4e3a\u4e3b\u673a\u5206\u914d\u4e86\u672c\u5730\u5b50\u7f51IP\u5730\u5740\u8303\u56f4\u4e4b\u4e00\u7684\u672c\u5730\u5b50\u7f51\u3002 \u4ece\u7269\u7406\u4e0a\u8bb2\uff0c\u8fd9\u610f\u5473\u7740\u4e3b\u673a\u5df2\u8fde\u63a5\u5230\u4e00\u53f0\u6216\u591a\u53f0\u4ea4\u6362\u673a\uff0c\u8fd9\u4e9b\u4ea4\u6362\u673a\u4e5f\u5df2\u8fde\u63a5\u5230\u672c\u5730\u7f51\u7edc\u7684\u5176\u4f59\u90e8\u5206\u3002<\/p>\n TCP \/ IP\u7f51\u7edc\u6a21\u578b<\/strong><\/div>\n \n\u5728\u8fdb\u884c\u8def\u7531\u9009\u62e9\u4e4b\u524d\uff0c\u5148\u4e86\u89e3\u4e00\u4e9b\u6709\u5173\u6570\u636e\u5305\u5982\u4f55\u627e\u5230\u901a\u5f80\u7f51\u7edc\u4e0a\u6b63\u786e\u4e3b\u673a\u7684\u65b9\u5f0f\u7684\u5e2e\u52a9\u3002 TCP \/ IP \u7f51\u7edc\u6a21\u578b\u5b9a\u4e49\u4e86\u4e00\u4e2a\u4e94\u5c42\u5806\u6808\uff0c\u8be5\u5806\u6808\u63cf\u8ff0\u4e86\u5c06\u6570\u636e\u5305\u4ece\u4e00\u53f0\u4e3b\u673a\u79fb\u52a8\u5230\u53e6\u4e00\u53f0\u4e3b\u673a\u6240\u5fc5\u9700\u7684\u673a\u5236\uff0c\u65e0\u8bba\u8be5\u4e3b\u673a\u662f\u5728\u672c\u5730\u7f51\u7edc\u4e0a\u8fd8\u662f\u5728\u4e16\u754c\u8303\u56f4\u5185\u3002 \u5728\u6b64\u6a21\u578b\u7684\u4ee5\u4e0b\u63cf\u8ff0\u4e2d\uff0c\u6bcf\u4e2a\u5c42\u90fd\u6709\u7f16\u53f7\uff0c\u5e76\u4e14\u8fd8\u5305\u542b\u8be5\u5c42\u5904\u7406\u7684\u6570\u636e\u5355\u5143\u7684\u540d\u79f0\u3002<\/p>\n 5.\u5e94\u7528\u7a0b\u5e8f\u5c42\uff1a\u6d88\u606f\u8be5\u5c42\u5305\u62ec\u5404\u79cd\u7f51\u7edc\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884c\u901a\u4fe1\u6240\u9700\u7684\u8fde\u63a5\u534f\u8bae\uff0c\u4f8b\u5982HTTP\uff0cDHCP\uff0cSSH\uff0cFTP\uff0cSMTP\uff0cIMAP\u7b49\u3002 \u5f53\u60a8\u4ece\u8fdc\u7a0b\u7f51\u7ad9\u8bf7\u6c42\u7f51\u9875\u65f6\uff0c\u8fde\u63a5\u8bf7\u6c42\u5c06\u53d1\u9001\u5230Web\u670d\u52a1\u5668\uff0c\u54cd\u5e94\u4f1a\u53d1\u9001\u56de\u8be5\u5c42\u7684\u4e3b\u673a\uff0c\u7136\u540e\u6d4f\u89c8\u5668\u5c06\u5728\u5176\u7a97\u53e3\u4e2d\u663e\u793a\u8be5\u7f51\u9875\u3002<\/p>\n 4.\u4f20\u8f93\u5c42\uff1aTCP\u6bb5\u3002 \u4f20\u8f93\u5c42\u63d0\u4f9b\u7aef\u5230\u7aef\u6570\u636e\u4f20\u8f93\u548c\u6d41\u7ba1\u7406\u670d\u52a1\uff0c\u8fd9\u4e9b\u670d\u52a1\u4e0e\u6570\u636e\u548c\u6240\u4f20\u8f93\u534f\u8bae\u7684\u7c7b\u578b\u65e0\u5173\u3002 \u5b83\u4f7f\u7528\u7aef\u53e380\uff08\u4f8b\u5982HTTP\uff09\u548c25\uff08SMTP\uff09\u5728\u53d1\u9001\u4e3b\u673a\u548c\u8fdc\u7a0b\u4e3b\u673a\u4e4b\u95f4\u5efa\u7acb\u8fde\u63a5\u3002<\/p>\n 3. Internet\u5c42\uff1a\u6570\u636e\u5305\u3002 \u6570\u636e\u5305\u8def\u7531\u5728Internet\u5c42\u4e0a\u6267\u884c\u3002 \u8be5\u5c42\u8d1f\u8d23\u5728\u4e24\u4e2a\u6216\u591a\u4e2a\u4e0d\u540c\u7684\u7f51\u7edc\u4e0a\u8def\u7531\u6570\u636e\u5305\uff0c\u4ee5\u5230\u8fbe\u5176\u6700\u7ec8\u76ee\u7684\u5730\u3002 \u8be5\u5c42\u4f7f\u7528IP\u5730\u5740\u548c\u8def\u7531\u8868\u6765\u786e\u5b9a\u5c06\u6570\u636e\u5305\u53d1\u9001\u5230\u4e0b\u4e00\u4e2a\u8bbe\u5907\u3002 \u5982\u679c\u53d1\u9001\u5230\u8def\u7531\u5668\uff0c\u5219\u6bcf\u4e2a\u8def\u7531\u5668\u4ec5\u8d1f\u8d23\u5c06\u6570\u636e\u5305\u53d1\u9001\u5230\u8be5\u7cfb\u5217\u4e2d\u7684\u4e0b\u4e00\u4e2a\u8def\u7531\u5668\uff0c\u800c\u4e0d\u8d1f\u8d23\u6620\u5c04\u4ece\u672c\u5730\u4e3b\u673a\u5230\u76ee\u6807\u4e3b\u673a\u7684\u6574\u4e2a\u8def\u7531\u3002 Internet\u5c42\u4e3b\u8981\u662f\u5173\u4e8e\u8def\u7531\u5668\u4e0e\u8def\u7531\u5668\u8fdb\u884c\u5bf9\u8bdd\uff0c\u4ee5\u786e\u5b9a\u94fe\u8def\u4e2d\u7684\u4e0b\u4e00\u4e2a\u8def\u7531\u5668\u3002<\/p>\n 2.\u6570\u636e\u94fe\u8def\u5c42\uff1a\u6846\u67b6\u3002 \u94fe\u8def\u5c42\u7ba1\u7406\u5355\u4e2a\u672c\u5730\u903b\u8f91\u903b\u8f91\u7f51\u7edc\u4e0a\u786c\u4ef6\u4e3b\u673a\u4e4b\u95f4\u7684\u76f4\u63a5\u8fde\u63a5\u3002 \u8be5\u5c42\u4f7f\u7528\u5d4c\u5165\u5728\u7f51\u7edc\u63a5\u53e3\u5361\uff08NIC\uff09\u4e2d\u7684\u5a92\u4f53\u8bbf\u95ee\u63a7\u5236\uff08M AC \uff09 \u5730\u5740\u6765\u8bc6\u522b\u8fde\u63a5\u5230\u672c\u5730\u7f51\u7edc\u7684\u7269\u7406\u8bbe\u5907\u3002 \u8be5\u5c42\u65e0\u6cd5\u8bbf\u95ee\u4e0d\u5728\u672c\u5730\u7f51\u7edc\u4e0a\u7684\u4e3b\u673a\u3002<\/p>\n 1.\u7269\u7406\u5c42\uff1a\u4f4d\u3002 \u8fd9\u662f\u786c\u4ef6\u5c42\uff0c\u7531NIC\u548c\u7269\u7406\u4ee5\u592a\u7f51\u7535\u7f06\u4ee5\u53ca\u7528\u4e8e\u5728\u6784\u6210\u4efb\u4f55\u4e24\u4e2a\u4e3b\u673a\u6216\u672c\u5730\u8fde\u63a5\u7684\u5176\u4ed6\u7f51\u7edc\u8282\u70b9\u4e4b\u95f4\u4f20\u8f93\u6784\u6210\u6570\u636e\u5e27\u7684\u5404\u4e2a\u4f4d\u7684\u786c\u4ef6\u7ea7\u522b\u534f\u8bae\u7ec4\u6210\u3002<\/p>\n \u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50<\/strong><\/div>\n \u90a3\u4e48\uff0c\u5f53\u4e3b\u673a\u5b9e\u9645\u4e0a\u4f7f\u7528TCP \/ IP\u7f51\u7edc\u6a21\u578b\u5728\u7f51\u7edc\u4e0a\u53d1\u9001\u6570\u636e\u65f6\uff0c\u4f1a\u662f\u4ec0\u4e48\u6837\uff1f \u8fd9\u662f\u6211\u5bf9\u6570\u636e\u5982\u4f55\u4ece\u4e00\u4e2a\u7f51\u7edc\u79fb\u52a8\u5230\u53e6\u4e00\u4e2a\u7f51\u7edc\u7684\u5b8c\u6574\u63cf\u8ff0\u3002 \u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u7684\u8ba1\u7b97\u673a\u6b63\u5728\u5411\u8fdc\u7a0b\u670d\u52a1\u5668\u53d1\u9001\u7f51\u9875\u8bf7\u6c42\u3002<\/p>\n \u8bf7\u6ce8\u610f\uff0c\u5bf9\u4e8e\u7b2c\u4e8c\u5c42\u53ca\u7b2c\u4e8c\u5c42\u4ee5\u4e0a\u7684\u6240\u6709\u534f\u8bae\u800c\u8a00\uff0c\u5f00\u5173\u662f\u4e0d\u53ef\u89c1\u7684\uff0c\u56e0\u6b64\u5b83\u4eec\u4e0d\u4f1a\u4ee5\u4efb\u4f55\u903b\u8f91\u65b9\u5f0f\u5f71\u54cd\u6570\u636e\u7684\u4f20\u8f93\u3002 \u4ea4\u6362\u673a\u7684\u529f\u80fd\u4ec5\u4ec5\u662f\u63d0\u4f9b\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u5373\u901a\u8fc7\u4ee5\u592a\u7f51\u7535\u7f06\u7684\u957f\u5ea6\u5c06\u591a\u4e2a\u4e3b\u673a\u8fde\u63a5\u5230\u5355\u4e2a\u7269\u7406\u7f51\u7edc\u4e2d\u3002<\/p>\n \u60a8\u53ef\u4ee5\u4f7f\u7528arp [-n]\u547d\u4ee4\u67e5\u770b\u4e3b\u673a\u5df2\u5728\u5176arp\u8868\u4e2d\u5b58\u50a8\u7684\u6240\u6709MAC\u5730\u5740\u3002 \u8fd9\u4e9b\u59cb\u7ec8\u662f\u672c\u5730\u7f51\u7edc\u4e0a\u7684\u4e3b\u673a\u3002<\/p>\n \u8def\u7531\u8868<\/strong><\/div>\n \u6240\u6709\u7f51\u7edc\u8bbe\u5907\uff0c\u65e0\u8bba\u5b83\u4eec\u662f\u4e3b\u673a\uff0c\u8def\u7531\u5668\u8fd8\u662f\u5176\u4ed6\u7c7b\u578b\u7684\u7f51\u7edc\u8282\u70b9\uff0c\u4f8b\u5982\u7f51\u7edc\u8fde\u63a5\u7684\u6253\u5370\u673a\uff0c\u90fd\u9700\u8981\u51b3\u5b9a\u5c06TCP \/ IP\u6570\u636e\u5305\u8def\u7531\u5230\u4f55\u5904\u3002 \u8def\u7531\u8868\u63d0\u4f9b\u4e86\u505a\u51fa\u8fd9\u4e9b\u51b3\u5b9a\u6240\u9700\u7684\u914d\u7f6e\u4fe1\u606f\u3002\u4e0e\u56fe1\u4e2d\u975e\u5e38\u7b80\u5355\u7684\u8def\u7531\u8868\u7c7b\u4f3c\uff0c\u8be5\u8def\u7531\u8868\u7528\u4e8e\u5b9a\u4e49\u5178\u578b\u672c\u5730\u4e3b\u673a\u53ef\u7528\u7684\u5355\u4e2a\u8def\u7531\uff0c\u5e76\u786e\u5b9a\u662f\u5426\u5c06\u6570\u636e\u5305\u53d1\u9001\u5230\u9ed8\u8ba4\u7f51\u5173\u8def\u7531\u5668\u3002 \u3002 route -n\u547d\u4ee4\u5217\u51fa\u4e86\u8def\u7531\u8868\uff1b -n\u9009\u9879\u4ec5\u5c06\u7ed3\u679c\u663e\u793a\u4e3aIP\u5730\u5740\uff0c\u5e76\u4e14\u4e0d\u5c1d\u8bd5\u6267\u884cDNS\u67e5\u627e\uff0c\u8be5DNS\u67e5\u627e\u5c06\u4f7f\u7528\u4e3b\u673a\u540d\u66ff\u6362IP\u5730\u5740\uff08\u5982\u679c\u53ef\u7528\uff09\u3002 \u4f7f\u7528netstat - R N\u547d\u4ee4\u4ea7\u751f\u7684\u7ed3\u679c\u975e\u5e38\u76f8\u4f3c\u3002<\/p>\n \r\n[root@host1 ~]# route -n\r\nKernel IP routing table\r\nDestination Gateway Genmask Flags Metric Ref Use Iface\r\n0.0.0.0 192.168.0.254 0.0.0.0 UG 100 0 0 eno1\r\n192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eno1\r\n<\/pre>\n |