RouterOS wireguard

新手學用RouterOS, set 咗wireguard interface 同peer, 用iphone connect 到,見到handshake 成功,但connect 完iphone 冇辦法access local network 或者 internet, 可能係firewall rules set 錯。
iphone WG ip: 10.0.1.2
RouterOS WG ip: 10.0.1.1
Local network ip: 192.168.1.0/24

另外試過唔用RouterOS 個WG, port forward 去RPi4 個WG, local network 同internet 都可以access

有冇高手可以教吓小弟,唔該晒!!

估计你需要set static route,不然怎样access到local network!

TOP

估计你需要set static route,不然怎样access到local network!
张无忌 發表於 2022-4-26 18:42


不是.

TOP

新手學用RouterOS, set 咗wireguard interface 同peer, 用iphone connect 到,見到handshake 成功,但conne ...
syndicate 發表於 2022-4-26 18:28




兩端的Allowed address要像圖中這樣set.
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

兩端的Allowed address要像圖中這樣set.
雯雯 發表於 2022-4-26 19:20


因为没有set过WireGuard,所以建议set static route,如果里面WireGuard可以set,那么就更加方便!

TOP

回復 4 #雯雯

Server應該係allow Peer IP就得
而Client先係allow 0.0.0.0/0

以下係我響VPS度用Debian起嘅WG
Server config:
  1. [Interface]
  2. Address = 192.168.69.1/24
  3. PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  4. PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
  5. ListenPort = 51820
  6. PrivateKey = RESULT_OF_private_server_key
  7. [Peer]
  8. PublicKey=RESULT_OF_public_client_key
  9. PresharedKey=RESULT_OF_presharedkey
  10. AllowedIPs=192.168.69.2
  11. PersistentKeepalive=30
複製代碼

Client config:
  1. [Interface]
  2. PrivateKey = RESULT_OF_private_client_key
  3. Address = 192.168.69.2/24
  4. DNS = 192.168.69.1
  5. [Peer]
  6. PublicKey = RESULT_OF_public_server_key
  7. PresharedKey = RESULT_OF_presharedkey
  8. Endpoint = domain_name:51820
  9. AllowedIPs = 0.0.0.0/0
複製代碼

就算放落ROS應該都唔會變先係?

via HKEPC Reader for Android

TOP

connect 冇問題,係access 唔到local network 同internet
估計係同postup/postdown 嘅 有關,因為我同一套config set 係RPi4 做server 經port forward 入冇問題
不過RouterOS 唔知點set postup/postdown d route

TOP

https://help.mikrotik.com/docs/display/ROS/WireGuard

有冇試過睇呢份黎做?

via HKEPC Reader for Android

TOP

Type "/export hide-sensitive file=export.rsc" in terminal. Download the export.rsc file from Winbox, open that file with NotePad, then post all contents here using the code function.

Nobody knows what's going on without knowing your settings.

TOP

here you go, thanks.

# apr/26/2022 21:52:39 by RouterOS 7.2.1
# software id = 5XU8-2EEP
#
# model = RBD52G-5HacD2HnD
# serial number =
/interface bridge
add admin-mac=DC:1C:6E:12:03:23 auto-mac=no comment=defconf name=bridge
/interface wireless
set [ find default-name=wlan1 ] band=2ghz-b/g/n channel-width=20/40mhz-XX \
    distance=indoors frequency=auto installation=indoor mode=ap-bridge ssid=\
    MikroTik-12C266 wireless-protocol=802.11
set [ find default-name=wlan2 ] band=5ghz-a/n/ac channel-width=\
    20/40/80mhz-XXXX country="hong kong" distance=indoors frequency=auto \
    installation=indoor mode=ap-bridge ssid=MikroTik wireless-protocol=802.11
/interface wireguard
add listen-port=13231 name=wireguard1
/disk
set usb1 disabled=no
set usb1-part1 disabled=no name=disk1
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa2-psk mode=dynamic-keys \
    supplicant-identity=MikroTik
/ip pool
add name=dhcp ranges=192.168.1.2-192.168.1.254
/ip dhcp-server
add address-pool=dhcp disabled=yes interface=bridge name=defconf
/routing table
add disabled=no fib name=VPN
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=wlan1
add bridge=bridge comment=defconf interface=wlan2
/interface bridge settings
set use-ip-firewall=yes
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface detect-internet
set detect-interface-list=all
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/interface wireguard peers
add allowed-address=10.0.1.2/32 endpoint-address=138.19.189.88 endpoint-port=\
    13231 interface=wireguard1 public-key=\
    "zEuWY0yM6rZrxCxD7G1m2eIvNARQ+Nux812x3XVkKL04="
/ip address
add address=192.168.1.1/24 comment=defconf interface=bridge network=\
    192.168.1.0
add address=10.0.1.0/24 interface=wireguard1 network=10.0.1.0
/ip dhcp-client
add comment=defconf interface=ether1 use-peer-dns=no use-peer-ntp=no
/ip dhcp-server network
add address=192.168.1.0/24 comment=defconf dns-server=192.168.1.200 gateway=\
    192.168.1.1 netmask=24
/ip dns
set cache-size=4096KiB servers=192.168.1.101,192.168.1.200
/ip dns static
add address=192.168.1.1 comment=defconf name=router.lan
/ip firewall address-list
add address=www.autotrader.ca list=Autotrader
/ip firewall filter
add action=accept chain=input dst-port=13231 log-prefix=Wireguard protocol=\
    udp
add action=accept chain=input comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
    invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
    "defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
    ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
    ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
    connection-state=established,related hw-offload=yes
add action=accept chain=forward comment=\
    "defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
add action=drop chain=forward comment=\
    "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN
add action=fasttrack-connection chain=forward comment=Fasttrack \
    connection-state=established,related disabled=yes hw-offload=yes
add action=accept chain=forward connection-state=established,related \
    disabled=yes
/ip firewall mangle
add action=mark-routing chain=prerouting dst-address-list=Autotrader \
    new-routing-mark=VPN passthrough=yes
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
add action=masquerade chain=srcnat dst-address-list=Mercedes log=yes \
    log-prefix=VPN out-interface=vyprVPN-Canada
add action=masquerade chain=srcnat dst-address-list=BMW out-interface=\
    vyprVPN-Canada
add action=masquerade chain=srcnat dst-address-list=Autotrader out-interface=\
    vyprVPN-Canada
/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=vyprVPN-Canada \
    routing-table=VPN suppress-hw-offload=no
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www address=192.168.1.0/24 port=8080
set ssh address=192.168.1.0/24 port=222
set api disabled=yes
set winbox address=192.168.1.0/24
set api-ssl disabled=yes
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 firewall filter
add action=accept chain=input comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
    invalid
add action=accept chain=input comment="defconf: accept ICMPv6" protocol=\
    icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=\
    33434-33534 protocol=udp
add action=accept chain=input comment=\
    "defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\
    udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \
    protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\
    ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\
    ipsec-esp
add action=accept chain=input comment=\
    "defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=input comment=\
    "defconf: drop everything else not coming from LAN" in-interface-list=\
    !LAN
add action=accept chain=forward comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
add action=drop chain=forward comment=\
    "defconf: drop packets with bad src ipv6" src-address-list=bad_ipv6
add action=drop chain=forward comment=\
    "defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \
    hop-limit=equal:1 protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\
    icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=\
    500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\
    ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\
    ipsec-esp
add action=accept chain=forward comment=\
    "defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=forward comment=\
    "defconf: drop everything else not coming from LAN" in-interface-list=\
    !LAN
/system clock
set time-zone-name=Asia/Hong_Kong
/system routerboard settings
set auto-upgrade=yes
/system scheduler
add interval=1d name="Config backup" on-event="/export file=export\r\
    \n/tool e-mail send to=\"xxxxx@gmail.com\" subject=\"\$[/system identity\
    \_get name]  export\" \\\r\
    \nbody=\" configuration file \$[/system clock get date]\" file=export.rsc" \
    policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
    start-date=apr/26/2022 start-time=00:00:00
/tool bandwidth-server
set enabled=no
/tool graphing interface
add
/tool graphing resource
add
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN

TOP