顯示具有 linux 標籤的文章。 顯示所有文章
顯示具有 linux 標籤的文章。 顯示所有文章

2017年11月7日 星期二

arduino email solution

想使用arduino在需要時發email通知。一開始找ethernet library,結果要使用的話必須要有public ip,後來找到的方法是利用arduino sdk寫code再利用外部網站API達到目的,不過那個需要付費並且掌握在別人手上。後來找到直接install apk在arduino linux上即可達到目的,為了這個還發現arduino出廠時是使用factory image,必須要自己upgrade才能獲取全部的arduino society support。看到download.linino.org就代表你是連到factory自己建的repository,不但常常掛資源也少,正確的應該是downloads.arduino.cc

參考資料

ethernet lib
https://forum.arduino.cc/index.php?topic=126829.0

arduino sdk
http://tronixstuff.com/2013/11/23/tutorial-send-email-with-the-arduino-yun/

arduino linux
http://www.binarypower.com/2014/07/use-arduino-yun-to-send-emails-simple.html

download.linino.org
https://forum.arduino.cc/index.php?topic=286191.0

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下的規則
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
自己

2011年11月26日 星期六

vpn

最近幾天自己架了一個openvpn server。然後在筆電上裝了openvpn client,最後在sensation上也裝了openvpn。因為過程實在有些複雜,po上來備忘兼給其他人參考。

首先openvpn server的部份,由於我的目標是讓外部網路可以透過vpn peer到我家內部網路,所以我是走tap而非tun。這部份主要是先安裝openvpn for windows然後bridge虛擬網卡與區域網路。openvpn server config部份要注意的是

proto udp

dev tap
dev-node tap-bridge

server-bridge 192.168.1.52 255.255.255.0 192.168.1.60 192.168.1.254

push "route 10.66.77.0 255.255.255.0"

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# or bridge the TUN/TAP interface to the internet
# in order for this to work properly).
;push "redirect-gateway def1 bypass-dhcp" 這邊好像是設定讓client端連外是server端ip的樣子

client-to-client

duplicate-cn

接著client部份


dev tap

proto udp

ca ca.crt
cert client1.crt
key client1.key

其他部份幾乎都是預設值,但是同樣的設定到阿璇那邊就變成不通,不知道為何。另外因為有開BT的關係中間有出現連不上,後來才查明是因為BT流量開太大所以導致vpn client連不進來。

所以後來使用xp vpn server之方法PPTP讓阿璇可以連進來。但xp vpn server只能允許同時一個使用者連入的樣子。設定方法

新增連線,序列埠,不選擇,允許私人連線及工作連線。最後設定分配的ip區段。但是阿璇說會無法上網,這點還要再測試。

最後是最麻煩的android openvpn設定。

首先sensation自己就有vpn設定,也是走PPTP,但是一開始設定好卻始終連不上,以為是server端問題但又不像。最後查到原來是3g會擋vpn PPTP,也難怪我使用筆電連手機上網要用xp vpn PPTP撥回來始終連不上。有看到有人說明可以走L2TP(xp要另外裝東西才能支援),不過最後決定用openvpn。

先在market上下載openvpn installer跟openvpn setting。要安裝openvpn之前要先安裝busybox。這邊要注意的是如果是用原廠的ROM則market上下載的busybox installer並不會去更改你的/system/bin/route & ifconfig。所以必須要手動去link busybox與route & ifconfig。

可用terminal終端機鍵入

ln -s /system/xbin/busybox /system/xbin/bb/route
ln -s /system/xbin/busybox /system/xbin/bb/ifconfig

前半要換成你busybox安裝的位置。

接下來就是tun.ko的部份,也是我花最久時間處理的部份。由於tun.ko必須配合你的kernel。所以我找了許久,最後甚至自己compile一個但是還是無法使用。最後是刷了PYR_UNITY_V13_OC1512_CIFS_TUN_NOOP_2WCR_VDD.zip這個kernel才解決。

compile的方法是先下載android-ndk-r4-linux-x86.zip,Pyramid_LE_CRC-2.6.35-877c198.tar.gz,另android-sdk因為只是用來取出手機內的/proc/config.gz所以我就沒下載
我是用vitualbox安裝utunbu在linux下操作,先將上面兩個及config.gz解壓縮並令裡面的CONFIG_TUN=m。接著改Pyramid_LE_CRC-2.6.35-877c198.tar.gz裡的MakefileEXTRAVERSION = 為你的kernel最後小數點後面的字串)。最後設定變數

export ARCH=arm
export CROSS_COMPILE=arm-eabi-
export PATH=$PATH:~/android/android-ndk-r4/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/

cdPyramid_LE_CRC-2.6.35-877c198目錄下並下指令make modules,則可在Pyramid_LE_CRC-2.6.35-877c198/driver/net下找到tun.ko

2012/3/23補充
後來有查詢到一些資料即iptable導致wifi與3G衝突可能引起連不上openvpn,此時可下指令ip ru del table gprs可解決。

2019/7/12 update
其實就是android不支援tap(因為需要root權限)


參考資料