{"id":8620,"date":"2021-07-28T10:54:53","date_gmt":"2021-07-28T02:54:53","guid":{"rendered":"https:\/\/blog.hoyo.idv.tw\/?p=8620"},"modified":"2023-02-14T09:09:08","modified_gmt":"2023-02-14T01:09:08","slug":"linux-avahi-autoipd","status":"publish","type":"post","link":"https:\/\/blog.hoyo.idv.tw\/?p=8620","title":{"rendered":"Linux - ZeroConfNetworking"},"content":{"rendered":"<p>--<\/p>\n<p>Windows \u8a2d\u5b9a DHCP \u6642\uff0c\u6c92\u6709 DHCP \u670d\u52d9\u6642\u6703\u81ea\u5df1\u7522\u751f\u4e00\u500b 169.254.x.x \u7684 IP\uff0cLinux \u9047\u5230\u6c92\u6709 DHCP \u670d\u52d9\u9664\u4e86\u958b\u6a5f\u4e0d\u65b7\u91cd\u8a66\u6d6a\u8cbb\u6642\u9593\u4e4b\u5916\uff0c\u5931\u6557\u5f8c\u4ec0\u9ebc IP \u90fd\u6c92\u6709\uff0c\u5c0e\u81f4\u81e8\u6642\u8981\u4f7f\u7528 IP \u9023\u7dda\u90fd\u6c92\u6709\u8fa6\u6cd5\u3002<\/p>\n<p>Linux \u8a72\u5982\u4f55\u5728\u4f7f\u7528 DHCP \u537b\u6c92\u6709 DHCP \u5206\u914d IP \u7684\u60c5\u6cc1\u9084\u53ef\u4ee5\u50cf Windows \u7522\u751f\u4e00\u7d44 IP \uff1f<\/p>\n<p>--<\/p>\n<h2>\u53c3\u8003\u8cc7\u6e90<\/h2>\n<ul>\n<li><a href=\"https:\/\/wiki.ubuntu.com\/ZeroConfNetworking\" target=\"_blank\" rel=\"noopener\">ZeroConfNetworking<\/a><\/li>\n<li><a class=\"question-hyperlink\" href=\"https:\/\/askubuntu.com\/questions\/696507\/how-can-i-get-avahi-autoipd-to-get-an-address-on-an-alias-regardless-of-the-sta\" target=\"_blank\" rel=\"noopener\">How can I get avahi-autoipd to get an address on an alias, regardless of the state of the interface?<\/a><\/li>\n<\/ul>\n<p>Windows \u4f7f\u7528\u7684\u662f\u00a0Zero-configuration networking (zeroconf) \u6280\u8853\uff0c RFC3927 \uff0cApple\u00a0Bonjour \u4e5f\u662f\u76f8\u540c\u7684\u6280\u8853<\/p>\n<p>--<\/p>\n<h2>\u5b89\u88dd<\/h2>\n<pre class=\"lang:default decode:true\"># apt-get install avahi-autoipd<\/pre>\n<p>Hoyo \u5728 DietPi \u4e0a\u6e2c\u8a66\u6642\u662f\u88dd\u00a0avahi-autoipd\uff0c\u7db2\u8def\u4e0a\u5927\u591a\u662f\u6559\u5b89\u88dd\u00a0avahi-daemon\uff0c\u5be6\u969b\u88dd\u904e\u4e0d\u77e5\u9053\u7528\u9014\u70ba\u4f55<\/p>\n<p>avahi-autoipd \u5b89\u88dd\u5b8c\u5c31\u5b8c\u6210\u4e86\uff0c\u9810\u8a2d\u8a2d\u5b9a\u6709\u4e00\u4e9b\u554f\u984c\u4e0d\u904e\u554f\u984c\u4e0d\u5927\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\uff0cHoyo \u662f\u6253\u7b97\u5c31\u9019\u6a23\u4f7f\u7528<\/p>\n<p>--<\/p>\n<h2>\u5be6\u969b\u4f7f\u7528<\/h2>\n<p>\u6c92\u6709 DHCP<\/p>\n<pre class=\"lang:default decode:true\">root@DietPi:~# ifconfig\r\neth0: flags=4099&lt;UP,BROADCAST,MULTICAST&gt;  mtu 1500\r\n        ether f6:10:e5:d0:32:3a  txqueuelen 1000  (Ethernet)\r\n        RX packets 0  bytes 0 (0.0 B)\r\n        RX errors 0  dropped 0  overruns 0  frame 0\r\n        TX packets 0  bytes 0 (0.0 B)\r\n        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0\r\n        device interrupt 47\r\n\r\neth0:avahi: flags=4099&lt;UP,BROADCAST,MULTICAST&gt;  mtu 1500\r\n        inet 169.254.7.53  netmask 255.255.0.0  broadcast 169.254.255.255\r\n        ether f6:10:e5:d0:32:3a  txqueuelen 1000  (Ethernet)\r\n        device interrupt 47<\/pre>\n<p>\u63a5\u4e0a\u7db2\u8def\u7dda\u6216\u662f DHCP \u6062\u5fa9\u5f8c<\/p>\n<pre class=\"lang:default decode:true \">root@DietPi:~# ifconfig\r\neth0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500\r\n        ether f6:10:e5:d0:32:3a  txqueuelen 1000  (Ethernet)\r\n        RX packets 16  bytes 1264 (1.2 KiB)\r\n        RX errors 0  dropped 0  overruns 0  frame 0\r\n        TX packets 3  bytes 726 (726.0 B)\r\n        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0\r\n        device interrupt 47<\/pre>\n<p>eth0:avahi \u7db2\u8def\u6703\u6d88\u5931<\/p>\n<p>--<\/p>\n<h2>\u8a2d\u5b9a\u6a94<\/h2>\n<p>\/etc\/dhcp\/dhclient-enter-hooks.d\/avahi-autoipd<\/p>\n<pre class=\"lang:default decode:true\">#!\/bin\/sh\r\n\r\n# This file is part of avahi.\r\n#\r\n# avahi is free software; you can redistribute it and\/or modify it\r\n# under the terms of the GNU Lesser General Public License as\r\n# published by the Free Software Foundation; either version 2 of the\r\n# License, or (at your option) any later version.\r\n#\r\n# avahi is distributed in the hope that it will be useful, but WITHOUT\r\n# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r\n# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public\r\n# License for more details.\r\n#\r\n# You should have received a copy of the GNU Lesser General Public\r\n# License along with avahi; if not, write to the Free Software\r\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307\r\n# USA.\r\n\r\ncase \"$reason\" in\r\n    MEDIUM|ARPCHECK|ARPSEND|NBI)\r\n        ;;\r\n\r\n    PREINIT|BOUND|RENEW|REBIND|REBOOT|STOP|RELEASE)\r\n        if [ -x \/usr\/sbin\/avahi-autoipd ] &amp;&amp; \/usr\/sbin\/avahi-autoipd -c $interface; then\r\n            \/usr\/sbin\/avahi-autoipd -k $interface 2&gt; \/dev\/null\r\n        fi\r\n        ;;\r\n\r\n    EXPIRE|FAIL|TIMEOUT)\r\n        # Starting avahi-autoipd is left for the exit hook\r\n        ;;\r\nesac<\/pre>\n<p>--<\/p>\n<h2>\u554f\u984c<\/h2>\n<p>\u767b\u5165\u6642\u9700\u8981 Ctrl + C \u4e2d\u65b7<\/p>\n<p><a href=\"https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/07\/20210728_104634.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-8625\" src=\"https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/07\/20210728_104634-300x170.png\" alt=\"\" width=\"300\" height=\"170\" srcset=\"https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/07\/20210728_104634-300x170.png 300w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/07\/20210728_104634-500x283.png 500w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/07\/20210728_104634.png 696w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>--<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"8620\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;1,602&nbsp;total views<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>-- Windows \u8a2d\u5b9a D...<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"8620\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;1,602&nbsp;total views<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[26],"tags":[313,315,314],"_links":{"self":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/8620"}],"collection":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8620"}],"version-history":[{"count":8,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/8620\/revisions"}],"predecessor-version":[{"id":11566,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/8620\/revisions\/11566"}],"wp:attachment":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}