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

top100011 wrote:
請教一下,因為最近把...(恕刪)
router若要用一個wireguard對應多個手機peers,
在peer裡allowed-address不能設0.0.0.0/0,要改設小米10的192.168.12.111/24。

其它peer裡,也要設其它手機的192.168.12.x/24。

但注意只有router wireguard peer裡的allowed-address是這麼做,
手機peer的allowed-address一樣是設定0.0.0.0/0不變。

因為手機是client端,router是server端,才會有這樣的區別。
另外這是手機透過wireguard翻牆才如此設定,

若是router vs router透過wireguard,為了雙向連結,
一般還是兩邊router allowed-address皆設0.0.0.0/0,也不會同時連結多個以上的peer。
gfx wrote:
router若要用一...(恕刪)


其實我自己也有這樣自己先試過,也是不行
想說gfx大有這樣說,想說再重新測過一次也還是一樣

router 各設 192.168.12.111/24 跟另一組 192.168.12.112/24 分別對應兩支手機的公鑰
手機也有設定相對應的各別IP

同一時間連上的話,還是只有一支可以連外網跟內網
無法連那支,已接收就會固定只有 92B ,已傳送是會一直有在跑

而且不能連的那組,我就算另一組斷開,原來不能連的重連還是不行
必須把peers 裡對應的那組先停用再啟用,再連才有辦法

防火牆除了設通道還需要設什麼嗎,感覺好像都沒什麼問題,但就是不行
先放上架構圖


最近發現如果把所有的設備Gateway都放在FG-81上面會有蠻大的性能瓶頸
所以想慢慢的把Gateway轉回去RB5009上面,對外的時候也可以經過Fortigate

但目前測試發現如果我的VLAN1想要出去WAN,RB5009上面需要開啟NAT,(Ping的通但網頁功能無法開啟)

是我RB5009設定有問題嗎,想請問是哪個部分需要設定呢?
寶貝:)開心最重要!
想請教一下各位先進,有關於網路配置的可行性與方法。
首先是網路架構,如下圖

RouterOS 版本: 7.13.4
swos 版本: 2.16

需求如下:
1. Main-LAN和Guest-LAN完全隔開
2. 中華電信MOD可以使用
3. HTPC可連NAS讀取資料
4. 使用IPsec/IKEv2或OpenVPN連入之設備可存取NAS的資料

然後目前的規劃如下:
Main-LAN:
撥號:PPPoE Client1(Static IP)、PPPoE Client2(備援、Dynamic IP)
LAN IP:10.0.0.1~10.0.0.254
10.0.0.1 - 10.0.0.99 Static LAN IP
10.0.0.100 - 10.0.0.199 Dynamic LAN IP (DHCP Pool1)
10.0.0.200 - 10.0.0.214 IPsec/IKEv2 LAN IP (VPN Pool1)
10.0.0.215 - 10.0.0.229 OpenVPN LAN IP (VPN Pool2)
10.0.0.230 - 10.0.0.254 Static LAN IP (網路設備專用)
Guset-LAN:
撥號:PPPoE Client3
LAN IP:10.0.1.1~10.0.1.254
10.0.1.1 - 10.0.1.249 Dynamic LAN IP (DHCP Pool2)
10.0.1.250 - 10.0.1.254 Static LAN IP (網路設備專用)

想請問該如何實作。


另外,想請問一下:
RB760iGS同時作為OpenVPN Server和Ipsec/IKEv2 VPN Server,其local address能否設定為同一個?又能否設定和DHCP Server的Gateway同樣(即全部設定成10.0.0.250)?
OVPN Server的設定 -> /ppp profile 的 local-address
Ipsec/IKEv2 VPN Server的設定 -> /ip ipsec peer 的 local-address
DHCP Server的設定 -> /ip dhcp-server network 的 gateway
Rimiya wrote:
想請教一下各位先進,...(恕刪)
花了一整天先解決了VLAN和Routing的問題
之後有空會整理一下我自己的設定並Po上來給可能有需要的人參考

現在遇到的問題是
IKEv2的IKE_SA_INIT封包傳入Server(即RB760iGS)時,可見其通過RAW和Mangle(packets的counter有增加),但看起來是沒有通過Filter的(counter持續是0)。

log中也完全沒有ipsec的任何紀錄(已在logging中加入ipsec),想請問這個封包有可能是在哪裡消失的?
Rimiya wrote:
想請教一下各位先進,...(恕刪)
Q:RB760iGS同時作為OpenVPN Server和Ipsec/IKEv2 VPN Server,其local address能否設定為同一個?
A:IKEv2 VPN Server因IPSec架構的關係,它沒有local address。

Q:又能否設定和DHCP Server的Gateway同樣(即全部設定成10.0.0.250)?
A:其實OpenVPN不應該與DHCP Server同網段,會造成路由表混亂。但啟用橋接器的arp偽裝(arp-proxy),VPN用戶端可偽裝成DHCP Server的Gateway,與DHCP裝置連繫。假設VPN Server也是10.0.0.250,VPN用戶端觸發arp偽裝瞬間,VPN隧道本地與遠端皆是相同的ip(10.0.0.250),將出現無法預期的錯誤。

VLAN:
#RB260GS:



#RB760iGS:
/interface bridge
add name=bridge1 protocol-mode=none arp=proxy-arp

/interface bridge port
add bridge=bridge1 interface=ether1 hw=no
add bridge=bridge1 interface=ether2 hw=no
add bridge=bridge1 interface=ether3 hw=no
add bridge=bridge1 interface=ether4 hw=no
add bridge=bridge1 interface=ether5 hw=no
add bridge=bridge1 interface=sfp1 hw=no

/interface bridge vlan
add bridge=bridge1 untagged=bridge1,ether1,ether3,ether4,sfp1 vlan-ids=1
add bridge=bridge1 tagged=bridge1,ether5 vlan-ids=20
add bridge=bridge1 tagged=bridge1,ether5 untagged=ether2 vlan-ids=10

/interface vlan
add name=vlan20 vlan-id=20 interface=bridge1
add name=vlan10 vlan-id=10 interface=bridge1

/ip address
add address=10.0.0.250/24 interface=bridge1 network=10.0.0.0
add address=10.0.1.250/24 interface=vlan20 network=10.0.1.0

/interface bridge
set bridge1 vlan-filtering=yes

RB760iGS LAN & PPPoE:
/ip pool
add name=dhcp1 ranges=10.0.0.100-10.0.0.199
add name=dhcp2 ranges=10.0.1.1-10.0.1.249
add name=vpn1 ranges=10.0.0.201-10.0.0.214
add name=vpn2 ranges=10.0.0.216-10.0.0.229

/ip dhcp-server
add address-pool=pool1 interface=bridge1 lease-time=1h name=dhcp1
add address-pool=pool2 interface=vlan20 lease-time=1h name=dhcp2

/ip dhcp-server network
add address=10.0.0.0/24 gateway=10.0.0.250 dns-server=8.8.8.8
add address=10.0.1.0/24 gateway=10.0.1.250 dns-server=8.8.8.8

/interface pppoe-client
add allow=pap interface=vlan10 name=pppoe-out1 profile=default [email protected]
add allow=pap interface=vlan10 name=pppoe-out2 profile=default [email protected]

/interface list
add name=PPPoE
add name=LAN
add name=VPN

/interface list member
add interface=bridge1 list=LAN
add interface=vlan20 list=LAN
add interface=pppoe-out1 list=PPPoE
add interface=pppoe-out2 list=PPPoE

/routing table
add fib=yes name=pppoe1
add fib=yes name=pppoe2

/routing rule
add action=lookup dst-address=10.0.0.0/23 table=main

#10.0.0.100-10.0.0.229
add action=lookup src-address=10.0.0.100/30 table=pppoe2
add action=lookup src-address=10.0.0.104/29 table=pppoe2
add action=lookup src-address=10.0.0.112/28 table=pppoe2
add action=lookup src-address=10.0.0.128/26 table=pppoe2
add action=lookup src-address=10.0.0.192/27 table=pppoe2
add action=lookup src-address=10.0.0.224/30 table=pppoe2
add action=lookup src-address=10.0.0.228/31 table=pppoe2

#10.0.1.1-10.0.1.249
add action=lookup src-address=10.0.1.0/25 table=pppoe2
add action=lookup src-address=10.0.1.128/26 table=pppoe2
add action=lookup src-address=10.0.1.192/27 table=pppoe2
add action=lookup src-address=10.0.1.224/28 table=pppoe2
add action=lookup src-address=10.0.1.240/29 table=pppoe2
add action=lookup src-address=10.0.1.248/31 table=pppoe2

/ip route
add distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out1
add distance=2 dst-address=0.0.0.0/0 gateway=pppoe-out2
add distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out1 routing-table=pppoel
add distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out2 routing-table=pppoe2

/ip firewall mangle
add action=change-mss chain=forward new-mss=clamp-to-pmtu passthrough=yes protocol=tcp tcp-flags=syn
add action=change-mss chain=output new-mss=clamp-to-pmtu passthrough=yes protocol=tcp tcp-flags=syn

add action=accept chain=prerouting in-interface=bridge1 dst-address=10.0.0.0/23
add action=accept chain=prerouting dst-address-type=local,broadcast,multicast in-interface=bridge1

add action=mark-connection chain=prerouting ipsec-policy=in,none in-interface=pppoe-out1 new-connection-mark=pppoe1_conn passthrough=yes
add action=mark-routing chain=prerouting connection-mark=pppoe1_conn in-interface=bridge1 new-routing-mark=pppoe1 passthrough=no
add action=mark-routing chain=output connection-mark=pppoe1_conn new-routing-mark=pppoe1 passthrough=no

add action=mark-connection chain=prerouting ipsec-policy=in,none in-interface=pppoe-out2 new-connection-mark=pppoe2_conn passthrough=yes
add action=mark-routing chain=prerouting connection-mark=pppoe2_conn in-interface=bridge1 new-routing-mark=pppoe2 passthrough=no
add action=mark-routing chain=output connection-mark=pppoe2_conn new-routing-mark=pppoe2 passthrough=no

/ip firewall nat
add action=masquerade chain=srcnat ipsec-policy=out,none out-interface-list=PPPoE
add action=masquerade chain=srcnat dst-address=10.0.0.0/24 dst-address-type=!local out-interface=bridge1 src-address=10.0.0.0/24

/ip firewall filter
add action=fasttrack-connection chain=forward ipsec-policy=in,none connection-mark=no-mark connection-state=established,related connection-nat-state=srcnat in-interface-list=PPPoE

RB760iGS VPN:
#OpenVPN Server:
/interface ovpn-server server
set auth=sha1,sha256 certificate=ovpn.ca default-profile=ovpn.pro enabled=yes netmask=28 protocol=udp redirect-gateway=def1 require-client-certificate=yes

/ppp profile
add change-tcp-mss=yes dns-server=8.8.8.8 interface-list=VPN local-address=10.0.0.200 name=ovpn.pro only-one=no remote-address=vpn1 use-compression=no use-encryption=no use-ipv6=no

/ppp secret
add name=帳號 password=密碼 profile=ovpn.pro service=ovpn

#IKEv2 VPN Server:
/ip ipsec profile
add dpd-interval=disable-dpd enc-algorithm=aes-256,3des hash-algorithm=sha256 name=ikev2.pro prf-algorithm=sha256

/ip ipsec mode-config
add address-pool=vpn2 address-prefix-length=32 name=ikev2.cfg static-dns=8.8.8.8 system-dns=no

/ip ipsec proposal
set [ find default=yes ] auth-algorithms=sha256 enc-algorithms=aes-256-cbc,aes-128-cbc,3des pfs-group=modp2048

/ip ipsec policy group
add name=ike2-s

/ip ipsec policy
add comment=IKEv2-Server group=ike2-s template=yes

/ip ipsec peer
add exchange-mode=ike2 name=ike2.psk-in-server passive=yes profile=ikev2.pro send-initial-contact=no

/ip ipsec identity
add generate-policy=port-strict mode-config=ikev2.cfg my-id=auto peer=ike2.psk-in-server policy-template-group=ike2-s remote-id=ignore secret=密鑰



a22548546 wrote:
先放上架構圖最近發現...(恕刪)

RB5009:
1.nat偽裝不需要
2.路由表不需要dst-address=10.9.1.1/24 gateway=10.99.1.2

fotigate 80e,路由表新增:
dst-address=192.168.1.0 subnet=255.255.255.0 gateway=10.99.1.1
dst-address=192.168.2.0 subnet=255.255.255.0 gateway=10.99.1.1
寶貝:)開心最重要!



gfx wrote:
Q:RB760iGS...(恕刪)



感謝gfx大回覆!
在firewall的部分比小妹的精細多了,實在是感謝。
為了避免無法預期的錯誤,小妹把VPN的部分搬到10.0.1.0/24好了
這樣的話架構會變成
10.0.0.0/24 :main-LAN
10.0.1.0/26 :IKEv2 VPN
10.0.1.64/26 :OpenVPN
10.0.1.128/25 :guest-LAN
然後開啟arp-proxy,應該架設上會簡單很多

目前OpenVPN的設定和gfx大的基本一樣(除了/ppp secret改成用/radius去處理),目前也都work。

另有幾個問題想請教:
  1. 在/interface pppoe-client中,為何2個client的interface都是掛在vlan10(MOD VLAN)底下?
  2. 在/route rule中,為何main-LAN和guest-LAN都使用table=pppoe2?
  3. /ip route 的前兩條規則,如果不給routing-table的值,defaults是給main。但是在/ip firewall mangle裡面,應該都mark-routing成pppoe1或pppoe2了,那還會有沒有mark到的packets走這兩條路徑嗎?
  4. main-LAN裡面有多台電腦,某userA想自行撥接上新的dynamic ip。據我查到的資料,應啟用RouterOS自己的pppoe server給userA撥接,那要如何確保只有userA使用pppoe-out2的dynamic ip,而其他user仍然使用pppoe-out1的static ip?
  5. 從Internat送往RouterI的packets有可能被判定為forward嗎?
    目前IKEv2 Server端的設定目前也是和gfx大的一樣,只是client所送出的IKE_SA_INIT package仍然沒有回應(Client是Android使用strongswan)。
    根據資料並用firewall查找的結果,該packet在通過Prerouting程序後,沒有到Input程序,反而通過了Forward程序,這是正常的嗎?
關閉廣告
文章分享
評分
評分
複製連結
請輸入您要前往的頁數(1 ~ 846)

今日熱門文章 網友點擊推薦!