{"id":182,"date":"2018-01-30T20:48:45","date_gmt":"2018-01-30T12:48:45","guid":{"rendered":"https:\/\/wp.yaanren.win\/?p=182"},"modified":"2018-01-30T20:48:45","modified_gmt":"2018-01-30T12:48:45","slug":"ubuntu%e9%85%8d%e7%bd%ae%e9%9d%99%e6%80%81%e8%b7%af%e7%94%b1%e5%8f%8a%e9%87%8d%e5%90%af%e7%94%9f%e6%95%88","status":"publish","type":"post","link":"https:\/\/wp.625300.xyz\/?p=182","title":{"rendered":"ubuntu\u914d\u7f6e\u9759\u6001\u8def\u7531\u53ca\u91cd\u542f\u751f\u6548"},"content":{"rendered":"<p>&nbsp;<\/p>\n<h2>\u7b2c\u4e00\u79cd\u65b9\u6cd5:\u4f7f\u7528route\u547d\u4ee4\uff08\u6dfb\u52a0\u4e34\u65f6\u8def\u7531\uff09<\/h2>\n<h2>\u6dfb\u52a0\u5230\u4e3b\u673a\u7684\u8def\u7531<\/h2>\n<p># route add -host 192.168.1.123 dev eth0<\/p>\n<p># route add -host 192.168.1.123 gw 192.168.1.1<\/p>\n<h2>\u6dfb\u52a0\u5230\u7f51\u7edc\u7684\u8def\u7531<\/h2>\n<p># route add -net 192.168.1.123 netmask 255.255.255.0 eth0<\/p>\n<p># route add -net 192.168.1.123 netmask 255.255.255.0 gw 192.168.1.1<\/p>\n<p># route add -net 192.168.1.123 netmask 255.255.255.0 gw 192.168.1.1 eth1<\/p>\n<p># route add -net 192.168.1.0\/24 eth1<\/p>\n<h2>\u6dfb\u52a0\u9ed8\u8ba4\u7f51\u5173<\/h2>\n<p># route add default gw 192.168.1.1<\/p>\n<h2>\u5220\u9664\u8def\u7531<\/h2>\n<p># route del -host 192.168.1.11 dev eth0<\/p>\n<p># route del -net 192.168.1.123 netmask 255.255.255.0<\/p>\n<h1>\u7b2c\u4e8c\u79cd\u65b9\u6cd5: \u4fee\u6539\/etc\/rc.local<\/h1>\n<p>\u4fee\u6539\/etc\/rc.local\uff0c\u53ea\u662f\u8981\u6ce8\u610f\u7684\u4e00\u70b9\u662f\u4e0d\u8981\u5378\u8f7d &#8220;exit 0&#8243;\u7684\u540e\u9762<\/p>\n<p>vi\u00a0\/etc\/rc.local<\/p>\n<p>route add default gw 192.168.1.1<\/p>\n<p>\u8fd9\u6837\u5728\u7cfb\u7edf\u542f\u52a8\u7684\u65f6\u5019\u4f1a\u81ea\u52a8\u52a0\u5165\u76f8\u5173\u7684\u8def\u7531\u8bbe\u7f6e<\/p>\n<p>\u6ce8\uff1a<\/p>\n<p>\uff081\uff09\u5982\u679c\u67d0\u4e2a\u7cfb\u7edf\u670d\u52a1\uff0c\u6bd4\u5982\u8bf4\u662fNFS\u670d\u52a1\uff0c\u8fd9\u4e2a\u670d\u52a1\u662f\u5728\u542f\u52a8network\u670d\u52a1\u4e4b\u540e\uff0c\u5728\u6267\u884crc.local\u4e4b\u524d\uff0c\u5982\u679c\u4f60\u8bbe\u7f6e\u7684\u6709\u81ea\u52a8\u6302\u8f7d\u7684nfs\uff0c\u90a3\u4e48\uff0c\u8fd9\u91cc\u94fe\u8def\u7684\u4e0d\u901a\u7545\uff0c\u4f1a\u9020\u6210\u6302\u8f7d\u7684\u5931\u8d25\u3002<\/p>\n<p>\uff082\uff09\u5982\u679c\u4f60\u91cd\u542f\u4e86\u7f51\u7edc\u670d\u52a1\u5668\uff0c\u90a3\u4e48\u8def\u7531\u5c31\u5931\u6548\u4e86\uff0c\u8fd9\u4e2a\u65f6\u5019\u4f60\u4e0d\u5f97\u4e0d\u91cd\u65b0\u52a0\u8f7d\u8fd9\u4e2a\u6587\u4ef6\uff0c\u4f46\u662f\u5982\u679c\u4f60\u662f\u8fdc\u7a0b\u64cd\u4f5c\u7684\u5462\uff1f\u6240\u4ee5\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u4e0d\u662f\u975e\u5e38\u7684\u4e0d\u63a8\u8350<\/p>\n<h1>\u7b2c\u4e09\u79cd\u65b9\u6cd5\uff1a\u4fee\u6539interfaces\u6587\u4ef6<\/h1>\n<p>up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u683c\u5f0f\u548croute\u547d\u4ee4\u7684\u552f\u4e00\u533a\u522b\u5728\u4e8e\uff0c\u5728\u524d\u9762\u591a\u4e86\u4e00\u4e2aup<\/p>\n<p>\u4e0b\u9762\u5217\u51fa\u6211\u7684interface\u6587\u4ef6\u4ec5\u4f9b\u53c2\u8003\uff0c\u7531\u4e8e\u5b89\u5168\u56e0\u7d20\uff0c\u8fd9\u91cc\u7684ip\u6211\u90fd\u7528xx\u66ff\u4ee3\u4e86\uff1a<\/p>\n<p># This file describes the network interfaces available on your system<\/p>\n<p># and how to activate them. For more information, see interfaces(5).<\/p>\n<p># The loopback network interface<\/p>\n<p>auto lo<\/p>\n<p>iface lo inet loopback<\/p>\n<p># The primary network interface<\/p>\n<p>auto eth0<\/p>\n<p>iface eth0 inet static<\/p>\n<p>address xxx.xxx.xxx.xxx<\/p>\n<p>netmask xxx.xxx.xxx.xxx<\/p>\n<p>gateway xxx.xxx.xxx.xxx<\/p>\n<p>auto eth0:0<\/p>\n<p>iface eth0:0 inet static<\/p>\n<p>address xxx.xxx.xxx.xxx<\/p>\n<p>netmask xxx.xxx.xxx.xxx<\/p>\n<p>#dns-nameservers 202.102.224.68 202.102.227.68<\/p>\n<p>up route add -net xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gw xxx.xxx.xxx.xxx eth0<\/p>\n<p>up route add -net xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gw xxx.xxx.xxx.xxx eth0<\/p>\n<p>up route add -net xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gw xxx.xxx.xxx.xxx eth0<\/p>\n<h1>\u7b2c\u56db\u79cd\uff1a\u5728\/etc\/sysconfig\/network<\/h1>\n<p>network\u91cc\u6dfb\u52a0\u5230\u6587\u4ef6\u672b\u5c3e\uff0c\u683c\u5f0f\u5982\u4e0b<\/p>\n<p>vi\u00a0\/etc\/sysconfig\/network<\/p>\n<p>GATEWAY=gw-ip \u6216\u8005 GATEWAY=gw-dev<\/p>\n<p>\u6ce8\uff1a\u8fd9\u79cd\u65b9\u5f0f\u4ece\u5916\u89c2\u4e0a\u6765\u770b\u53ea\u80fd\u7528\u4e8e\u6dfb\u52a0\u9ed8\u8ba4\u7f51\u5173\u4e86\uff0c\u5bf9\u4e8e\u591a\u8def\u7f51\u7edc\u73af\u5883\u8c8c\u4f3c\u4e0d\u592a\u9002\u5408\u7684\u6837\u5b50<\/p>\n<h1>\u7b2c\u4e94\u79cd\uff1a\u76f4\u63a5\u5199\u5165ifcfg\u6587\u4ef6<\/h1>\n<p>\u5728\u914d\u7f6eip\u5730\u5740\u7684\u65f6\u5019\u76f4\u63a5\u5c06GATEWAY\u7684\u914d\u7f6e\u5199\u5165ifcfg\u6587\u4ef6\uff0c\u5f62\u5f0f\uff1aGATEWAY=gw-ip<\/p>\n<p>\u9002\u5408\u6dfb\u52a0\u9ed8\u8ba4\u8def\u7531<\/p>\n<h1>\u7b2c\u516d\u79cd\uff1a\u5199\u5165\/etc\/sysconfig\/static-routes\u6587\u4ef6<\/h1>\n<p>\u9ed8\u8ba4\u5728\/etc\/sysconifg\u76ee\u5f55\u4e2d\u662f\u6ca1\u6709\u8fd9\u4e2a\u6587\u4ef6\u7684\uff0c\u9700\u8981\u6211\u4eec\u624b\u5de5\u521b\u5efa\uff0c\u5bf9\u8fd9\u4e2a\u6587\u4ef6\u7684\u8c03\u7528\u5728\u4e0b\u9762\uff1a<\/p>\n<p>\/etc\/init.d\/network\uff1a<\/p>\n<p>159 # Add non interface-specific static-routes.<\/p>\n<p>160 if [ -f \/etc\/sysconfig\/static-routes ]; then<\/p>\n<p>161 grep &#8220;^any&#8221; \/etc\/sysconfig\/static-routes | while read ignore args ; do<\/p>\n<p>162 \/sbin\/route add -$args<\/p>\n<p>163 done<\/p>\n<p>&lt;span style=&#8221;font-fam<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u7b2c\u4e00\u79cd\u65b9\u6cd5:\u4f7f\u7528route\u547d\u4ee4\uff08\u6dfb\u52a0\u4e34\u65f6\u8def\u7531\uff09 \u6dfb\u52a0\u5230\u4e3b\u673a\u7684\u8def\u7531 # route add -ho&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,33,37],"tags":[],"class_list":["post-182","post","type-post","status-publish","format-standard","hentry","category-32","category-33","category-37"],"_links":{"self":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/posts\/182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=182"}],"version-history":[{"count":0,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/posts\/182\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}