之前就有發生過類似的情形,後來試了一下發現是碰不到openvpn server(log沒有反應,區網測試可以)。trouble shoot老半天結果居然是Dlink router DMZ不會轉送 port 443,我還找到MTU那邊去。之前因為都是直接用pfsense pppoe,最近換到dlink減輕server負擔沒想到會這樣,暈倒....
附上解決方法,除了DMZ外再做一次port forwarding....
參考資料
自己
https://www.google.com.tw/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwji842Uv4HWAhUFJ5QKHU4sBlIQFggoMAA&url=https%3A%2F%2Fwww.mobile01.com%2Ftopicdetail.php%3Ff%3D110%26t%3D5888&usg=AFQjCNF3Tx6urZ1LXe0L-3gCuDcaNebGuA
2017年8月31日 星期四
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年10月5日 星期一
openvpn server, pfsense ipsec 設定
iptables 需要將ppp設為MASQUERADE偽裝IP才有辦法連到internet
出現錯誤訊息
Options error: server and client cannot be used together
代表conf檔案內有用到不是server指令的指令
iptables restart in ubuntu
如使用ufw
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
port-share
可設一個port(通常為443)如果沒有TLS handshake則導到網頁,有則連接上openvpn server
方法是在Advanced configuration > Advanced 加上以下指令
pfsense 的ipsec設定可以參考下面的參考資料
因為後來看到似乎ipsec比較穩定,所以有用pfsense架設了一個ipsec VPN,到中國後才知道GFW(網路長城)的厲害啊...
總之現在就是openvpn PPTP ipsec輪著用,通常至少有一個能work
要push dns 到client時使用push "dhcp-option DNS <ip>"
如果是client端conf則使用dhcp-option DNS <ip>
可同時複數使用如增加google dns push "dhcp-option DNS 8.8.8.8"
這樣就可以同時使用local dns server與internet dns server
順帶一提,有問題的vpn是hola vpn。
2019/4/17更新
後來將VPN network與local network分開,導致兩邊無法互連問題,經過研究發現是因為設了ipv4 local network,這會導致直接優先在local route尋找而不是透過gateway轉遞。另外也須加上 push "route <local subnet> <local subnet netmask>"
參考資料
http://acman.bluenest.net/wordpress/archives/118
apache ssl (https) setting
https://www.bestvpn.com/blog/5919/how-to-hide-openvpn-traffic-an-introduction/
http://neidi.homeip.net/blog/cblog/index.php?id=414
http://kirby86a.pixnet.net/blog/post/95136568-ubuntu-12.04%E5%95%9F%E7%94%A8apache%E7%9A%84-ssl
openvpn port share
https://doc.pfsense.org/index.php/Sharing_a_Port_with_OpenVPN_and_a_Web_Server
pfsense ipsec
https://doc.pfsense.org/index.php/IPsec_for_road_warriors_in_PfSense_2.0.1_with_PSK_in_stead_of_xauth
https://www.shrew.net/download/vpn
https://doc.pfsense.org/index.php/IPsec_Road_Warrior/Mobile_Client_How-To
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
different subnet
https://blog.bobbyallen.me/2016/02/07/enabling-openvpn-clients-to-access-to-the-lan/
出現錯誤訊息
Options error: server and client cannot be used together
代表conf檔案內有用到不是server指令的指令
iptables restart in ubuntu
如使用ufw
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
port-share
可設一個port(通常為443)如果沒有TLS handshake則導到網頁,有則連接上openvpn server
方法是在Advanced configuration > Advanced 加上以下指令
port-share x.x.x.x 443x.x.x.x為apache或web server的位址
pfsense 的ipsec設定可以參考下面的參考資料
因為後來看到似乎ipsec比較穩定,所以有用pfsense架設了一個ipsec VPN,到中國後才知道GFW(網路長城)的厲害啊...
總之現在就是openvpn PPTP ipsec輪著用,通常至少有一個能work
要push dns 到client時使用push "dhcp-option DNS <ip>"
如果是client端conf則使用dhcp-option DNS <ip>
可同時複數使用如增加google dns push "dhcp-option DNS 8.8.8.8"
這樣就可以同時使用local dns server與internet dns server
順帶一提,有問題的vpn是hola vpn。
2019/4/17更新
後來將VPN network與local network分開,導致兩邊無法互連問題,經過研究發現是因為設了ipv4 local network,這會導致直接優先在local route尋找而不是透過gateway轉遞。另外也須加上 push "route <local subnet> <local subnet netmask>"
參考資料
http://acman.bluenest.net/wordpress/archives/118
apache ssl (https) setting
https://www.bestvpn.com/blog/5919/how-to-hide-openvpn-traffic-an-introduction/
http://neidi.homeip.net/blog/cblog/index.php?id=414
http://kirby86a.pixnet.net/blog/post/95136568-ubuntu-12.04%E5%95%9F%E7%94%A8apache%E7%9A%84-ssl
openvpn port share
https://doc.pfsense.org/index.php/Sharing_a_Port_with_OpenVPN_and_a_Web_Server
pfsense ipsec
https://doc.pfsense.org/index.php/IPsec_for_road_warriors_in_PfSense_2.0.1_with_PSK_in_stead_of_xauth
https://www.shrew.net/download/vpn
https://doc.pfsense.org/index.php/IPsec_Road_Warrior/Mobile_Client_How-To
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
different subnet
https://blog.bobbyallen.me/2016/02/07/enabling-openvpn-clients-to-access-to-the-lan/
2014年3月25日 星期二
pfsense openvpn設置,設定有線網路優先於無線網路
如何使有線網路優先於無線網路。進入網路與共用中心,變更介面卡設定,F10,進階,進階設定。
pfsense裡設定openvpn重點如下
參考資料
有線網路優先
http://www.techbang.com/posts/6326-in-windows-7-fast-switching-wired-wireless-network
http://bojack.pixnet.net/blog/post/35356025-%E3%80%90windows%E3%80%91%E5%9C%A8-windows-7-%E8%AA%BF%E6%95%B4%E6%9C%89%E7%B7%9A%E7%B6%B2%E8%B7%AF%E5%92%8C%E7%84%A1%E7%B7%9A%E7%B6%B2%E8%B7%AF
IP相同
https://forum.pfsense.org/index.php?topic=4587.0
SMB
https://doc.pfsense.org/index.php/Why_can't_I_access_Windows/SMB_shares_on_OpenVPN_clients
同事討論與實做測試
pfsense裡設定openvpn重點如下
- 先設定ca certification
- 接著server certification於pfsense用
- client certification用於要連接的設備
- 注意LZO compression及cipher兩端(server及client)要設定一樣
- 目前測試pfsense只能用tun而不能用tap
- 建立.crt與.key時如common name設一樣則會拿到同一個IP,會造成互搶,應避免
- 如需使用samba服務如網路芳鄰則需將Enable NetBIOS over TCP/IP打勾並選擇m-node,但android device有時還是會連不上
參考資料
有線網路優先
http://www.techbang.com/posts/6326-in-windows-7-fast-switching-wired-wireless-network
http://bojack.pixnet.net/blog/post/35356025-%E3%80%90windows%E3%80%91%E5%9C%A8-windows-7-%E8%AA%BF%E6%95%B4%E6%9C%89%E7%B7%9A%E7%B6%B2%E8%B7%AF%E5%92%8C%E7%84%A1%E7%B7%9A%E7%B6%B2%E8%B7%AF
IP相同
https://forum.pfsense.org/index.php?topic=4587.0
SMB
https://doc.pfsense.org/index.php/Why_can't_I_access_Windows/SMB_shares_on_OpenVPN_clients
同事討論與實做測試
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裡的Makefile,EXTRAVERSION = (為你的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/
cd至Pyramid_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權限)
2012/3/23補充
後來有查詢到一些資料即iptable導致wifi與3G衝突可能引起連不上openvpn,此時可下指令ip ru del table gprs可解決。
2019/7/12 update
其實就是android不支援tap(因為需要root權限)
參考資料
訂閱:
文章 (Atom)