{"id":167,"date":"2021-03-12T14:21:07","date_gmt":"2021-03-12T06:21:07","guid":{"rendered":"http:\/\/feel.name\/?p=167"},"modified":"2021-03-12T14:24:56","modified_gmt":"2021-03-12T06:24:56","slug":"linux%e5%a4%9a%e7%bd%91%e5%8d%a1%e9%85%8d%e7%bd%ae%e8%b7%af%e7%94%b1%e8%a1%a8%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/feel.name\/?p=167","title":{"rendered":"Linux\u591a\u7f51\u5361\u914d\u7f6e\u8def\u7531\u8868\u811a\u672c"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-medium-font-size\"><strong>route \u547d\u4ee4\n                 \u8bbe\u7f6e\u548c\u67e5\u770b\u8def\u7531\u8868\u90fd\u53ef\u4ee5\u7528 route \u547d\u4ee4\uff0c\u8bbe\u7f6e\u5185\u6838\u8def\u7531\u8868\u7684\u547d\u4ee4\u683c\u5f0f\u662f\uff1a \n         # route  [add|del] [-net|-host] target [netmask Nm] [gw Gw] [[dev] If]\n         \u5176\u4e2d\uff1a \n         add : \u6dfb\u52a0\u4e00\u6761\u8def\u7531\u89c4\u5219\n         del : \u5220\u9664\u4e00\u6761\u8def\u7531\u89c4\u5219\n         -net : \u76ee\u7684\u5730\u5740\u662f\u4e00\u4e2a\u7f51\u7edc\n         -host : \u76ee\u7684\u5730\u5740\u662f\u4e00\u4e2a\u4e3b\u673a\n         target : \u76ee\u7684\u7f51\u7edc\u6216\u4e3b\u673a\n         netmask : \u76ee\u7684\u5730\u5740\u7684\u7f51\u7edc\u63a9\u7801\n         gw : \u8def\u7531\u6570\u636e\u5305\u901a\u8fc7\u7684\u7f51\u5173\n         dev : \u4e3a\u8def\u7531\u6307\u5b9a\u7684\u7f51\u7edc\u63a5\u53e3        \n        route \u547d\u4ee4\u4f7f\u7528\u4e3e\u4f8b\n                 \u6dfb\u52a0\u5230\u4e3b\u673a\u7684\u8def\u7531 \n         # route add -host 192.168.1.2 dev eth0:0 <\/strong>\n         <strong># route add -host 10.20.30.148 gw 10.20.30.40\n         \u6dfb\u52a0\u5230\u7f51\u7edc\u7684\u8def\u7531 \n         # route add -net 10.20.30.40 netmask 255.255.255.248 eth0 <\/strong>\n         <strong># route add -net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41 <\/strong>\n         <strong># route add -net 192.168.1.0\/24 eth1\n         \u6dfb\u52a0\u9ed8\u8ba4\u8def\u7531 \n         # route add default gw 192.168.1.1\n         \u5220\u9664\u8def\u7531 \n         # route del -host 192.168.1.2 dev eth0:0 <\/strong>\n         <strong># route del -host 10.20.30.148 gw 10.20.30.40 <\/strong>\n         <strong># route del -net 10.20.30.40 netmask 255.255.255.248 eth0 <\/strong>\n         <strong># route del -net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41 <\/strong>\n         <strong># route del -net 192.168.1.0\/24 eth1 <\/strong>\n         <strong># route del default gw 192.168.1.1        \n        \u8bbe\u7f6e\u5305\u8f6c\u53d1\n                 \u5728 CentOS \u4e2d\u9ed8\u8ba4\u7684\u5185\u6838\u914d\u7f6e\u5df2\u7ecf\u5305\u542b\u4e86\u8def\u7531\u529f\u80fd\uff0c\u4f46\u9ed8\u8ba4\u5e76\u6ca1\u6709\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u542f\u7528\u6b64\u529f\u80fd\u3002\u5f00\u542f  Linux\u7684\u8def\u7531\u529f\u80fd\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574\u5185\u6838\u7684\u7f51\u7edc\u53c2\u6570\u6765\u5b9e\u73b0\u3002\u8981\u914d\u7f6e\u548c\u8c03\u6574\u5185\u6838\u53c2\u6570\u53ef\u4ee5\u4f7f\u7528 sysctl \u547d\u4ee4\u3002\u4f8b\u5982\uff1a\u8981\u5f00\u542f  Linux\u5185\u6838\u7684\u6570\u636e\u5305\u8f6c\u53d1\u529f\u80fd\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u7684\u547d\u4ee4\u3002 \n         # sysctl -w net.ipv4.ip_forward=1\n         \u8fd9\u6837\u8bbe\u7f6e\u4e4b\u540e\uff0c\u5f53\u524d\u7cfb\u7edf\u5c31\u80fd\u5b9e\u73b0\u5305\u8f6c\u53d1\uff0c\u4f46\u4e0b\u6b21\u542f\u52a8\u8ba1\u7b97\u673a\u65f6\u5c06\u5931\u6548\u3002\u4e3a\u4e86\u4f7f\u5728\u4e0b\u6b21\u542f\u52a8\u8ba1\u7b97\u673a\u65f6\u4ecd\u7136\u6709\u6548\uff0c\u9700\u8981\u5c06\u4e0b\u9762\u7684\u884c\u5199\u5165\u914d\u7f6e\u6587\u4ef6\/etc\/sysctl.conf\u3002 \n         # vi \/etc\/sysctl.conf\n         net.ipv4.ip_forward = 1\n         \u7528\u6237\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u7684\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u662f\u5426\u652f\u6301\u5305\u8f6c\u53d1\u3002 \n         # sysctl  net.ipv4.ip_forward        \n\n\u591a\u7f51\u5361\u60c5\u51b5\u4e0b\u53ef\u4ee5\u76f4\u63a5\u7528make_route.sh\u8fd9\u4e2a\u811a\u672c\n\u4e0b\u8f7d\u5730\u5740 <a href=\"http:\/\/feel.name\/download\/make_route.sh\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/feel.name\/download\/make_route.sh<\/a>\n\u5c01\u56fd\u5916ip\u7684iptables\u811a\u672c\n\u4e0b\u8f7d\u5730\u5740 <a href=\"http:\/\/feel.name\/download\/iptables.sh\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/feel.name\/download\/iptables.sh<\/a>\n<\/strong><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>route \u547d\u4ee4 \u8bbe\u7f6e\u548c\u67e5\u770b\u8def\u7531\u8868\u90fd\u53ef\u4ee5\u7528 route \u547d\u4ee4\uff0c\u8bbe\u7f6e\u5185\u6838\u8def\u7531\u8868\u7684\u547d\u4ee4\u683c\u5f0f\u662f\uff1a # route [&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-167","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=167"}],"version-history":[{"count":4,"href":"https:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/167\/revisions"}],"predecessor-version":[{"id":171,"href":"https:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/167\/revisions\/171"}],"wp:attachment":[{"href":"https:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}