<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>設定 &#8211; 備忘程式碼</title>
	<atom:link href="https://www.weblink.idv.tw/tag/%E8%A8%AD%E5%AE%9A/feed" rel="self" type="application/rss+xml" />
	<link>https://www.weblink.idv.tw</link>
	<description>Javascript, PHP, HTML5 &#38; CSS3 coding memos</description>
	<lastBuildDate>Tue, 26 Mar 2024 03:15:38 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>玩泥巴玩到openWrt去</title>
		<link>https://www.weblink.idv.tw/2023/348</link>
					<comments>https://www.weblink.idv.tw/2023/348#comments</comments>
		
		<dc:creator><![CDATA[Steven LIU]]></dc:creator>
		<pubDate>Sat, 18 Mar 2023 08:39:55 +0000</pubDate>
				<category><![CDATA[etc]]></category>
		<category><![CDATA[AdGuard]]></category>
		<category><![CDATA[openwrt]]></category>
		<category><![CDATA[port forward]]></category>
		<category><![CDATA[pppoe]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[網路]]></category>
		<category><![CDATA[設定]]></category>
		<category><![CDATA[路由]]></category>
		<guid isPermaLink="false">https://www.weblink.idv.tw/?p=348</guid>

					<description><![CDATA[家裡網路早在8、9年前就用了光纖到府的100/40Mbps，不過說來慚愧，雖然明知跑不到全速，但這些年主Rou [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>家裡網路早在8、9年前就用了光纖到府的100/40Mbps，不過說來慚愧，雖然明知跑不到全速，但這些年主Router一直都是由Asus RT-N18U硬扛，最大的原因，就是我總覺得這類家用機器的預算不該超過兩千。可是這幾年不只網路技術突飛猛進，上網設備也是越來越多，從手機、平板、筆電、桌機、NAS、Web Server到智慧手錶，一家大大小小超過20台設備全都擠著RT-N18U進出抽插，就算咱家不掛網下BT，光是幾個設備同時串流看影片，也是真夠RT-N18U瞧的了。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img fetchpriority="high" decoding="async" width="1837" height="1102" src="https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic1.png" alt="" class="wp-image-413" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic1.png 1837w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic1-300x180.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic1-1024x614.png 1024w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic1-768x461.png 768w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic1-1536x921.png 1536w" sizes="(max-width: 1837px) 100vw, 1837px" /><figcaption class="wp-element-caption">▲要RT-N18U扛這麼多設備連線，著實難為人家了。</figcaption></figure>
</div>


<p>農曆年前做孝子，牙一咬幫爸媽換上兩台性能滿出來的高階筆電，網路也趁中華電信特價升級到了500/250Mbps（前陣子中華還佛心免費升成500/500Mbps）；只是這麼一來，網路速度就更被RT-N18U掐著脖子跑不上去，看來也的確是時候請這位老兄讓讓位了。</p>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9940075534877533"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-9940075534877533"
     data-ad-slot="4891658629"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<br>



<p>剛好，看到Asus在PC家大特價，便順勢讓兩台RT-N18U除役，換上性能三級跳的TUF-AX5400，一來AX5400可以兩台串Mesh，二來也想看看Wifi 6到底有多香。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="1837" height="1102" src="https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic2.png" alt="" class="wp-image-414" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic2.png 1837w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic2-300x180.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic2-1024x614.png 1024w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic2-768x461.png 768w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic2-1536x921.png 1536w" sizes="(max-width: 1837px) 100vw, 1837px" /><figcaption class="wp-element-caption">▲TUF-AX5400前陣子特價台票4,000有找，換來體驗一下Mesh與Wifi 6到底有多香，整體效能也是RT-N18U三級跳。</figcaption></figure>
</div>


<p>上機用了個兒把月，5GHz頻率確實順，SSID無縫切換也的確方便，Wifi 6速度提升更是暴力直接；但不知怎麼的，雖然AX5400的CPU與RAM使用率始終不高，無論是手機還是筆電，卻始終達不到即點即開的滑順體驗。</p>



<p>是我對滑順的期待太不切實際嗎？</p>



<p>或許是近十萬都開下去了，不試著把網路速度榨到一滴不剩就是不甘心。剛好筆電汰換下來的i5-5200U迷你桌機帶雙網孔（當年淘寶買的占美，機殼銳角超割手，也忘了當初為什麼買雙網孔機型），反正拿上網賣也換不了幾個錢，不如死馬當活馬醫（其實也沒那麼死馬，AX5400很夠用的），灌個openWrt跑Router，再掛個AdGuard Home還能順便擋廣告，一兼二顧何樂不為？</p>



<figure class="wp-block-image size-full"><img decoding="async" width="2560" height="1238" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/IMG_1025-scaled.jpg" alt="" class="wp-image-364" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/IMG_1025-scaled.jpg 2560w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/IMG_1025-300x145.jpg 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/IMG_1025-1024x495.jpg 1024w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/IMG_1025-768x371.jpg 768w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/IMG_1025-1536x743.jpg 1536w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/IMG_1025-2048x991.jpg 2048w" sizes="(max-width: 2560px) 100vw, 2560px" /><figcaption class="wp-element-caption">▲這台PC老歸老，i5-5200U / 8GB拿來跑Router一樣效能滿到天邊去，加上剛好有雙網孔，一定是老天爺要我拿來灌openWrt的sign。</figcaption></figure>



<p>網路上中英文資訊查了一堆，確定openWrt就算掛在隨身碟也不太會影響速度，就把桌機SSD拆下來、便宜搞了一隻SanDisk 32GB，花個百來塊開始動手瞎搞。</p>



<p>首先，因為小弟天性多疑，就算Lean、ImmortalWrt這些現成固件都開源放上gitHub了，不用擔心被開後門捅屁股，不過看到一堆對岸應用就是不舒坦；而且咱家Router很乖巧很單純的，PPPoE、DHCP這些基本設置外，多個Port forwarding、再掛個AdGuard Home就拍拍屁股結案了事。想了一下，還是從官方系統上老老實實裸奔吧！</p>



<h2 class="wp-block-heading">1. 下載與機器對應的img映像檔</h2>



<p>搞openWrt大致分兩路，一路是直接把手上的Wifi路由器刷上openWrt韌體，另一路就是像我這種秉持客家精神拿x86舊電腦來灌系統。Wifi路由器要刷openWrt比較麻煩，你要先找到<a rel="noreferrer noopener" href="https://openwrt.org/toh/start" data-type="URL" data-id="https://openwrt.org/toh/start" target="_blank">對應的型號或CPU</a>、下載到對的系統、用奇技淫巧把韌體刷進去，有些機子弄不好還會變磚。記得早期神機RT-N16刷DD-WRT時，總是戰戰兢兢，搞得跟拆炸彈似的……</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="768" height="576" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/33855398_OVR_2_1333x1000.webp" alt="" class="wp-image-351" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/33855398_OVR_2_1333x1000.webp 768w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/33855398_OVR_2_1333x1000-300x225.webp 300w" sizes="auto, (max-width: 768px) 100vw, 768px" /><figcaption class="wp-element-caption">▲RT-N16身為一代神機，別說你沒有刷過他！（網路圖片）</figcaption></figure>
</div>


<p>咳，扯遠了。</p>



<p>總之，x86電腦選擇單純得多，我是因為根本不懂squash姓啥名誰，所以直接用ext4版本。如果你也跟我一樣是用老電腦裝，選「<a rel="noreferrer noopener" href="https://downloads.openwrt.org/releases/22.03.3/targets/x86/64/openwrt-22.03.3-x86-64-generic-ext4-combined.img.gz" data-type="URL" data-id="https://downloads.openwrt.org/releases/22.03.3/targets/x86/64/openwrt-22.03.3-x86-64-generic-ext4-combined.img.gz" target="_blank">generic-ext4-combined.img.gz</a>」應該適用大部分情況。</p>



<h2 class="wp-block-heading">2. 解壓縮、刷進隨身碟</h2>



<p>在Mac OS我是用<a rel="noreferrer noopener" href="https://apps.apple.com/tw/app/the-unarchiver/id425424353?mt=12" data-type="URL" data-id="https://apps.apple.com/tw/app/the-unarchiver/id425424353?mt=12" target="_blank">Unarchiver</a>解壓縮、<a rel="noreferrer noopener" href="https://www.balena.io/etcher#download-etcher" data-type="URL" data-id="https://www.balena.io/etcher#download-etcher" target="_blank">BalenaEtcher</a>把openWrt寫進隨身碟；如果是windows應該就7.zip解壓縮、Rufus寫系統吧！？</p>



<h2 class="wp-block-heading">3. 改BIOS、重開機</h2>



<p>沒什麼新鮮事，進電腦改BIOS開機順序，插上隨身碟，重開機。</p>



<h2 class="wp-block-heading">4. Voila！openWrt安裝完成</h2>



<p>是的，安裝openWrt就是這麼樸實無華且粗暴。</p>



<h2 class="wp-block-heading">5. 基本設定：PPPoE、DHCP、關IPv6</h2>



<p>如果你跟我一樣，是在原本的架構下置換Router，那建議把所有設定都在openWrt上搞定了再移機比較好。</p>



<p>基本上Router最重要的功能，對外就是PPPoE撥號，對內就是DHCP讓設備取得IP上網，IPv6雖然先進但我不懂用、開著又礙眼，關掉！（唉對，root密碼進系統就先改掉了是常識，對吧？！）</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="911" height="626" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/PPPoE-redacted_dot_app.png" alt="" class="wp-image-353" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/PPPoE-redacted_dot_app.png 911w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/PPPoE-redacted_dot_app-300x206.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/PPPoE-redacted_dot_app-768x528.png 768w" sizes="auto, (max-width: 911px) 100vw, 911px" /><figcaption class="wp-element-caption">▲PPPoE設定簡單明瞭。</figcaption></figure>
</div>

<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="917" height="879" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/IPv6.png" alt="" class="wp-image-352" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/IPv6.png 917w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/IPv6-300x288.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/IPv6-768x736.png 768w" sizes="auto, (max-width: 917px) 100vw, 917px" /><figcaption class="wp-element-caption">▲IPv6停用參考設置。</figcaption></figure>
</div>


<h2 class="wp-block-heading">6. Firewall與Port Forwards</h2>



<p>接著因為架站，所以另外需要在Firewall裡設定Port Forwards，把https的埠號443指向內部的Web Server。我的IP編號習慣是，連接實體網路線的Web Server、NAS、桌機……這些設備走固定IP，無腦從192.168.1.2照順序往後排；至於走無線Wifi的手機、平板等就吃DHCP，編號從100起跳。這樣我很容易就能從IP位址快速判斷設備來源。（這樣分類只是我自己方便，如果有缺點還請大家不吝分享原因。）</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="983" height="827" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/firewall.png" alt="" class="wp-image-354" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/firewall.png 983w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/firewall-300x252.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/firewall-768x646.png 768w" sizes="auto, (max-width: 983px) 100vw, 983px" /><figcaption class="wp-element-caption">▲Drop Invalid Packets建議勾起來。</figcaption></figure>
</div>

<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="967" height="815" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/portforwards-redacted_dot_app.png" alt="" class="wp-image-356" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/portforwards-redacted_dot_app.png 967w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/portforwards-redacted_dot_app-300x253.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/portforwards-redacted_dot_app-768x647.png 768w" sizes="auto, (max-width: 967px) 100vw, 967px" /><figcaption class="wp-element-caption">▲Port Forwards可以個別選擇開或關很方便。</figcaption></figure>
</div>


<h2 class="wp-block-heading">7. 安裝AdGuard Home</h2>



<p>openWrt安裝軟體套件是用opkg而不是apt-get，一開始沒注意還嚇了一跳，想說apt怎麼openWrt看不懂。安裝AdGuard Home沒什麼稀奇，就是opkg install adguardhome按下去就幫你裝妥妥了。比較麻煩的是openWrt的設定，因為你還要告訴系統「以後DNS出去前還要多經過AdGuard Home這一關」，所以DNS forwardings要另外設定AdGurad Home埠號。</p>



<p>爬文看到網友說不建議AdGuard Home把原本系統的dnsmasq服務取代，所以53埠不去動他，讓AdGuard Home拿54埠。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="999" height="631" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/DNS.png" alt="" class="wp-image-357" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/DNS.png 999w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/DNS-300x189.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/DNS-768x485.png 768w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/DNS-200x125.png 200w" sizes="auto, (max-width: 999px) 100vw, 999px" /><figcaption class="wp-element-caption">▲DNS forwardings需要指定給AdGuard Home的埠號才有作用。</figcaption></figure>
</div>

<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="1339" height="775" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.16.59.png" alt="" class="wp-image-358" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.16.59.png 1339w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.16.59-300x174.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.16.59-1024x593.png 1024w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.16.59-768x445.png 768w" sizes="auto, (max-width: 1339px) 100vw, 1339px" /><figcaption class="wp-element-caption">▲看到AdGuard Home的數字在跳就是舒坦。</figcaption></figure>
</div>

<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="949" height="851" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/startup.png" alt="" class="wp-image-360" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/startup.png 949w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/startup-300x269.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/startup-768x689.png 768w" sizes="auto, (max-width: 949px) 100vw, 949px" /><figcaption class="wp-element-caption">▲看到網友說不建議AdGuard Home把原本系統的dnsmasq服務取代，所以53埠不去動他，讓AdGuard Home拿54埠。</figcaption></figure>
</div>


<h2 class="wp-block-heading">8. 測試、上機</h2>



<p>測試時我先直連小烏龜撥動態IP上網，等到所有設定都搞定，重開機確認一切正常後，我才用最快速度把openWrt換成主Router、改撥固定IP；至於AX5400，則是由路由器模式改成AP模式，另一台Mesh節點完全不用動。</p>



<p>實體操作上，只需要把原本小烏龜連AX5400 Wan孔的網路線改接到openWrt Wan孔上，然後openWrt Lan孔多牽一條網路線到Switch上而已，其他線路與設備的設定都完全一樣，家人甚至感覺不到有任何區別。（這應該是最理想的升級狀態吧？！）</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="1837" height="1102" src="https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic3.png" alt="" class="wp-image-416" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic3.png 1837w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic3-300x180.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic3-1024x614.png 1024w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic3-768x461.png 768w, https://www.weblink.idv.tw/wp-content/uploads/2023/12/pic3-1536x921.png 1536w" sizes="auto, (max-width: 1837px) 100vw, 1837px" /><figcaption class="wp-element-caption">▲整體架構與個別設備的設定不用動，抽換個Router網路效能就有感提升，整個素喜！</figcaption></figure>
</div>


<h2 class="wp-block-heading">9. 心得</h2>



<p>實際跑了幾個禮拜下來，這台Router幫我把煩人廣告擋掉一堆不說，即點即開的滑順感確實有達到我的預期。專業的學理或數據我不懂，純就體感上主觀覺得有再順上那麼一咪咪，而且i5 5200U / 8GB的配置輕鬆輾壓咱家不到30個設備上網的需求，負載從來沒超過10%；把Router功能從AX5400身上拔掉，讓他單純作為AP與Mesh節點來用，也釋放了大約50MB的記憶體用量出來。雖然原本AX5400效能就沒吃滿，不過分工更確實、工作量又降低，相信大夥兒也是非常滿意這樣的安排吧！嗯嗯！（點頭）</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="1097" height="1096" src="https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.28.35-redacted_dot_app.png" alt="" class="wp-image-361" srcset="https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.28.35-redacted_dot_app.png 1097w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.28.35-redacted_dot_app-300x300.png 300w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.28.35-redacted_dot_app-1024x1024.png 1024w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.28.35-redacted_dot_app-150x150.png 150w, https://www.weblink.idv.tw/wp-content/uploads/2023/03/截圖-2023-03-18-下午4.28.35-redacted_dot_app-768x767.png 768w" sizes="auto, (max-width: 1097px) 100vw, 1097px" /><figcaption class="wp-element-caption">▲用路由器模式運作時，AX5400的記憶體使用量大約70%（350MB），改成AP模式後掉到60%（300MB），實際感受倒是沒差別。</figcaption></figure>
</div>


<p>至於用退役的兩台RT-N18U刷機做VLAN，讓單條網路線上樓的配置，能收看第二台MOD、設備又在同個區網內，那又是另一個故事了……（菸）。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weblink.idv.tw/2023/348/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>純遠端初始設定Raspberry Pi (headless)</title>
		<link>https://www.weblink.idv.tw/2020/260</link>
					<comments>https://www.weblink.idv.tw/2020/260#respond</comments>
		
		<dc:creator><![CDATA[Steven LIU]]></dc:creator>
		<pubDate>Mon, 06 Apr 2020 15:23:15 +0000</pubDate>
				<category><![CDATA[RaspberryPi]]></category>
		<category><![CDATA[headless]]></category>
		<category><![CDATA[raspberrypi]]></category>
		<category><![CDATA[設定]]></category>
		<guid isPermaLink="false">https://www.weblink.idv.tw/?p=260</guid>

					<description><![CDATA[很久沒有增加備忘了，原因之前在近況更新裡面解釋過；去年底感覺我帶領的部門已經逐漸上軌道，案子慢慢可以由下面的同 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>很久沒有增加備忘了，原因之前在<a href="https://www.weblink.idv.tw/2018/177" target="_blank" rel="noopener noreferrer">近況更新</a>裡面解釋過；去年底感覺我帶領的部門已經逐漸上軌道，案子慢慢可以由下面的同仁自行運作了，便跟我老闆提說想離開 (他當然是大吃了一斤的____)，主要原因除了希望能休息一陣子 (肝指數真的被操到多了好幾項紅字阿&#8230;&#8230;)，其實更想花點時間精進coding的知識。交接過程拖拖磨磨，到了今年三月初才總算把棒子交了出去，回到家開始了半廢人的新生活。</p>



<p>這個wordpress的站一直是架在我的一台Raspberry Pi 3上面，練習coding可別拿正在服務的機子開刀；翻箱倒櫃找出了另一台原本拿來玩RetroPie的Pi 3出來，想要重新製作SD卡才發現，這幾年我已經把所有的作業移到筆電上了，桌機賣掉自然也不會留鍵盤滑鼠，但沒有鍵盤滑鼠要如何初始設定Pi呢？上網找了找才知道原來<a href="https://www.raspberrypi.org/documentation/configuration/wireless/headless.md" target="_blank" rel="noreferrer noopener">官方</a>就有提供方式，想到未來應該都會用這種方式去初始設定Pi，不如就好好備註在這裡以免忘記。</p>



<hr><p><h4>思考流程</h4><ul><li>因為沒有鍵盤滑鼠，所以希望直接以ssh連到Pi 3做設定</li><li>但Pi預設關閉ssh、wifi也需要另外設定</li><li>有沒有方法可以事先打開ssh、並設定好wifi SSID與密碼？</li><li style="color: red">找到headless方式</li><li>加入ssh檔案</li><li>加入wpa_supplicant.conf檔案</li><li>Pi開機，透過wifi路由器找到IP，ssh登入</li><li>結束收工</li></ul></p>



<hr><p><h4>設定步驟</h4><ol><li>下載<a href="https://www.raspberrypi.org/downloads/raspbian/" target="_blank" rel="noopener noreferrer">Raspbian的映像檔</a>、解壓縮 (Noobs沒有鍵盤滑鼠應該是完全沒辦法安裝，省省吧)</li><li><a href="https://www.sdcard.org/downloads/formatter/" target="_blank" rel="noopener noreferrer">SD card formatter</a>去格式化記憶卡、<a href="https://win32diskimager.download/" target="_blank" rel="noopener noreferrer">Win32DiskImager</a>把映像檔解進記憶卡內</li><li>用windows內建的「記事本」製作一個檔名為”ssh”的空檔案(不要有後綴.txt)</li><li>把這個”ssh”檔案放進記憶卡的根目錄內</li><img loading="lazy" decoding="async" width="450" height="383" class="wp-image-262" style="width: 450px;" src="https://www.weblink.idv.tw/wp-content/uploads/2020/04/sshImg.jpg" alt="" srcset="https://www.weblink.idv.tw/wp-content/uploads/2020/04/sshImg.jpg 1746w, https://www.weblink.idv.tw/wp-content/uploads/2020/04/sshImg-300x255.jpg 300w, https://www.weblink.idv.tw/wp-content/uploads/2020/04/sshImg-1024x872.jpg 1024w, https://www.weblink.idv.tw/wp-content/uploads/2020/04/sshImg-768x654.jpg 768w, https://www.weblink.idv.tw/wp-content/uploads/2020/04/sshImg-1536x1307.jpg 1536w" sizes="auto, (max-width: 450px) 100vw, 450px" /><li>用程式編輯軟體 (例如VS Code) 製作一個檔名為”wpa_supplicant.conf”的檔案</li><li>檔案內容：<br>



<pre class="wp-block-code"><code>ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=TW

network={
 ssid="輸入你的wifi ssid"
 psk="輸入wifi密碼" //若wifi沒有密碼則此行要改成下行：
 //key_mgmt=NONE 
}</code></pre>



</li><li>同樣把wpa_supplicant.conf放在記憶卡的根目錄</li><li>Pi以記憶卡開機，進入路由器設定頁面，找到Pi的IP</li><img loading="lazy" decoding="async" width="450" height="95" class="wp-image-269" style="width: 450px;" src="https://www.weblink.idv.tw/wp-content/uploads/2020/04/ipImg.jpg" alt="" srcset="https://www.weblink.idv.tw/wp-content/uploads/2020/04/ipImg.jpg 1800w, https://www.weblink.idv.tw/wp-content/uploads/2020/04/ipImg-300x63.jpg 300w, https://www.weblink.idv.tw/wp-content/uploads/2020/04/ipImg-1024x215.jpg 1024w, https://www.weblink.idv.tw/wp-content/uploads/2020/04/ipImg-768x161.jpg 768w, https://www.weblink.idv.tw/wp-content/uploads/2020/04/ipImg-1536x323.jpg 1536w" sizes="auto, (max-width: 450px) 100vw, 450px" /><li>PuTTY走ssh連進Pi，輸入預設帳密</li><li>結束收工</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weblink.idv.tw/2020/260/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
