Community discussions

MikroTik App
 
siudd
just joined
Topic Author
Posts: 3
Joined: Thu Apr 21, 2022 11:30 am

firewall settings for wireguard

Sat Sep 17, 2022 11:02 am

i've setup a road-warrior wireguard server on a remote site with asus ax86u and my phone is able to connect to it with mobile network without any issue. i can access both my router with internal IP, or browser the internet.

however, when i try to access with home wifi which using mikrotik router, i'm not able access my router with internal IP or browser internet. i'm guessing if my mikrotik router firewall block some of the connections. anyone can give some hints? much appreciate!
/ip 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 ICMP" protocol=icmp
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
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 all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN

/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19107
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: firewall settings for wireguard

Sat Sep 17, 2022 1:28 pm

Please provide a network diagram so that the relationships between devices are clear.
It is not clear who initiates the connection, assuming its the iphone in one case and then users behind the MT in another case (both originators), and the asus is the focal point of the tunnels....... (receiver of initial requests).
 
siudd
just joined
Topic Author
Posts: 3
Joined: Thu Apr 21, 2022 11:30 am

Re: firewall settings for wireguard

Sun Sep 18, 2022 1:12 pm

Please provide a network diagram so that the relationships between devices are clear.
It is not clear who initiates the connection, assuming its the iphone in one case and then users behind the MT in another case (both originators), and the asus is the focal point of the tunnels....... (receiver of initial requests).
applogize for wasn't clear enough. both connection in both situations (mobile network and MT backed wifi network) were initiated from iPhone. my iPhone was setup to connect the Asus router via WireGuard.

situation 1
iPhone -----> (mobile network) -----> Asus router (WG) ------> internal network and internet
situation 2
iPhone -----> (MT backed wifi network) -----> Asus router (WG) --X--> internal network and internet
I got a chance to connect my iPhone to another wifi network and was able to connect the Asus router via WG with internal network and internet access. So very likely there are some issues with my MT router...
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19107
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: firewall settings for wireguard

Sun Sep 18, 2022 4:31 pm

A network diagram details the relationships.
Right now I have no idea what the Asus is connected to or what the mikrotik router is connected to. ISP modems (and get public IPs) or to each other etc.........
Why keep mentioning wifi? It has nothing to do with wireguard......

Are they in separate locations?
Does the iphone originate the connection to the asus via wireguard OR does the iphone connect to the mikrotik via wireguard?
Does the mikrotik originate a connection to the asus via wireguard.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
What I think you are stating.
a. ASUS is the main host for your wireguard connections
b. the iphone can connect to the asus over wireguard from any location.
c. the mikrotik can also host wireguard connections
d. the iphone cannot connect to the mikrotik over wireguard from any location.

So if the above is true what is the relations between the ASUS and the MIKROTIK ??
Finally I would need to see.

1. FULL config of the the mikrotik not just snippets /export (minus any public WANIP info or serial number of unit)
2. Snapshot of IPHONE settings when connected to MT (less any public WANIP info)
3. Snapshot of ASUS wireguard settings (minus any key or public WANIP info) for connection to iphone
4. Snapshot of ASUS wireguard settings (minus any key or public WANIP info) for connection to Mikrotik device if that does happen.
 
siudd
just joined
Topic Author
Posts: 3
Joined: Thu Apr 21, 2022 11:30 am

Re: firewall settings for wireguard

Mon Sep 19, 2022 3:53 pm

Are they in separate locations?
Does the iphone originate the connection to the asus via wireguard OR does the iphone connect to the mikrotik via wireguard?
Does the mikrotik originate a connection to the asus via wireguard.

Asus (location A) is in separate location with the mikrotik (location B). It is the iPhone originate the connection to the asus via wireguard, not the mikrotik originate. Apologize should have made it clearer in first place.

What I think you are stating.
a. ASUS is the main host for your wireguard connections
b. the iphone can connect to the asus over wireguard from any location.
c. the mikrotik can also host wireguard connections
d. the iphone cannot connect to the mikrotik over wireguard from any location.

So if the above is true what is the relations between the ASUS and the MIKROTIK ??

a. Yes
b. The iPhone can connect to Asus over wireguard with mobile network
c. didn't setup mikrotik for wireguard connection
d. The iPhone cannot connect to Asus over wireguard with the mikrotik network
actually there is no relation between the Asus and the mikrotik. You could simply treat the mikrotik is just providing network (internet) connection in location B to the iPhone.

Finally I would need to see.

1. FULL config of the the mikrotik not just snippets /export (minus any public WANIP info or serial number of unit)
2. Snapshot of IPHONE settings when connected to MT (less any public WANIP info)
3. Snapshot of ASUS wireguard settings (minus any key or public WANIP info) for connection to iphone
4. Snapshot of ASUS wireguard settings (minus any key or public WANIP info) for connection to Mikrotik device if that does happen.

1. FULL config (note 192.168.1.5 is adguard home DNS)
/interface bridge
add admin-mac=11:22:33:44:55:66 auto-mac=no comment=defconf name=bridge
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface lte apn
set [ find default=yes ] ip-type=ipv4 use-network-apn=no
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool ranges=192.168.1.200-192.168.1.254
/ip dhcp-server
add add-arp=yes address-pool=dhcp_pool interface=bridge name=dhcp
/port
set 0 name=serial0
/interface bridge port
add bridge=bridge comment=defconf ingress-filtering=no interface=ether2
add bridge=bridge comment=defconf ingress-filtering=no interface=ether3
add bridge=bridge comment=defconf ingress-filtering=no interface=ether4
add bridge=bridge comment=defconf ingress-filtering=no interface=ether5
add bridge=bridge comment=defconf ingress-filtering=no interface=sfp1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/ipv6 settings
set disable-ipv6=yes max-neighbor-entries=8192
/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 ovpn-server server
set auth=sha1,md5
/ip address
add address=192.168.1.1/24 comment=defconf disabled=yes interface=ether2 \
    network=192.168.1.0
add address=192.168.1.1/24 interface=bridge network=192.168.1.0
/ip dhcp-client
add comment=defconf interface=ether1 use-peer-dns=no
/ip dhcp-relay
add dhcp-server=192.168.1.1 disabled=no interface=bridge name=dhcp_relay
/ip dhcp-server network
add address=192.168.1.0/24 comment=defconf dns-server=192.168.1.5 gateway=\
    192.168.1.1 netmask=24
/ip dns
set allow-remote-requests=yes servers=192.168.1.5 verify-doh-cert=yes
/ip 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 ICMP" protocol=icmp
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
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 all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
/ip service
set www port=1234
/system clock
set time-zone-name=Asia/Hong_Kong
/system identity
set name=home
/tool graphing interface
add interface=ether1
add interface=ether3
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN

2. Snapshot of IPHONE wireguard settings when connected to Asus
IMG_7731.jpg
3. Snapshot of ASUS wireguard settings
IMG_7734.jpg
IMG_7733.jpg
4. N/A
You do not have the required permissions to view the files attached to this post.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19107
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: firewall settings for wireguard

Mon Sep 19, 2022 7:44 pm

Hmmm so let me get this straight.
NO WIREGUARD connections are needed at all on the mikrotik??
The IPHONE connects anywhere to the ASUS via wireguard be it through a wifi coffee shop, hotel wifi, or cellular signal or through wifi at home.
Which is a logical conclusion.

If that is the case, then this thread is not relative to mikrotik and thus cannot provide any assistance.
The decision for your phone to go out wireguard and not to the subnets of the MT router IS A PHONE ISSUE not an mt issue.

Presumably, the smartphone is on one of your LAN subnets when connected via wifi, and as such follows the firewall rules that pertainb to the LAN.
So when you want to access the router subnets and or internet through the local MT router, do not turn on the wireguard application!!

Who is online

Users browsing this forum: anav, Bing [Bot], ernieball17, wsantos and 70 guests