最近伺服器只要重開PPPOE就會撥接不上,本來還以為是switch topology有誤,後來總算是發現原來是wan interface沒有正確assign到em0,重新assign後問題解決。
參考資料:
自己
2017年4月13日 星期四
2016年12月21日 星期三
virtualbox guest windows OS network issue
遇到一個問題是guest OS windows會不定期網路沒有網際網路,後來發現host有裝vmplayer,將vmware network adapter停用後目前問題解除,待觀察
經過一陣子觀察之後沒有再出現異常,應該是這個問題沒錯,有遇到相同問題的人可以一試
20170201更新
還是有問題發生,暫停guest os再取消暫停之後可以回復網路狀態
參考資料
自己
經過一陣子觀察之後沒有再出現異常,應該是這個問題沒錯,有遇到相同問題的人可以一試
20170201更新
還是有問題發生,暫停guest os再取消暫停之後可以回復網路狀態
參考資料
自己
2016年4月19日 星期二
Windows 10 磁碟空間 storage space經驗分享
最近想組raid保護資料,研究了一下發現硬體raid可能有風險,如果controller壞掉的話必須要找到相同晶片資料才可以救援,而且同樣容量的硬碟外接硬碟比裸碟便宜不少。所以後來看了資料後決定使用windows自身的軟體raid機制。
先是發現windows7不支援外接硬碟布建軟體raid,本來看到有人說可以更改分割表的bit把硬碟顯示為fix,後來看了一下發現是發文者弄錯了。後來看到windows8以上可以使用新功能-磁碟空間(storage space)可以使用外接硬碟,就決定將系統升級到windows10。
本來想要架raid5,買了兩顆3TB的硬碟加上原有的一顆三組,後來接上去之後發現windows磁碟空間的架構與硬體不同,不需用到整顆硬碟容量做設定可以切割。於是先分割小空間做測試,傳輸檔案時發現速度非常慢,usb 3.0速度僅有10MB/s,實在是不可思議,本來想說沒救了,後來看到有人分享加速的方法,原來是windows考量到power failure的可能將寫入快取取消限制效能。
開啟加速方法如下:
最後是virtualbox在升級到windows10後發生網卡找不到問題,同樣搜尋後找到必須解除安裝後重新安裝virtualbox問題解決。
參考資料
storage space加速
https://social.technet.microsoft.com/Forums/windowsserver/en-US/64aff15f-2e34-40c6-a873-2e0da5a355d2/parity-storage-space-so-slow-that-its-unusable?forum=winserver8gen
同位(raid5)寫入速度慢
http://blogs.technet.com/b/mspfe/archive/2013/02/25/why-windows-server-2012-parity-storage-spaces-might-perform-slowly.aspx
virtualbox找不到網卡問題
http://ftcforum.usfirst.org/showthread.php?4898-Error-relaunching-the-VirtualBox
先是發現windows7不支援外接硬碟布建軟體raid,本來看到有人說可以更改分割表的bit把硬碟顯示為fix,後來看了一下發現是發文者弄錯了。後來看到windows8以上可以使用新功能-磁碟空間(storage space)可以使用外接硬碟,就決定將系統升級到windows10。
本來想要架raid5,買了兩顆3TB的硬碟加上原有的一顆三組,後來接上去之後發現windows磁碟空間的架構與硬體不同,不需用到整顆硬碟容量做設定可以切割。於是先分割小空間做測試,傳輸檔案時發現速度非常慢,usb 3.0速度僅有10MB/s,實在是不可思議,本來想說沒救了,後來看到有人分享加速的方法,原來是windows考量到power failure的可能將寫入快取取消限制效能。
開啟加速方法如下:
- 使用系統管理員權限開啟powershell
- 輸入Get-StoragePool,找到FriendlyName
- 輸入Set-StoragePool -FriendlyName <Storage Pool Name> -IsPowerProtected $True
最後是virtualbox在升級到windows10後發生網卡找不到問題,同樣搜尋後找到必須解除安裝後重新安裝virtualbox問題解決。
參考資料
storage space加速
https://social.technet.microsoft.com/Forums/windowsserver/en-US/64aff15f-2e34-40c6-a873-2e0da5a355d2/parity-storage-space-so-slow-that-its-unusable?forum=winserver8gen
同位(raid5)寫入速度慢
http://blogs.technet.com/b/mspfe/archive/2013/02/25/why-windows-server-2012-parity-storage-spaces-might-perform-slowly.aspx
virtualbox找不到網卡問題
http://ftcforum.usfirst.org/showthread.php?4898-Error-relaunching-the-VirtualBox
2016年3月1日 星期二
gmail inbox chrome這個網頁無法使用問題
幾天前開始遇到這個問題,一開始懷疑是router出問題,也查了DNS。後來注意到同一台電腦IE可以但chrome不行,於是開始清cookie,但還是不行。花了不少時間最後發現error是ERR_QUIC_PROTOCOL_ERROR,參考網頁到chrome://flags/#enable-quic將實驗性 QUIC 通訊協定。停用後問題解決,看來是chrome實驗性的東西出問題,供大家參考。
參考資料
http://stackoverflow.com/questions/28195610/why-is-this-error-appearing-in-chrome-load-resource-neterr-quic-protocol-erro
參考資料
http://stackoverflow.com/questions/28195610/why-is-this-error-appearing-in-chrome-load-resource-neterr-quic-protocol-erro
windows command prompt 命令提示字元突然無法顯示中文
今天命令提示字元突然無法顯示中文,處理了整個下午找解法,後來自己找到方法是先在控制台-地區-系統管理-非unicode程式的語言改成中文(簡體, 中國)然後重新啟動後再改回中文(繁體, 台灣)才成功解決。
明明一開始就是中文(繁體, 台灣)的呀...不禁讓人想到是不是又是中國搞的鬼....orz
參考資料
自己
明明一開始就是中文(繁體, 台灣)的呀...不禁讓人想到是不是又是中國搞的鬼....orz
參考資料
自己
2015年12月2日 星期三
iptables
iptables 需要將ppp設為MASQUERADE偽裝IP才有辦法連到internet,但是這樣做會造成inner ip顯示全部變為gateway ip。修正方法為改用SNAT加指定EXTIP,但是就變成要有固定IP才可以使用。
出現錯誤訊息
Options error: server and client cannot be used together
代表conf檔案內有用到不是server指令的指令
iptables restart in ubuntu
sudo service ufw stop
sudo service ufw start
刪除單一chain下的規則
enable forwarding in ubuntu
echo 1 >/proc/sys/net/ipv4/ip_forward
如果要兩個網路能夠成功的達成路由﹐對方網路也必須有相應的路由設定指向本地網路才行
pfsense 內 openvpn檔案存放位置/var/etc/openvpn
traceroute
mac: traceroute
dos: tracert
linux: tracepath
terminate openvpn
sudo killall openvpn
參考資料
http://acman.bluenest.net/wordpress/archives/118
http://askubuntu.com/questions/298419/how-to-disconnect-from-openvpn
iptables
http://serverfault.com/questions/431593/iptables-forwarding-between-two-interface
http://askubuntu.com/questions/161551/how-to-start-stop-iptables
http://stackoverflow.com/questions/8239047/iptables-how-to-delete-postrouting-rule
http://s2.naes.tn.edu.tw/~kv/iptables.htm
https://gigenchang.wordpress.com/2014/04/19/10%E5%88%86%E9%90%98%E5%AD%B8%E6%9C%83iptables/
http://www.pcnet.idv.tw/pcnet/network/network_ip_routing.htm
pfsense存放位置
https://forum.pfsense.org/index.php?topic=13123.0
openvpn with two interface in and out
https://forums.openvpn.net/topic11033.html
https://forums.openvpn.net/topic14072.html
http://ubuntuforums.org/showthread.php?t=1606136
route
http://yinung2.blogspot.tw/2013/05/route_17.html
bridge vs routing
https://community.openvpn.net/openvpn/wiki/BridgingAndRouting
https://openvpn.net/index.php/open-source/documentation/miscellaneous/76-ethernet-bridging.html
chain using openvpn
http://serverfault.com/questions/512160/vpn-chaining-using-openvpn
dns server on openvpn
http://superuser.com/questions/637579/setting-dns-servers-using-openvpn-client-config-file
show route on mac
http://stackoverflow.com/questions/6782658/how-to-get-default-gateway-in-mac-osx
自己
出現錯誤訊息
Options error: server and client cannot be used together
代表conf檔案內有用到不是server指令的指令
iptables restart in ubuntu
sudo service ufw stop
sudo service ufw start
刪除單一chain下的規則
iptables -t nat -D POSTROUTING <number>
enable forwarding in ubuntu
echo 1 >/proc/sys/net/ipv4/ip_forward
如果要兩個網路能夠成功的達成路由﹐對方網路也必須有相應的路由設定指向本地網路才行
pfsense 內 openvpn檔案存放位置/var/etc/openvpn
traceroute
mac: traceroute
dos: tracert
linux: tracepath
terminate openvpn
sudo killall openvpn
參考資料
http://acman.bluenest.net/wordpress/archives/118
http://askubuntu.com/questions/298419/how-to-disconnect-from-openvpn
iptables
http://serverfault.com/questions/431593/iptables-forwarding-between-two-interface
http://askubuntu.com/questions/161551/how-to-start-stop-iptables
http://stackoverflow.com/questions/8239047/iptables-how-to-delete-postrouting-rule
http://s2.naes.tn.edu.tw/~kv/iptables.htm
https://gigenchang.wordpress.com/2014/04/19/10%E5%88%86%E9%90%98%E5%AD%B8%E6%9C%83iptables/
http://www.pcnet.idv.tw/pcnet/network/network_ip_routing.htm
pfsense存放位置
https://forum.pfsense.org/index.php?topic=13123.0
openvpn with two interface in and out
https://forums.openvpn.net/topic11033.html
https://forums.openvpn.net/topic14072.html
http://ubuntuforums.org/showthread.php?t=1606136
route
http://yinung2.blogspot.tw/2013/05/route_17.html
bridge vs routing
https://community.openvpn.net/openvpn/wiki/BridgingAndRouting
https://openvpn.net/index.php/open-source/documentation/miscellaneous/76-ethernet-bridging.html
chain using openvpn
http://serverfault.com/questions/512160/vpn-chaining-using-openvpn
dns server on openvpn
http://superuser.com/questions/637579/setting-dns-servers-using-openvpn-client-config-file
show route on mac
http://stackoverflow.com/questions/6782658/how-to-get-default-gateway-in-mac-osx
自己
2015年11月9日 星期一
Google問卷根據地址自動查詢3+2郵遞區號
因為最近在準備結婚的事,使用了google form來統計賓客資料。用google apps script寫了一個小程式(參考https://gist.github.com/mhawksey/1442370),透過http://tools.5432.tw/zip5api.html提供的API自動查詢3+2碼郵遞區號。分享給大家。
由於API作者有提到不要連續查詢,最好間隔一秒,因此請不要更動code內部sleep的部分。否則會被API作者封鎖來源網址。作者已經將google script的來源封鎖,這讓我在一開始的時候花了不少功夫debug。所以使用者必須提供一個web server供redirect來源繞過封鎖。
google apps script
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "fix郵遞區號",
functionName : "findpostcode"
}];
spreadsheet.addMenu("fix郵遞區號", entries);
};
/**
* Runs when the add-on is installed; calls onOpen() to ensure menu creation and
* any other initializion work is done immediately.
*
* @param {Object} e The event parameter for a simple onInstall trigger.
*/
function onInstall(e) {
onOpen(e);
}
/**
* Opens a sidebar. The sidebar structure is described in the Sidebar.html
* project file.
*/
function findpostcode() {
var o = 4; //4為修正前地址的欄位,可依需求修正
var a = 14; //將修正後之地址輸出到第14欄,可依需求修正
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Form Responses 1");
var TIDrange = sheet.getRange(1,1,sheet.getMaxRows(), a);
var rows = sheet.getLastRow();
for (i = 2; i <= rows; i++)
{
var dirtyaddress = TIDrange.getCell(i,o).getValue().toString().replace(/ /g,"");
var address = dirtyaddress.split(/^[0-9]*/)[1]; //去除已填寫之郵遞區號(可能為3碼)
var target = TIDrange.getCell(i,a).getValue().toString().replace(/ /g,"");
if (target == "") {
if (typeof address === 'undefined') {address = dirtyaddress;}
var response = UrlFetchApp.fetch("這邊放入轉址的網站"+address)
Utilities.sleep(1000); //此行勿動
var dataAll = JSON.parse(response.getContentText());
var newaddr = dataAll.new_adrs;
sheet.getRange(i,a).setValue(newaddr);
}
}
?>
由於API使用url參數會自動decode % encode,所以一開始遇到一點麻煩,後來發現我不用去store資料,只要直接echo就OK。
將webserver PHP放在webserver如apache下,假設檔名為phpexample.php,domain name為neverregret.net,則google apps script紅字部分這邊放入轉址的網站為
http://neverregret.net/phpexample.php?link=http://zip5.5432.tw/zip5json.py?adrs=
將google apps script部分複製並貼在工具-指令碼編輯器的內容(將內容先全部清空)
儲存後工具列會出現fix郵遞區號的選項,點選後執行即可使用。
查詢流程為如果尚未修正則修正(修正欄位不為空白),已修正則不處理,所以如果地址有變要記得將修正後欄位也一併清除。這樣做是為了不用每次都全部重新修正。
如有親友想使用請直接與我聯繫,我可以提供我自己的webserver供使用。
參考資料
API
http://tools.5432.tw/zip5api.html
unicode decode encode (didn't use in the end)
http://www.cnblogs.com/txw1958/archive/2013/04/20/unicode-encode-decode.html
http://stackoverflow.com/questions/16943281/javascript-google-scripts-how-to-get-the-title-of-a-page-encoded-with-iso-88
http://stackoverflow.com/questions/332872/encode-url-in-javascript
http://stackoverflow.com/questions/23496750/how-to-prevent-python-requests-from-percent-encoding-my-urls
http://blog.bestdaylong.com/2010/09/phputf8get.html
http://www.ewdna.com/2008/12/online-urlencoderutf-8.html
http://stackoverflow.com/questions/17342671/pass-a-percent-sign-in-a-url-and-get-exact-value-of-it-using-php
http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding
PHP
http://stackoverflow.com/questions/5884807/get-url-parameter-in-php
http://stackoverflow.com/questions/959063/how-to-send-a-get-request-from-php
determine undefine
http://stackoverflow.com/questions/2647867/how-to-determine-if-variable-is-undefined-or-null
JSON array
http://stackoverflow.com/questions/14408281/access-elements-in-json-object-like-an-array
javascript split
http://stackoverflow.com/questions/650022/how-do-i-split-a-string-with-multiple-separators-in-javascript
google apps script
https://gist.github.com/mhawksey/1442370
http://ctrlq.org/code/19871-get-post-requests-google-script
https://developers.google.com/apps-script/guides/html/
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#getRequest(String,Object)
https://discuss.ninjablocks.com/t/google-script-for-parsing-json-to-google-spreadsheets/1088/4
https://developers.google.com/apps-script/reference/spreadsheet/range
http://stackoverflow.com/questions/11334296/google-docs-script-set-cell-value
google spreadsheet
https://support.google.com/docs/answer/3093335?hl=zh-Hant
javascript
http://stackoverflow.com/questions/2499567/how-to-make-a-json-call-to-a-url/2499647#2499647
http://stackoverflow.com/questions/18910939/how-to-get-json-key-and-value-in-javascript
http://stackoverflow.com/questions/12070631/how-to-use-json-file-in-html-code
JSON test site
http://developers.squarespace.com/view-json-data/
http://base-template.squarespace.com/blog/?format=json-pretty
由於API作者有提到不要連續查詢,最好間隔一秒,因此請不要更動code內部sleep的部分。否則會被API作者封鎖來源網址。作者已經將google script的來源封鎖,這讓我在一開始的時候花了不少功夫debug。所以使用者必須提供一個web server供redirect來源繞過封鎖。
google apps script
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "fix郵遞區號",
functionName : "findpostcode"
}];
spreadsheet.addMenu("fix郵遞區號", entries);
};
/**
* Runs when the add-on is installed; calls onOpen() to ensure menu creation and
* any other initializion work is done immediately.
*
* @param {Object} e The event parameter for a simple onInstall trigger.
*/
function onInstall(e) {
onOpen(e);
}
/**
* Opens a sidebar. The sidebar structure is described in the Sidebar.html
* project file.
*/
function findpostcode() {
var o = 4; //4為修正前地址的欄位,可依需求修正
var a = 14; //將修正後之地址輸出到第14欄,可依需求修正
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Form Responses 1");
var TIDrange = sheet.getRange(1,1,sheet.getMaxRows(), a);
var rows = sheet.getLastRow();
for (i = 2; i <= rows; i++)
{
var dirtyaddress = TIDrange.getCell(i,o).getValue().toString().replace(/ /g,"");
var address = dirtyaddress.split(/^[0-9]*/)[1]; //去除已填寫之郵遞區號(可能為3碼)
var target = TIDrange.getCell(i,a).getValue().toString().replace(/ /g,"");
if (target == "") {
if (typeof address === 'undefined') {address = dirtyaddress;}
var response = UrlFetchApp.fetch("這邊放入轉址的網站"+address)
Utilities.sleep(1000); //此行勿動
var dataAll = JSON.parse(response.getContentText());
var newaddr = dataAll.new_adrs;
sheet.getRange(i,a).setValue(newaddr);
}
}
webserver PHP
<?php
if (isset($_GET['link'])) {
// echo $_GET['link'];
echo file_get_contents($_GET['link']);
}else{
// Fallback behaviour goes here
}
if (isset($_GET['link'])) {
// echo $_GET['link'];
echo file_get_contents($_GET['link']);
}else{
// Fallback behaviour goes here
}
?>
由於API使用url參數會自動decode % encode,所以一開始遇到一點麻煩,後來發現我不用去store資料,只要直接echo就OK。
將webserver PHP放在webserver如apache下,假設檔名為phpexample.php,domain name為neverregret.net,則google apps script紅字部分這邊放入轉址的網站為
http://neverregret.net/phpexample.php?link=http://zip5.5432.tw/zip5json.py?adrs=
將google apps script部分複製並貼在工具-指令碼編輯器的內容(將內容先全部清空)
儲存後工具列會出現fix郵遞區號的選項,點選後執行即可使用。
查詢流程為如果尚未修正則修正(修正欄位不為空白),已修正則不處理,所以如果地址有變要記得將修正後欄位也一併清除。這樣做是為了不用每次都全部重新修正。
如有親友想使用請直接與我聯繫,我可以提供我自己的webserver供使用。
參考資料
API
http://tools.5432.tw/zip5api.html
unicode decode encode (didn't use in the end)
http://www.cnblogs.com/txw1958/archive/2013/04/20/unicode-encode-decode.html
http://stackoverflow.com/questions/16943281/javascript-google-scripts-how-to-get-the-title-of-a-page-encoded-with-iso-88
http://stackoverflow.com/questions/332872/encode-url-in-javascript
http://stackoverflow.com/questions/23496750/how-to-prevent-python-requests-from-percent-encoding-my-urls
http://blog.bestdaylong.com/2010/09/phputf8get.html
http://www.ewdna.com/2008/12/online-urlencoderutf-8.html
http://stackoverflow.com/questions/17342671/pass-a-percent-sign-in-a-url-and-get-exact-value-of-it-using-php
http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding
PHP
http://stackoverflow.com/questions/5884807/get-url-parameter-in-php
http://stackoverflow.com/questions/959063/how-to-send-a-get-request-from-php
determine undefine
http://stackoverflow.com/questions/2647867/how-to-determine-if-variable-is-undefined-or-null
JSON array
http://stackoverflow.com/questions/14408281/access-elements-in-json-object-like-an-array
javascript split
http://stackoverflow.com/questions/650022/how-do-i-split-a-string-with-multiple-separators-in-javascript
google apps script
https://gist.github.com/mhawksey/1442370
http://ctrlq.org/code/19871-get-post-requests-google-script
https://developers.google.com/apps-script/guides/html/
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#getRequest(String,Object)
https://discuss.ninjablocks.com/t/google-script-for-parsing-json-to-google-spreadsheets/1088/4
https://developers.google.com/apps-script/reference/spreadsheet/range
http://stackoverflow.com/questions/11334296/google-docs-script-set-cell-value
google spreadsheet
https://support.google.com/docs/answer/3093335?hl=zh-Hant
javascript
http://stackoverflow.com/questions/2499567/how-to-make-a-json-call-to-a-url/2499647#2499647
http://stackoverflow.com/questions/18910939/how-to-get-json-key-and-value-in-javascript
http://stackoverflow.com/questions/12070631/how-to-use-json-file-in-html-code
JSON test site
http://developers.squarespace.com/view-json-data/
http://base-template.squarespace.com/blog/?format=json-pretty
訂閱:
文章 (Atom)