{"id":380474,"date":"2021-03-08T20:48:56","date_gmt":"2021-03-08T12:48:56","guid":{"rendered":"http:\/\/4563.org\/?p=380474"},"modified":"2021-03-08T20:48:56","modified_gmt":"2021-03-08T12:48:56","slug":"%e6%b1%82%e5%8a%a9%ef%bc%9a%e5%90%af%e5%8a%a8%e5%99%a8%e4%bb%8e-openrc-%e5%88%87%e6%8d%a2%e5%88%b0-systemd%ef%bc%8c%e5%9b%a0-systemd-networkd-%e9%85%8d%e7%bd%ae%e7%bd%91%e7%bb%9c%ef%bc%8c%e5%af%bc","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=380474","title":{"rendered":"\u6c42\u52a9\uff1a\u542f\u52a8\u5668\u4ece openrc \u5207\u6362\u5230 systemd\uff0c\u56e0 systemd-networkd \u914d\u7f6e\u7f51\u7edc\uff0c\u5bfc\u81f4 dnsmasq \u542f\u52a8\u5931\u8d25\uff01"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6c42\u52a9\uff1a\u542f\u52a8\u5668\u4ece openrc \u5207\u6362\u5230 systemd\uff0c\u56e0 systemd-networkd \u914d\u7f6e\u7f51\u7edc\uff0c\u5bfc\u81f4 dnsmasq \u542f\u52a8\u5931\u8d25\uff01               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xivisi <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5982\u6807\u9898\u6240\u8ff0\uff0c\u81ea\u542f\u52a8 dnsmasq \u4f1a\u5931\u8d25\uff0c\u8fdb\u5165\u7cfb\u7edf\u540e\u624b\u52a8\u542f\u52a8 dnsmasq \u670d\u52a1\u5219\u4e00\u5207\u6b63\u5e38\u3002 \u6839\u636e\u9519\u8bef\u63d0\u793a\uff1a<\/p>\n<p>3 \u6708 08 20:24:56 LINUX systemd[1]: Starting A lightweight DHCP and caching DNS server&#8230;<\/p>\n<p>3 \u6708 08 20:24:56 LINUX dnsmasq[228]: dnsmasq: syntax check OK.<\/p>\n<p>3 \u6708 08 20:24:56 LINUX systemd[1]: Started A lightweight DHCP and caching DNS server.<\/p>\n<p>3 \u6708 08 20:24:56 LINUX dnsmasq[232]: dnsmasq: failed to create listening socket for 10.0.1.1: \u65e0\u6cd5\u6307\u5b9a\u88ab\u8bf7\u6c42\u7684\u5730\u5740<\/p>\n<p>3 \u6708 08 20:24:56 LINUX systemd[1]: dnsmasq.service: Main process exited, code=exited,\uff0cstatus=2\/INVALIDARGUMENT<\/p>\n<p>3 \u6708 08 20:24:56 LINUX systemd[1]: dnsmasq.service: Failed with result &#8216;exit-code&#8217;.<\/p>\n<p>\u53ef\u77e5\uff0c\u662f\u65e0\u6cd5\u7ed1\u5b9a\u6211\u8bbe\u7f6e\u7684\u5c40\u57df\u7f51\u672c\u673a\u5730\u5740\uff1a10.0.1.1\uff0c \u8be5\u5730\u5740\u662f\u6211\u7528 systemd-networkd \u914d\u7f6e\u7684\u9759\u6001\u5730\u5740\u3002\u6839\u636e\u7cfb\u7edf\u542f\u52a8\u540e\u518d\u6b21\u8fd0\u884c\u8be5\u670d\u52a1\u53c8\u4e00\u5207\u6b63\u5e38\uff0c\u521d\u6b65\u5224\u65ad\u662f\u56e0\u4e3a dnsmasq \u542f\u52a8\u65f6\uff0c\u7f51\u7edc\u8fd8\u6ca1\u6709\u914d\u7f6e\u597d\u3002<\/p>\n<p>\u4f46\u662f\u670d\u52a1\u7684\u4f9d\u8d56\u914d\u7f6e\uff0c\u611f\u89c9\u53c8\u6ca1\u4ec0\u4e48\u95ee\u9898\uff0c\u4e0d\u77e5\u9053\u600e\u4e48\u89e3\u51b3\u4e86\uff1f \u96be\u9053\u5199\u4e2a sh \u811a\u672c\uff0c\u7279\u610f\u7b49\u5f85\u82e5\u5e72\u79d2\uff0c\u518d\u542f\u52a8 dnsmasq \uff1f\uff1f<\/p>\n<p>[Unit]<\/p>\n<p>Description=A lightweight DHCP and caching DNS server<\/p>\n<p>After=network.target<\/p>\n<p>[Service]<\/p>\n<p>Type=simple<\/p>\n<p>ExecStartPre=\/usr\/sbin\/dnsmasq &#8211;test<\/p>\n<p>ExecStart=\/usr\/sbin\/dnsmasq -k<\/p>\n<p>ExecReload=\/bin\/kill -HUP $MAINPID<\/p>\n<p>[Install]<\/p>\n<p>WantedBy=multi-user.target<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5487328\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : codehz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bd5\u8bd5<br \/>After=network-online.target<br \/>Wants=network-online.target                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487329\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jim9606 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bd5\u4e0b\u6539\u6210\u8fd9\u4e2a<br \/>After=systemd-networkd.service<br \/>Before=network.target<br \/>\u53c2\u8003\u81ea systemd-resolved.setvice                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487330\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jirajine <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             systemd \u975e\u5e38\u7684\u6fc0\u8fdb\uff0c\u4f60\u4e0d\u663e\u793a\u6307\u5b9a After \u7684\u5168\u90fd\u4f1a\u5e76\u884c\u542f\u52a8\u3002<\/p>\n<p>https:\/\/wiki.archlinux.org\/index.php\/Systemd#Handling_dependencies<\/p>\n<p>With systemd, dependencies can be resolved by designing the unit files correctly. The most typical case is that the unit A requires the unit B to be running before A is started. In that case add Requires=B and After=B to the [Unit] section of A. If the dependency is optional, add Wants=B and After=B instead. Note that Wants= and Requires= do not imply After=, meaning that if After= is not specified, the two units will be started in parallel.                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487331\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : xivisi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @codehz \u4f1a\u5bfc\u81f4\u4e00\u76f4\u7b49\u5f85\u670d\u52a1\u4e2d\uff0c\u6ca1\u6709\u771f\u6b63\u8fd0\u884c\u7a0b\u5e8f\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487332\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : xivisi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @jim9606 \u73b0\u8c61\u4e00\u6837\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487333\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : defunct9 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f00 ssh\uff0c\u8ba9\u6211\u4e0a\u53bb\u770b\u770b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487334\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tinkerer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8981\u66b4\u529b\u4e00\u70b9\u76f4\u63a5\u628a Restart=always \u52a0\u8fdb\u53bb                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487335\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : xivisi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @tinkerer \u6682\u65f6\u8fd9\u6837\u66b4\u529b\u89e3\u51b3\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u52a9\uff1a\u542f\u52a8\u5668\u4ece openrc \u5207\u6362&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/380474"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=380474"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/380474\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=380474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=380474"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=380474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}