{"id":1639,"date":"2015-12-10T11:42:04","date_gmt":"2015-12-10T03:42:04","guid":{"rendered":"http:\/\/www.51cos.com\/?p=1639"},"modified":"2015-12-10T11:47:53","modified_gmt":"2015-12-10T03:47:53","slug":"%e7%94%b1-ifconfig-siocsifflags-cannot-assign-requested-address-%e6%83%b3%e5%88%b0%e7%9a%84mac%e5%9c%b0%e5%9d%80%e6%9c%89%e6%95%88%e6%80%a7","status":"publish","type":"post","link":"http:\/\/www.51cos.com\/?p=1639","title":{"rendered":"\u7531 ifconfig: SIOCSIFFLAGS: Cannot assign requested address  \u60f3\u5230\u7684MAC\u5730\u5740\u6709\u6548\u6027"},"content":{"rendered":"<p>\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u9047\u5230\u4e00\u4e2a\u95ee\u9898\uff1a<\/p>\n<p>Ifconfig eth0 up \u65f6 ifconfig: SIOCSIFFLAGS: Cannot assign requested address \uff0c\u4ece\u800c\u5bfc\u81f4LAN \u4e0d\u53ef\u7528\uff0c<\/p>\n<p>\u6839\u636e\u767e\u5ea6\u7684\u89e3\u51b3\u65b9\u6cd5\uff0c\u662fMAC\u5730\u5740\u8bbe\u7f6e\u6709\u95ee\u9898\uff0c\u9700\u8981\u7528\u4e0b\u9762\u65b9\u6cd5\u8bbe\u7f6e\uff1a<\/p>\n<pre class=\"prettyprint linenums\">#\u53e6\u5916\u8bd5\u8bd5\u624b\u52a8\u8bbe\u7f6eMAC\uff1a<\/p>\n<p># ifconfig eth0 down<br \/>\n# ifconfig eth0 hw ether 9d:2c:64:78:35:2e<\/p>\n<p># ifconfig eth0 up<\/p>\n<p>\u4f46\u662f\u65b9\u6cd5\u65e0\u6548\uff0c\u540e\u6765\u53d1\u73b0\u662f\u201c9d:2c:64:78:35:2e\u201d\u4e0d\u5408\u6cd5\u5bfc\u81f4\u3002<\/p>\n<p>MAC\u5730\u5740\u662f\u4ee5\u592a\u7f51\u4e8c\u5c42\u4f7f\u7528\u7684\u4e00\u4e2a48bit\uff086\u5b57\u8282\u5341\u516d\u8fdb\u5236\u6570\uff09\u7684\u5730\u5740\uff0c\u7528\u6765\u6807\u8bc6\u8bbe\u5907\u4f4d\u7f6e\u3002MAC\u5730\u5740\u5206\u6210\u4e24\u90e8\u5206\uff0c\u524d24\u4f4d\u662f\u7ec4\u7ec7\u552f\u4e00\u6807\u8bc6\u7b26\uff08OUI, Organizationally unique identifier\uff09\uff0c\u540e24\u4f4d\u7531\u5382\u5546\u81ea\u884c\u5206\u914d\u3002<\/p>\n<p>MAC\u5730\u5740\u6709\u5355\u64ad\u3001\u7ec4\u64ad\u3001\u5e7f\u64ad\u4e4b\u5206\u3002\u5355\u64ad\u5730\u5740(unicast address)\u8868\u793a\u5355\u4e00\u8bbe\u5907\u3001\u8282\u70b9\uff0c\u591a\u64ad\u5730\u5740\u6216\u8005\u7ec4\u64ad\u5730\u5740(multicast address\u3001group address)\u8868\u793a\u4e00\u7ec4\u8bbe\u5907\u3001\u8282\u70b9\uff0c\u5e7f\u64ad\u5730\u5740(broadcast address)\u662f\u7ec4\u64ad\u7684\u7279\u4f8b\uff0c\u8868\u793a\u6240\u6709\u5730\u5740\uff0c\u7528\u5168F\u8868\u793a\uff1aFF-FF-FF-FF-FF-FF\u3002\u5f53\u7136\uff0c\u4e09\u5c42\u7684IP\u5730\u5740\u4e5f\u6709\u5355\u64ad\u3001\u7ec4\u64ad\u3001\u5e7f\u64ad\u4e4b\u5206\u3002<\/p>\n<p>48bit\u7684MAC\u5730\u5740\u4e00\u822c\u75286\u5b57\u8282\u7684\u5341\u516d\u8fdb\u5236\u6765\u8868\u793a\uff0c\u5982XX-XX-XX-XX-XX\u3002IEEE 802.3\u89c4\u5b9a\uff1a\u4ee5\u592a\u7f51\u7684\u7b2c48bit\u7528\u4e8e\u8868\u793a\u8fd9\u4e2a\u5730\u5740\u662f\u7ec4\u64ad\u5730\u5740\u8fd8\u662f\u5355\u64ad\u5730\u5740\u3002\u5982\u679c\u8fd9\u4e00\u4f4d\u662f0\uff0c\u8868\u793a\u6b64MAC\u5730\u5740\u662f\u5355\u64ad\u5730\u5740\uff0c\u5982\u679c\u8fd9\u4f4d\u662f1\uff0c\u8868\u793a\u6b64MAC\u5730\u5740\u662f\u591a\u64ad\u5730\u5740\u3002\u89c1IEEE 802.3 3.2.3 Address fields\uff1a \u201cThe first bit (LSB) shall be used in the Destination Address field as an address type designation bit to identify the Destination Address either as an individual or as a group address. If this bit is 0, it shall indicate that the address field contains an individual address. If this bit is 1, it shall indicate that the address field contains a group address that identifies none, one or more, or all of the stations connected to the LAN. In the Source Address field, the first bit is reserved and set to 0.\u201d<\/p>\n<p><strong>\u770b\u5230\u8fd9\u91cc\u5f88\u591a\u4eba\u90fd\u8ff7\u7cca\u4e86\uff0c\u4ee5\u592a\u7f51\u7684\u7b2c48bit \u548c The first bit (LSB) \u5230\u5e95\u662f\u54ea\u4e2aBit\uff1f<\/strong><\/p>\n<p>\u63a5\u7740\u5f80\u4e0b\u770b\uff1a<\/p>\n<p><strong>\u56e0\u4e3a\u4ee5\u592a\u7f51\u7ebf\u8def\u4e0a\u6309\u201cBig Endian\u201d\u5b57\u8282\u5e8f\u4f20\u9001\u62a5\u6587\uff08\u4e5f\u5c31\u662f\u6700\u9ad8\u5b57\u8282\u5148\u4f20\u9001\uff0c\u5173\u4e8e\u5b57\u8282\u5e8f\u8bf7\u53c2\u8003\u76f8\u5173\u6587\u6863\uff09\uff0c\u800c\u6bd4\u7279\u5e8f\u662f\u201dLittle Endian\u201d\uff08\u4e5f\u5c31\u662f\u6700\u4f4e\u4f4d\u5148\u4f20\u9001\uff09\u3002<\/strong>\u6240\u4ee5\u6709\u5982\u4e0b\u7684\u56fe\uff08\u4ece\u6700\u5de6\u8fb9\u5f00\u59cb\u4f20\u9001\uff09\uff0c\u7ed3\u5408\u4e0a\u8ff0\u6765\u7406\u89e3\u4e0b\u56fe\uff0c\u5b9e\u9645\u6240\u8bf4\u7684First Bit Transmitted\u662f<strong><span style=\"color: #ff0000;\">\u6700\u9ad8\u5b57\u8282\u7684\u6700\u4f4e\u4f4d<\/span><\/strong>\uff0c\u5373\u201c9d:2c:64:78:35:2e\u201d 9d\u5bf9\u5e94\u7684\u201c1001 110<strong>1<\/strong>\u201d\uff08\u7c97\u4f53\u90e8\u5206\uff09\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.51cos.com\/wp-content\/uploads\/2015\/12\/5d9bea632dc9315b15a6554ea800fda1.gif\" alt=\"\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u6ce8\u610f\u4e0a\u56fe\u7684\u5b57\u8282\u5e8f\u548c\u6bd4\u7279\u5e8f\u3002<\/p>\n<p>\u5b57\u8282\u5e8f\u4e3aBig-endian\uff0c\u5373\u6700\u9ad8\u5b57\u8282\u5728\u524d\u3002\u6240\u4ee5\u56fe\u4e2d\u7684first byte\u5b9e\u9645\u5bf9\u5e94\u7684MAC\u5730\u5740\u6700\u5de6\u8fb9\u4e00\u7ec4\u3002\u4ee5Note 2 MAC\u5730\u574090-18-7C-69-88-E2\u4e3a\u4f8b\uff0cfirst byte\u5c31\u662f\u201c90\u201d\uff08\u5982\u679c\u662fLittle-endian\uff0c\u5219first byte\u662f\u201cE2\u201d\uff09\uff0c\u5176OUI\u662fSamsungE\uff0c\u4ee3\u8868\u4e09\u661f\u7535\u5b50\u3002<\/p>\n<p>\u6bd4\u7279\u5e8f\u4e3aLittle-endian\uff0c\u5373\u6700\u4f4e\u4f4d\u5728\u524d\u3002\u8fd9\u5c31\u662f01-XX-XX-XX-XX-XX\u4e3a\u7ec4\u64ad\u5730\u5740\u7684\u539f\u56e0\u4e86\u3002\u56e0\u4e3a\u201c01\u201d\u5bf9\u5e94\u7684\u4e8c\u8fdb\u5236\u662f\u201c0000-0001\u201d\uff0c\u5176\u7b2c0\u4f4d\u662f1\uff0c\u5e94\u8be5\u653e\u5728\u56fe\u4e2dfirst byte\u6700\u5de6\u8fb9\u4e00\u683c\u3002<\/p>\n<p><strong>\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u5b57\u8282\u5e8f\u548c\u6bd4\u7279\u5e8f\u662f\u4e00\u81f4\u7684\u3002\u4f46\u662f\u4ee5\u592a\u7f51\u6570\u636e\u4f20\u8f93\u65f6\uff0c\u5b57\u8282\u5e8f\u91c7\u7528Big-endian\uff0c\u6bd4\u7279\u5e8f\u4e3aLittle-endian\u3002<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Linux\u4e2d\u4e5f\u6709\u4ee3\u7801\u9a8c\u8bc1MAC\u5730\u5740\u6709\u6548\u6027\uff1b<\/p>\n<pre class=\"prettyprint linenums\">static inline int is_valid_ether_addr(const u8 *addr)<br \/>\n{<br \/>\n    \/* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to<br \/>\n     * explicitly check for it here. *\/<br \/>\n    return !is_multicast_ether_addr(addr) &amp;&amp; !is_zero_ether_addr(addr);<br \/>\n}  <\/p>\n<p>\u53d1\u73b0\u7b2c\u4e00\u4e2a\u5b57\u8282\u6700\u4f4e\u4f4d\u4e3a1\u65f6\u8be5\u51fd\u6570\u5c31\u4f1a\u8fd4\u56de0\uff0cdriver\u4e2d\u7684set_mac_addr\u5c31\u4f1a\u8fd4\u56deEADDRNOTAVAIL\u9519\u8bef\u7801\u3002<\/p>\n<p>\u4e25\u683c\u6765\u8bf4mac\u5730\u5740\u5bf9\u4e8e\u6bcf\u5757\u7f51\u5361\u662f\u56fa\u5b9a\u7684\uff0c\u6bcf\u5757\u7f51\u5361\u88ab\u751f\u4ea7\u51fa\u6765\u540e\uff0c\u90fd\u4f1a\u6709\u4e00\u4e2a\u5168\u7403\u552f\u4e00\u7684\u7f16\u53f7\u6765\u6807\u8bc6\u81ea\u5df1\uff0c\u4e0d\u4f1a\u91cd\u590d\uff0c<\/p>\n<p>\u8fd9\u4e2a\u7f16\u53f7\u5c31\u662fMAC\u5730\u5740\uff0c\u4e5f\u5c31\u662f\u7f51\u5361\u7684\u7269\u7406\u5730\u5740\u3002MAC\u5730\u5740\u662f\u753148\u4f4d\u7684\u4e8c\u8fdb\u5236\u6570\u7ec4\u6210\uff0c\u53736\u4e2a\u5b57\u8282\u3002\u5728\u901a\u4fe1\u4e2d\u662f\u752816\u8fdb\u5236\u8868\u793a\u7684\u3002<\/p>\n<p>\u524d24\u4f4d\u662f\u7531\u751f\u4ea7\u5382\u5bb6\u5411IEEE\u6807\u51c6\u7ec4\u7ec7\u7533\u8bf7\u7684\u5382\u5bb6\u4ee3\u7801\uff0c\u662f\u56fa\u5b9a\u7684\uff0c\u4f46\u662f\u7b2c\u4e00\u4e2a\u5b57\u8282\u7684\u6700\u4f4e\u4f4d\u4e00\u5b9a\u662f0\uff0c\u56e0\u4e3a\u7f51\u5361\u7684\u7269\u7406\u5730\u5740\uff0c\u4e00\u5b9a\u662f\u5355\u64ad\u5730\u5740\uff0c<\/p>\n<p>\u5728IPv4\u7684\u73af\u5883\u4e2d\uff0c\u533a\u5206\u5355\u64ad\u548c\u7ec4\u64ad\u5730\u5740\u5c31\u662f\u6821\u68c0\u6700\u4f4e\u4f4d\u7684\u4e8c\u8fdb\u5236\u6570\u5b57\uff0c0\u4ee3\u8868\u5355\u64ad\u5730\u5740\uff0c1\u4ee3\u8868\u7ec4\u64ad\u5730\u5740\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\u7b2c\u4e8c\u4e2a\u6570\u5b57\u4e00\u5b9a\u662f0\u30012\u30014\u30016\u30018\u3001A\u3001C\u3001E\u5176\u4e2d\u7684\u4e00\u4e2a\u3002<\/p>\n<p>\u6240\u4ee5mac\u5730\u5740\u867d\u7136\u53ef\u4ee5\u4fee\u6539\uff0c\u4f46\u662f\u4e0d\u8981\u4e71\u6539\uff0c\u8981\u6309\u7167\u5382\u5546\u89c4\u5b9a\u6765\u4fee\u6539\uff0c\u4ee5\u514d\u91cd\u590d\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>WiKi\u4e0a\u7ed9\u51fa\u7684\u89e3\u91ca\u4e5f\u975e\u5e38\u8be6\u7ec6(<strong>\u8fd8\u662f\u4e0b\u56fe\u5bb9\u6613\u7406\u89e3\uff0cIEEE\u7684\u56fe\u592a\u6666\u6da9\u96be\u61c2\u4e86<\/strong>)\uff0c\u5177\u4f53\u53ef\u53c2\u8003\uff1ahttps:\/\/en.wikipedia.org\/wiki\/MAC_address<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.51cos.com\/wp-content\/uploads\/2015\/12\/f08d8a73703d8a5dcfa025a348d564d2.png\" srcset=\"\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/9\/94\/MAC-48_Address.svg\/713px-MAC-48_Address.svg.png 1.5x, \/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/9\/94\/MAC-48_Address.svg\/950px-MAC-48_Address.svg.png 2x\" alt=\"MAC-48 Address.svg\" width=\"475\" height=\"400\" data-file-width=\"475\" data-file-height=\"400\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u9047\u5230\u4e00\u4e2a\u95ee\u9898\uff1a Ifconfig eth0 up \u65f6 ifconfig: SIOCSIFFLAGS: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1639","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1639"}],"version-history":[{"count":4,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1639\/revisions"}],"predecessor-version":[{"id":1645,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1639\/revisions\/1645"}],"wp:attachment":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1639"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}