<?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>nameserver &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/nameserver/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Tue, 03 Dec 2019 16:07:58 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>nameserver &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>curl 的詭異問題 &#8211; Vultr DNS 設定</title>
		<link>https://noter.tw/115/curl-%e7%9a%84%e8%a9%ad%e7%95%b0%e5%95%8f%e9%a1%8c-vultr-dns-%e8%a8%ad%e5%ae%9a/</link>
					<comments>https://noter.tw/115/curl-%e7%9a%84%e8%a9%ad%e7%95%b0%e5%95%8f%e9%a1%8c-vultr-dns-%e8%a8%ad%e5%ae%9a/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Sun, 16 Sep 2018 14:51:03 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Vultr]]></category>
		<category><![CDATA[resolv.conf]]></category>
		<category><![CDATA[nameserver]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[curl]]></category>
		<guid isPermaLink="false">https://noter.tw/?p=115</guid>

					<description><![CDATA[<p>之前朋友買了一台 Vultr 的主機，據說是蠻穩定的，而且重點是日本的機房 ping 大約只有 50ms 左右，一切聽起來都比小蛙用的遠在 LA，ping 隨便都 150ms 起跳來的強，但是價位也相&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/115/curl-%e7%9a%84%e8%a9%ad%e7%95%b0%e5%95%8f%e9%a1%8c-vultr-dns-%e8%a8%ad%e5%ae%9a/" data-wpel-link="internal">curl 的詭異問題 &#8211; Vultr DNS 設定</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>之前朋友買了一台 <a rel="noreferrer noopener nofollow external" href="https://www.vultr.com/" target="_blank" data-wpel-link="external" class="wpel-icon-right">Vultr<span class="wpel-icon wpel-image wpel-icon-6"></span></a> 的主機，據說是蠻穩定的，而且重點是日本的機房 ping 大約只有 50ms 左右，一切聽起來都比小蛙用的遠在 LA，ping 隨便都 150ms 起跳來的強，但是價位也相對偏高，今天遇到了一個奇怪的狀況，這邊記錄一下解決方法。 </p>



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



<p>今天接到朋友的求助，php curl 貌似有問題，朋友自己也不確定問題在哪裡，只知道 API 放在遠振一切正常，但是移到 vultr 就有問題，大約幾十個 request 會遇到一個等待到 timeout 的情況，當時小蛙人在外面，大概聽了問題，還不清楚確切的原因，因為 php curl 的對象是自己 &#8230; 是自己還會等到 timeout？</p>



<p>一開始看 code，釐清所有的功能之後，感覺上沒有什麼問題，於是想說在 command line 直接下 curl 看看狀況，雖然不一定會跟 php 下 curl 完全一樣的情況，但至少試試看不吃虧 ~ 下了 curl -v https://xxxxxxxxx 後，詭異的事情來了，竟然等了很久都沒反應，甚至有時候還會出現 timeout 或是名稱無法解析的問題，連 ping 自己的 hostname 都 ping 不到，這是什麼好笑的狀況 &#8230;</p>



<p>後來小蛙在 /etc/hosts 上加入了 domain 對應之後，curl 自己的 API 至少沒問題了，看起來可以大聲說打完收工了。不久之後，小蛙又接到朋友電話，說有某個 domain curl 等到 timeout，該 domain 是外部的，有了上面的經驗後，小蛙第一次時間就 ping 該 domain，喔買尬 &#8230; 名稱無法解析，那試試看 ping noter.tw，ㄜ ~ 名稱無法解析，看來是 DNS 的問題了！</p>



<h2 class="para wp-block-heading">設定 Nameserver</h2>



<p>上網查了一下 ubuntu 的 DNS 設定編輯 ，使用 Google 的 8.8.8.8 跟 8.8.4.4 就好了，換上之後一切正常。 </p>



<p>小蛙在查資料的過程中看到有些人問，每次重開機之後這個設定檔都會恢復預設值該怎麼辦，其他人提出的解法感覺很複雜，小蛙也懶得測試，於是跟朋友要了 vultr 的帳密，也許可以直接透過網站直接設定就好，切換到 Network 設定部份，果然找到設定的方法：</p>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://noter.tw/wp-content/uploads/2018/09/1537109032408.jpg" alt="1537109032408 curl 的詭異問題 - Vultr DNS 設定" class="wp-image-4078" title="curl 的詭異問題 - Vultr DNS 設定"></figure></div>



<h2 class="para wp-block-heading">開機後額外調整 resolv.conf 內容</h2>



<p>小蛙設定上去後 reboot，花惹發 &#8230; 又跑回原本的設定 108.61.10.10，嗯 ~ 只好使出比較下三濫的手法了，修改 .bashrc，可能有更正統或正規的作法，但 &#8230; 趕時間，又剛好想到這個方法，就 ~ 先這樣子吧！常常聽到 sed 跟 awk 是神兵級的，但小蛙一直不知道怎麼用，通常都是想到什麼功能好像有，去查一下正確用法來套，於是找到&nbsp;<a rel="noreferrer noopener nofollow external" href="https://www.phpini.com/linux/sed-delete-file-whole-line" target="_blank" data-wpel-link="external" class="wpel-icon-right">sed 搜尋並刪除整行資料<span class="wpel-icon wpel-image wpel-icon-6"></span></a> 這篇，設定完重開機，就可以看到效果了！</p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">vim .bashrc 
sed -i '/108.61.10.10/d' /etc/resolv.conf </pre>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/115/curl-%e7%9a%84%e8%a9%ad%e7%95%b0%e5%95%8f%e9%a1%8c-vultr-dns-%e8%a8%ad%e5%ae%9a/" data-wpel-link="internal">curl 的詭異問題 &#8211; Vultr DNS 設定</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/115/curl-%e7%9a%84%e8%a9%ad%e7%95%b0%e5%95%8f%e9%a1%8c-vultr-dns-%e8%a8%ad%e5%ae%9a/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
