• 860

[研究所] MikroTik RouterOS 學習 (持續更新)


eavictor wrote:
小弟也是最近才剛入手...(恕刪)


你可以試試看,我是這樣設定的:

/ip ipsec proposal auth-algorithms=sha1 enc-algorithms=3des,aes-128,aes-192,aes-256 lifetime=1h pfs-group=none

/ip ipsec peer address=0.0.0.0/0 port=500 auth-method=pre-shared-key generate-policy=yes exchange-mode=main-l2tp
send-initial-contact=yes nat-traversal=yes hash-algorithm=sha1 enc-algorithm=3des dh-group=modp1024
lifetime=1d dpd-interval=2m dpd-maximum-failures=5

/ip firewall filter chain=input action=accept protocol=udp dst-port=4500
/ip firewall filter chain=input action=accept protocol=udp dst-port=1701
/ip firewall filter chain=input action=accept protocol=udp dst-port=500
/ip firewall filter chain=input action=accept protocol=ipsec-esp

感謝大大您提供的設定值
剛剛小弟確定是自己Router內部設定的問題,這部分還需要繼續學習。


以下簡述小弟的網路設定,為什麼會造成L2TP/IPsec連不上的問題目前自己也還沒頭緒。


IP > Address
ether13上面設了中華電信給的6個固定IP:***.***.***.19-24/24

IP > Routes
因為6個IP都是同網段,Gateway只有***.***.***.254
因此只有一個規則。

IP > Pool
10.0.1.2-10.0.1.254 < 此網段給家中使用(dhcp_pool)
10.0.2.2-10.0.2.254 < 此網段給VPN使用(vpn_pool)

IP > DHCP Server
DHCP & Networks
僅設定10.0.1.0/24這段

IP > Firewall
Filter Rules
這部分小弟沒有block任何東西,因此沒有設定任何東西
NAT
10.0.1.0/24和10.0.2.0/24這兩個網段有做srcnat讓內部設備可以連網際網路


分配給 VPN Server 使用的是***.***.***.20這個IP
很神奇的,PPTP 和 SSTP 都可以正常連線使用,但是使用what is my IP之類的軟體去查詢還是會顯示為***.***.***.19

L2TP/IPsec 和 OpenVPN 就沒有那麼幸運,客戶端用第二個IP連上的時候會一直卡在「連線中」


這部分該不會要用到metaRouter的功能吧
L2TP/IPSEC 實作

在前面提到有關 L2TP VPN 的實作, 在 L2TP 採用不加密 or MPPE 加密方式, 通常會透過 IPSEC 來補強.

小弟不是這方面的專家, google 有關 L2TP 相關資料, 有的人寫不加密, 有的人寫本身已加密, 不過實測在 Microsoft L2TP client 連線確定是不加密的, 但如果在 MikroTik L2TP VPN, user 可自行指定是否加密, 於 PPP Active Connection Encoding 可以看到連線加密狀態.

這裡不囉嗦, 目的就是讓 iPhone/iPad 上 L2TP/IPSEC 連上 MikroTik router, 至於其他 Android, PC & Mac...以此類推.

MikroTik Server 設定:

# VPN SUBNET: 10.0.31.0/24
# USRENAME: username
# PASSWORD: password
# SECRET: vpnsecret

/ip pool
add name=l2tp-pool ranges=10.0.31.101-10.0.31.199

/ppp profile
add address-list=L2TP_Clients local-address=10.0.31.1 name=L2TP remote-address=l2tp-pool

/ppp secret
add name=username password=password profile=L2TP service=l2tp

/interface l2tp-server server
set default-profile=default-encryption enabled=yes

/ip ipsec proposal
set [ find default=yes ] auth-algorithms=md5,sha1 enc-algorithms=\
3des,aes-128,aes-192,aes-256

/ip ipsec peer
add exchange-mode=main-l2tp generate-policy=yes hash-algorithm=sha1 \
nat-traversal=yes secret=vpnsecret


iPhone or iPad 上的設定:
軤前述所設定的 username, password & vpnsecret 填入即可.


完工! 如果你預設的 ip firewall filter 不是 pass, 請參考 weiyu99 網友前面所寫的 firewall filter.

經驗談
如果 Router 設定好了以後, iPhone or iPad 無法建立 L2TP/IPSEC 連線, 並不代表你的設定有問題, 請重新 reboot router 後再試看看, 會有意想不到的效果, 這是小弟在這裡被卡過N次所得到的經驗.

參考資料
mikrotik forum
L2TP/IPSEC on MikroTik router
FB: Pctine

pctine wrote:
小弟不是這方面的專家, google 有關 L2TP 相關資料, 有的人寫不加密, 有的人寫本身已加密, 不過實測在 Microsoft L2TP client 連線確定是不加密的, 但如果在 MikroTik L2TP VPN, user 可自行指定是否加密, 於 PPP Active Connection Encoding 可以看到連線加密狀態....(恕刪)


p大:我在iOS下測試L2TP,選項都選擇要求加密了,但還是一直沒有顯示加密,但PPTP確有。
不知道您是否也可以測試看看?


irsjx2vxo3ne3k84dr1dz4,r4pe8bez3/4ne3bq4bew2j92gea jx4hq me-2d8 e3hy4hi2ty k84!
derliang wrote:
p大:我在iOS下測...(恕刪)


沒有仔細去看, 不過它是 L2TP over IPSEC, 你連線後去看有沒有產生一筆 ip ipsec policy 的資料便知. 加密是在 IPSEC 這裡做的.
FB: Pctine
L2TP/IPSEC site to site VPN 實作

官方文件: L2TP/IPSEC

官方文件講解的非常清楚了, 這裡只列出小弟實作的 script, 自行修改直接套用就可以了. 設定非常簡單, 先建立 L2TP VPN, 再透過 IPSEC 把 Tunnel 包起來就 ok 了.

至於 L2TP 加密和不加密的 performance 差異多少就沒有去測了, 如果怕效能不好, 在 L2TP 這層可以不做加密. (profile=default 就不會加密了)




# http://wiki.mikrotik.com/wiki/L2TP_%2B_IPSEC_between_2_Mikrotik_routers
# SERVER SUBNET: 192.168.38.0/24
# CLIENT SUBNET: 192.168.22.0/24
# PEER IP: 172.16.1.1 & 172.16.1.2
# SERVER WAN IP: 123.123.123.123

# SERVER SIDE
/ppp secret
add comment="for khome dial in" local-address=172.16.1.1 name=Home password=\
test profile=default-encryption remote-address=172.16.1.2 routes=\
"192.168.22.0/24 172.16.1.2 1"

/interface l2tp-server server
set authentication=pap,chap,mschap1,mschap2 default-profile=default-encryption enabled=yes \
keepalive-timeout=30 max-mru=1460 max-mtu=1460 mrru=disabled

/ip ipsec proposal
set [ find default=yes ] enc-algorithms=3des,aes-128,aes-192,aes-256

/ip ipsec peer
add address=172.16.1.2/32 dpd-interval=disable-dpd dpd-maximum-failures=1 \
hash-algorithm=sha1 secret=test

/ip ipsec policy
add dst-address=192.168.22.0/24 sa-dst-address=172.16.1.2 sa-src-address=\
172.16.1.1 src-address=192.168.38.0/24 tunnel=yes


# CLIENT SIDE
/interface l2tp-client
add connect-to=123.123.123.123 disabled=no name=l2tp-out1 password=test user=Home

/ip ipsec proposal
set [ find default=yes ] auth-algorithms=md5,sha1 enc-algorithms=\
3des,aes-128,aes-192,aes-256

add address=172.16.1.1/32 dpd-interval=disable-dpd dpd-maximum-failures=1 hash-algorithm=\
sha1 secret=test

/ip ipsec policy
add dst-address=192.168.38.0/24 sa-dst-address=172.16.1.1 sa-src-address=172.16.1.2 \
src-address=192.168.22.0/24 tunnel=yes

/ip route
add distance=1 dst-address=192.168.38.0/24 gateway=172.16.1.1


說明
以 btest bandwidth test tool 實測, L2TP 加密和不加密的 performance 差異是相當大的, 加密後 performance 至少掉一半以上, 如果怕效能不好, 在 L2TP 這層可以不做加密. (profile=default 就不會加密了)
FB: Pctine
VPN performance Test

這裡沒有做太多的測試, 只是將之前諸多 site to site VPN 實作做個總結.

MikroTik 提供這麼多 VPN 的做法, 到底如何選擇? 如果你是要應用在 China, 基本上就那個不會被 block 就用它, 畢竟 China 的情況太複雜, 每個地區的限制不同.

但以之前所做的 SSTP, L2TP, PPTP 來看, 結果如下.


補上 OpenVPN 效能.


這只是在同一時間利用 btest bandwidth test tool 切換不同的 VPN mode 初略的測試, 至於 L2TP/IPSEC 沒有再加進來. 其中以 SSTP & OVPN 效能最好, 約 8~9Mbps.

ps: 小弟這裡最快下載頻寬約 10Mbps
FB: Pctine
IPIP Tunnel

IPIP - IP within IP Tunnel 和 GRE Tunnel 用法相當類似, 可以用於多點間建立 intranet 之用.


官方文件: IPIP Tunnel


# IPIP Tunnel
# Home subnet: 192.168.22.0/24
# Office subnet: 192.168.38.0/24
# Home WAN IP: 114.32.xxx.xxx
# Office WAN IP: 114.34.xxx.xxx
# Peer IP: 10.0.0.1 & 10.0.0.2

# HOME side
/interface ipip
add disabled=no local-address=114.32.xxx.xxx name=ipip1 remote-address=114.34.xxx.xxx

/ip address
add address=10.0.0.2/30 interface=ipip1

/ip route
add distance=1 dst-address=192.168.38.0/24 gateway=10.0.0.1


# OFFICE side
/interface ipip
add disabled=no local-address=114.34.xxx.xxx name=ipip1 remote-address=114.32.xxx.xxx

/ip address
add address=10.0.0.1/30 interface=ipip1

/ip route
add distance=1 dst-address=192.168.22.0/24 gateway=10.0.0.2


做法和之前的 GRE Tunnel 完全相同, 而 IPIP 實際上也是在封包前面冠上 WAN IP 後直接往 remote site 送出, 只要 Internet 上兩 site subnet 不同, 就可以透過 IPIP 建立 intranet.

GRE, IPIP Tunnel 這些都是未加密的, 建議在使用時必須輔以其他加密協定(例如 IPSEC).
FB: Pctine

pctine wrote:
沒有仔細去看, 不過它是 L2TP over IPSEC, 你連線後去看有沒有產生一筆 ip ipsec policy 的資料便知. 加密是在 IPSEC 這裡做的....(恕刪)


p大:看起來SSTP與L2TP over IPSec的加密都不會顯示在PPP的連線狀態裡。
另外我發現啟用了IPSec以後,都會有一些奇怪不明的遠端Peer連線,例如下面的這個。
我很確定這不是我自己遠端連線的IP,請問這有關係嗎?

irsjx2vxo3ne3k84dr1dz4,r4pe8bez3/4ne3bq4bew2j92gea jx4hq me-2d8 e3hy4hi2ty k84!
請問大大,
/ip firewall filter中預設有4條規則,
在官網 http://wiki.mikrotik.com/wiki/Manual:IP/Firewall/Filter#Basic_examples 也有看到,
請問基礎防禦比較建議用哪一邊的規則呢?
  • 860
內文搜尋
X
評分
評分
複製連結
請輸入您要前往的頁數(1 ~ 860)
Mobile01提醒您
您目前瀏覽的是行動版網頁
是否切換到電腦版網頁呢?