{"id":18635,"date":"2014-12-01T06:14:22","date_gmt":"2014-11-30T22:14:22","guid":{"rendered":"https:\/\/2blog.ilc.edu.tw\/25793\/2014\/12\/01\/cubie-truck-%e6%b8%ac%e8%a9%a6-archlinux-%e6%88%90%e7%82%ba%e7%84%a1%e7%b7%9a-ap\/"},"modified":"2021-03-18T17:24:12","modified_gmt":"2021-03-18T09:24:12","slug":"cubie-truck-%e6%b8%ac%e8%a9%a6-archlinux-%e6%88%90%e7%82%ba%e7%84%a1%e7%b7%9a-ap","status":"publish","type":"post","link":"https:\/\/2blog.ilc.edu.tw\/25793\/2014\/12\/01\/cubie-truck-%e6%b8%ac%e8%a9%a6-archlinux-%e6%88%90%e7%82%ba%e7%84%a1%e7%b7%9a-ap\/","title":{"rendered":"Cubie Truck \u6e2c\u8a66 &#8211; ArchLinux \u6210\u70ba\u7121\u7dda AP"},"content":{"rendered":"<p>\u53c3\u8003\u7db2\u9801\uff1a <br \/><a href=\"https:\/\/wiki.archlinux.org\/index.php\/Dhcpd\" target=\"_blank\" rel=\"noopener noreferrer\">dhcpd &#8211; ArchWiki<\/a> <\/p>\n<p>\u5b89\u88dd hostapd <br \/># <span style=\"color: #ff0000\">pacman -S hostapd<\/span> <\/p>\n<p>\u5b89\u88dd DHCP Server <br \/># <span style=\"color: #ff0000\">pacman -S dhcp<\/span> <\/p>\n<p>\u5099\u4efd\u539f\u8a2d\u5b9a\u6a94 <br \/># <span style=\"color: #ff0000\">mv \/etc\/dhcpd.conf \/etc\/dhcpd.conf.$(date +%F)<\/span> <\/p>\n<p>\u5efa\u7acb DHCP Server \u8a2d\u5b9a\u6a94 <br \/># <span style=\"color: #ff0000\">vim \/etc\/dhcpd.conf<\/span> <br \/><span style=\"color: #0000ff\">ddns-update-style none; <\/span> <br \/><span style=\"color: #0000ff\">option domain-name &#8220;example.org&#8221;; <\/span> <br \/><span style=\"color: #0000ff\">option domain-name-servers ns1.example.org, ns2.example.org; <\/span> <br \/><span style=\"color: #0000ff\">default-lease-time 600; <\/span> <br \/><span style=\"color: #0000ff\">max-lease-time 7200; <\/span> <br \/><span style=\"color: #0000ff\">log-facility local7; <\/span> <br \/><span style=\"color: #0000ff\">subnet 172.16.0.0 netmask 255.255.255.0 { <\/span> <br \/><span style=\"color: #0000ff\">\u00a0 \u00a0 range 172.16.0.1 172.16.0.10; <\/span> <br \/><span style=\"color: #0000ff\">\u00a0 \u00a0 option domain-name-servers 168.95.1.1; <\/span> <br \/><span style=\"color: #0000ff\">\u00a0 \u00a0 option domain-name-servers 8.8.8.8; <\/span> <br \/><span style=\"color: #0000ff\">\u00a0 \u00a0 option routers 172.16.0.254; <\/span> <br \/><span style=\"color: #0000ff\">}[@more@]<\/span><\/p>\n<p># <span style=\"color: #ff0000\">vim \/etc\/systemd\/system\/dhcpd4@.service<\/span><br \/><span style=\"color: #0000ff\">[Unit]<\/span><br \/><span style=\"color: #0000ff\">Description=IPv4 DHCP server on %I<\/span><br \/><span style=\"color: #0000ff\">Wants=network.target<\/span><br \/><span style=\"color: #0000ff\">After=network.target<\/span><\/p>\n<p><span style=\"color: #0000ff\">[Service]<\/span><br \/><span style=\"color: #0000ff\">Type=forking<\/span><br \/><span style=\"color: #0000ff\">PIDFile=\/run\/dhcpd4.pid<\/span><br \/><span style=\"color: #0000ff\">ExecStart=\/usr\/bin\/dhcpd -4 -q -pf \/run\/dhcpd4.pid %I<\/span><br \/><span style=\"color: #0000ff\">KillSignal=SIGINT<\/span><\/p>\n<p><span style=\"color: #0000ff\">[Install]<\/span><br \/><span style=\"color: #0000ff\">WantedBy=multi-user.target<\/span><\/p>\n<p>\u4fee\u6539 wlan0\u00a0\u7db2\u8def\u5361\u8a2d\u5b9a<br \/># <span style=\"color: #ff0000\">cat \/etc\/netctl\/wlan0<\/span><br \/><span style=\"color: #0000ff\">Description=&#8217;A simple WPA encrypted wireless connection using a static IP&#8217;<\/span><br \/><span style=\"color: #0000ff\">Interface=wlan0<\/span><br \/><span style=\"color: #0000ff\">Connection=ethernet<\/span><br \/><span style=\"color: #0000ff\">AutoWired=yes<\/span><br \/><span style=\"color: #0000ff\">IP=static<\/span><br \/><span style=\"color: #0000ff\">Address=&#8217;172.16.0.254\/24&#8242;<\/span><br \/><span style=\"color: #0000ff\">DNS=(&#8216;168.95.1.1&#8217; &#8216;140.111.66.1&#8217; &#8216;8.8.8.8&#8217;)<\/span><br \/><span style=\"color: #0000ff\"># Uncomment this if your ssid is hidden<\/span><br \/><span style=\"color: #0000ff\">#Hidden=yes<\/span><\/p>\n<p>\u91cd\u65b0\u555f\u52d5 wlan0<br \/># <span style=\"color: #ff0000\">netctl restart wlan0<\/span><\/p>\n<p># <span style=\"color: #ff0000\">ifconfig wlan0<\/span><br \/><span style=\"color: #0000ff\">wlan0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;\u00a0 mtu 1500<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet 172.16.0.254\u00a0 netmask 255.255.255.0\u00a0 broadcast 172.16.0.255<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet6 fe80::9a3b:16ff:fe1e:67d8\u00a0 prefixlen 64\u00a0 scopeid 0x20&lt;link&gt;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ether 98:3b:16:1e:67:d8\u00a0 txqueuelen 1000\u00a0 (Ethernet)<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets 15\u00a0 bytes 1914 (1.8 KiB)<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX errors 0\u00a0 dropped 0\u00a0 overruns 0\u00a0 frame 0<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets 69\u00a0 bytes 7236 (7.0 KiB)<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX errors 0\u00a0 dropped 0 overruns 0\u00a0 carrier 0\u00a0 collisions 0<\/span><\/p>\n<p>\u555f\u52d5 DHCP Server<br \/># <span style=\"color: #ff0000\">systemctl start dhcpd4@wlan0.service<\/span><\/p>\n<p>\u8a2d\u5b9a\u958b\u6a5f\u6642\u555f\u52d5 DHCP Server<br \/># <span style=\"color: #ff0000\">systemctl enable dhcpd4@wlan0.service<\/span><br \/><span style=\"color: #0000ff\">Created symlink from \/etc\/systemd\/system\/multi-user.target.wants\/dhcpd4@wlan0.service to \/etc\/systemd\/system\/dhcpd4@.service.<\/span><\/p>\n<p>\u8a2d\u5b9a\u9632\u706b\u7246<br \/># <span style=\"color: #ff0000\">vim \/etc\/firewall.wifiap<\/span><br \/><span style=\"color: #0000ff\">#!\/bin\/bash<\/span><br \/><span style=\"color: #0000ff\">IPTABLES=\/sbin\/iptables<\/span><br \/><span style=\"color: #0000ff\">$IPTABLES -F<\/span><br \/><span style=\"color: #0000ff\">$IPTABLES -F -t nat<\/span><br \/><span style=\"color: #0000ff\">$IPTABLES -X<\/span><\/p>\n<p><span style=\"color: #0000ff\">$IPTABLES -P INPUT ACCEPT<\/span><br \/><span style=\"color: #0000ff\">$IPTABLES -P OUTPUT ACCEPT<\/span><br \/><span style=\"color: #0000ff\">$IPTABLES -P FORWARD ACCEPT<\/span><\/p>\n<p><span style=\"color: #0000ff\">modprobe ip_conntrack<\/span><br \/><span style=\"color: #0000ff\">modprobe iptable_nat<\/span><br \/><span style=\"color: #0000ff\">modprobe ip_conntrack_ftp<\/span><br \/><span style=\"color: #0000ff\">modprobe ip_nat_ftp<\/span><\/p>\n<p><span style=\"color: #0000ff\">echo 1 &gt; \/proc\/sys\/net\/ipv4\/ip_forward<\/span><br \/><span style=\"color: #0000ff\">$IPTABLES -t nat -A POSTROUTING -j MASQUERADE<br \/><\/span><br \/>\u57f7\u884c\u9632\u706b\u7246\u898f\u5247<br \/># <span style=\"color: #ff0000\">sh \/etc\/firewall.wifiap<\/p>\n<p><\/span><span style=\"color: #ff0000\"><span style=\"color: #000000\">\u5728 \/etc\/rc.local\u00a0\u00a0\u6a94\u6848\u6700\u5f8c\u9762\u52a0\u5165\u57f7\u884c\u9632\u706b\u7246\u898f\u5247\u7684\u8a2d\u5b9a<\/span><br \/><span style=\"color: #000000\">#<\/span> sed -i &#8216;$a # NAT \u9632\u706b\u7246nsh \/etc\/firewall.wifiap&#8217; \/etc\/rc.local<\/p>\n<p><span style=\"color: #000000\">\u8a2d\u5b9a hostapd<\/span><br \/><\/span><span style=\"color: #ff0000\"><span style=\"color: #000000\">#<\/span> <span style=\"color: #ff0000\">cat\u00a0\/etc\/hostapd\/hostapd.conf<\/span><br \/><span style=\"color: #0000ff\">interface=wlan0<\/span><br \/><span style=\"color: #0000ff\">driver=nl80211<\/span><br \/><span style=\"color: #0000ff\">ssid=CubieTruck<\/span><br \/><span style=\"color: #0000ff\">channel=11<\/span><br \/><span style=\"color: #0000ff\">hw_mode=g<\/span><br \/><span style=\"color: #0000ff\">macaddr_acl=0<\/span><br \/><span style=\"color: #0000ff\">auth_algs=1<\/span><br \/><span style=\"color: #0000ff\">ignore_broadcast_ssid=0<\/span><br \/><span style=\"color: #0000ff\">wpa=2<\/span><br \/><span style=\"color: #0000ff\">wpa_psk=ee07bee15c9c33bf7bcc53d84aac17e2b83f82476f96e32efcd03d716d99a4d2<\/span><br \/><span style=\"color: #0000ff\">wpa_key_mgmt=WPA-PSK<\/span><br \/><span style=\"color: #0000ff\">rsn_pairwise=CCMP<\/p>\n<p><span style=\"color: #000000\">\u57f7\u884c hostapd<\/span><br \/><span style=\"color: #000000\">#<\/span> <span style=\"color: #ff0000\">systemctl start hostapd<\/span><\/p>\n<p><span style=\"color: #000000\">\u67e5\u8a62\u57f7\u884c\u72c0\u614b<\/span><br \/><\/span><\/span><span style=\"color: #ff0000\"><span style=\"color: #0000ff\"><span style=\"color: #ff0000\"><span style=\"color: #0000ff\"><span style=\"color: #000000\">#<\/span> <span style=\"color: #ff0000\">systemctl status hostapd<\/span><br \/><\/span><\/span>\u25cf hostapd.service &#8211; Hostapd IEEE 802.11 AP, IEEE 802.1X\/WPA\/WPA2\/EAP\/RADIUS Authenticator<br \/>\u00a0\u00a0 Loaded: loaded (\/usr\/lib\/systemd\/system\/hostapd.service; enabled)<br \/>\u00a0\u00a0 Active: active (running) since Tue 2014-10-14 13:23:38 CST; 1s ago<br \/>\u00a0 Process: 353 ExecStart=\/usr\/bin\/hostapd \/etc\/hostapd\/hostapd.conf -P \/run\/hostapd.pid -B (code=exited, status=0\/SUCCESS)<br \/>\u00a0Main PID: 354 (hostapd)<br \/>\u00a0\u00a0 CGroup: \/system.slice\/hostapd.service<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u2514\u2500354 \/usr\/bin\/hostapd \/etc\/hostapd\/hostapd.conf -P \/run\/hostapd.pid -B<\/p>\n<p><span style=\"color: #000000\">\u76f4\u63a5\u4f7f\u7528\u547d\u4ee4\u5217\u57f7\u884c<\/span><br \/><span style=\"color: #000000\">#<\/span><span style=\"color: #ff0000\"> \/usr\/bin\/hostapd \/etc\/hostapd\/hostapd.conf -P \/run\/hostapd.pid -B<\/span><br \/>Configuration file: \/etc\/hostapd\/hostapd.conf<br \/>Using interface wlan0 with hwaddr 98:3b:16:1e:67:d8 and ssid &#8220;CubieTruck&#8221;<br \/>wlan0: interface state UNINITIALIZED-&gt;ENABLED<br \/>wlan0: AP-ENABLED<\/p>\n<p><span style=\"color: #000000\">\u8a2d\u5b9a\u958b\u6a5f\u6642\u57f7\u884c<\/span><br \/><span style=\"color: #000000\">#<\/span> <span style=\"color: #ff0000\">systemctl enable hostapd<\/span><br \/><\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53c3\u8003\u7db2\u9801\uff1a dhcpd &#8211; ArchWiki \u5b89\u88dd hostapd # pacman -S hos &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/2blog.ilc.edu.tw\/25793\/2014\/12\/01\/cubie-truck-%e6%b8%ac%e8%a9%a6-archlinux-%e6%88%90%e7%82%ba%e7%84%a1%e7%b7%9a-ap\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008Cubie Truck \u6e2c\u8a66 &#8211; ArchLinux \u6210\u70ba\u7121\u7dda AP\u3009<\/span><\/a><\/p>\n","protected":false},"author":55,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[167,170],"tags":[],"class_list":["post-18635","post","type-post","status-publish","format-standard","hentry","category-c-84386","category-c-85297"],"meta_key":{"_pingme":["1"],"_encloseme":["1"],"lt_post_id":["523400"]},"_links":{"self":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18635"}],"collection":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/comments?post=18635"}],"version-history":[{"count":1,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18635\/revisions"}],"predecessor-version":[{"id":20256,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18635\/revisions\/20256"}],"wp:attachment":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/media?parent=18635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/categories?post=18635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/tags?post=18635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}