<?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>SAMBA &#8211; acm&#039;s blog</title>
	<atom:link href="https://blog.acm.idv.tw/tag/samba/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.acm.idv.tw</link>
	<description>技術與生活隨筆</description>
	<lastBuildDate>Sat, 23 Sep 2023 02:40:54 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>

<image>
	<url>https://blog.acm.idv.tw/wp-content/uploads/2022/06/cropped-logo_kaffa9-3-32x32.png</url>
	<title>SAMBA &#8211; acm&#039;s blog</title>
	<link>https://blog.acm.idv.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>米家攝影機如何上傳影像至另一網段的NAS</title>
		<link>https://blog.acm.idv.tw/2023/09/23/%e7%b1%b3%e5%ae%b6%e6%94%9d%e5%bd%b1%e6%a9%9f%e5%a6%82%e4%bd%95%e4%b8%8a%e5%82%b3%e5%bd%b1%e5%83%8f%e8%87%b3%e5%8f%a6%e4%b8%80%e7%b6%b2%e6%ae%b5%e7%9a%84nas/</link>
					<comments>https://blog.acm.idv.tw/2023/09/23/%e7%b1%b3%e5%ae%b6%e6%94%9d%e5%bd%b1%e6%a9%9f%e5%a6%82%e4%bd%95%e4%b8%8a%e5%82%b3%e5%bd%b1%e5%83%8f%e8%87%b3%e5%8f%a6%e4%b8%80%e7%b6%b2%e6%ae%b5%e7%9a%84nas/#respond</comments>
		
		<dc:creator><![CDATA[kaffa9]]></dc:creator>
		<pubDate>Sat, 23 Sep 2023 02:40:54 +0000</pubDate>
				<category><![CDATA[技術]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[SAMBA]]></category>
		<category><![CDATA[小米]]></category>
		<category><![CDATA[米家]]></category>
		<guid isPermaLink="false">https://kaffa9.com/?p=795</guid>

					<description><![CDATA[我在A、B兩地都安裝了小米攝影機，其中A地有另外用Linux架設了SAMBA Server，供小米攝影機上傳影像（米家app的NAS設定）。為了讓影像資源的管理...<p class="read-more"><a class="btn btn-default" href="https://blog.acm.idv.tw/2023/09/23/%e7%b1%b3%e5%ae%b6%e6%94%9d%e5%bd%b1%e6%a9%9f%e5%a6%82%e4%bd%95%e4%b8%8a%e5%82%b3%e5%bd%b1%e5%83%8f%e8%87%b3%e5%8f%a6%e4%b8%80%e7%b6%b2%e6%ae%b5%e7%9a%84nas/"> Read More<span class="screen-reader-text">  Read More</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p>我在A、B兩地都安裝了小米攝影機，其中A地有另外用Linux架設了SAMBA Server，供小米攝影機上傳影像（米家app的NAS設定）。為了讓影像資源的管理集中，而且不另外在B地架設SAMBA Server，便有了讓B地攝影機將影像上傳至A地SAMBA Server（後稱SAMBA_A）的想法誕生。</p>



<p>上回說到我在A、B兩地之間建了Site-To-Site VPN (IPSec Tunnel)，因此A、B兩地之間的互連是沒有問題的。但我在米家app裡為B地攝影機進行NAS設定時還是卡關了，是什麼問題呢？</p>



<span id="more-795"></span>



<p>米家app第一次進行NAS設定時，會使用NBNS (NetBIOS Name Service) 協定發出廣播封包，待SAMBA Server收到時發出回應，藉此獲得整個區域網路內的SAMBA資訊，列成清單，供使用者在app內選擇。</p>



<p>乍聽之下，好像沒什麼毛病，問題在於<mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color"><strong>NBNS廣播封包只會在LAN端，不會被轉到WAN端，因此B地的小米攝影機發出NBNS廣播時，A地是完全收不到的</strong></mark>。</p>



<p>為了解決這個問題，拿了片樹莓派4B，架好SAMBA Server（後稱SAMBA_B），先在B地運行，讓B地的小米攝影機都先完成第一次NAS設定。接著將樹莓派的SAMBA服務停止，再透過app調整攝影機的NAS設定，直接將NAS名稱設定為SAMBA_A的IP位址，沒想到完全無效。（註：先前在小米N3做過此實驗可正常上傳影像，不知是不同型號的支援度有差還是何故，竟然沒辦法運作）</p>



<p>為了解決這個問題，我想起先前拜讀過的（也動手實作過）一篇文篇：《<a href="https://post.smzdm.com/p/axzep9k3/">跨网段环境下，小米摄像机配置NAS存储</a>》，文章裡頭提到一個轉發封包的小工具<a href="https://github.com/udp-redux/udp-broadcast-relay-redux">udp-boradcast-relay-redux</a>，可以用來將NBNS封包轉發到特定IP，這可成了救命稻草。</p>



<p>此前在閱讀此文時，文中方法是將udp-broadcast-relay-redux置於OpenWRT中執行，而我的網路環境使用的是UBNT EdgeRouter-X和Mikrotik RB570Gr3，未必能支援，而且已經折騰了好幾天，便沒深入思考這個方法還能怎麼套用在我的環境上。現在重新忖度……咦？在B地找台可以收得到NBNS廣播封包的機器來跑udp-broadcast-relay-redux不就成了嗎？不一定要靠路由器呀！</p>



<p>udp-broadcast-relay-redux雖是由C語言寫成，但沒有用到第三方函式庫，直接make即可順利獲得執行檔，接著我們指定封包轉傳到A地的SAMBA_A：</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo ./udp-broadcast-relay-redux --id 1 --port 137 --dev eth0 --dev wlan0 -t SAMBA_A_IP_ADDR</pre>



<p>此時再到米家app裡重新設定NAS，廣播封包順利被轉發到SAMBA_A，SAMBA_A也做出回應，從此B地攝影機和A地的NAS過著幸福快樂的日子。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.acm.idv.tw/2023/09/23/%e7%b1%b3%e5%ae%b6%e6%94%9d%e5%bd%b1%e6%a9%9f%e5%a6%82%e4%bd%95%e4%b8%8a%e5%82%b3%e5%bd%b1%e5%83%8f%e8%87%b3%e5%8f%a6%e4%b8%80%e7%b6%b2%e6%ae%b5%e7%9a%84nas/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
