Reach a vpn from another vpn

Hello everyone.
At work i have a vpn with a costumer via IPSec from our Mikrotik to their site wich is managed by another office. The subnets are 192.1.0.0/22 on their site and 172.16.10.0/24 on our side.
If, on my pc at work, i assign an ip on the /24 subnet i have no problems to reach all of their pc and stuff.
Now cause covid i’m working from home and i would like to not use anydesk or such to reach my pc at work and do stuff.
At home i have a gre tunnel to reach my office. All works well, i have added a 192.168.20.0/24 subnet to the Mikrotik at work so i can use my 192.168.0.0/24 at home (where i have a Mikrotik too).
Since i have total control on both Mikrotiks i tried to set the routes on the Mikrotiks but of course the customer side don’t know about my 192.168.0.0/24 or if they know it’s the subnet of someone else.

I was thinking about masquerading but i have no idea how to do it to reach just one subnet and where to put. Also if i’m right, masquerading needs an interfaces and site-to-site ipsec don’t create any interface i can work with.
What i can do?
I’m open to all suggestions, the only limit is that i can’t access customer vpn configuration.
Thank you all in advance.

Use action=src-nat instead of action=masquerade. action=src-nat doesn’t need to be linked to any interface, so you can set it up on your office Tik and let it match only on src-address=192.168.20.0/24 dst-address=192.1.0.0/22 on their side (I assume 192.1.0.0 is a typo but I follow the suite). It’s up to you whether you use the office Tik’s own address in 172.16.10.0/24 or some unassigned one as to-addresses in the rule.

Thank you a lot for the quick answer and to point me do the right direction. And no, it’s not a typo. My customer has a subnet 192.1.0.0/22 for over 1000 ip. My fingers makes always a lot of mistakes when i work with them cause i think my finger have memorized 192.168.x.x and write on their own. :smiley:
I’m working with the scr-nat now and trying the easiest step before to work on the routings.
So via anydesk i contacted my pc, assigned it an ip on the usual network we use at work 192.168.1.0/24 and today it’s .113 with gw .1
Under firewall->nat i have added as line zero
chain=srcnat action=src-nat to-addresses=172.16.10.1 src-address=192.168.1.0/24 dst-address=192.1.0.0/22 log=yes
log-prefix=“”

in the log i get this
https://i.imgur.com/U1hGLPC.png

I see the 192.168.1.113 being changed to 172.16.10.1 but the ping don’t work and i can’t reach the synology on the other side.

But if i ping from terminal [admin@MikroTik] > ping 192.1.2.152 src-address=172.16.10.1
SEQ HOST SIZE TTL TIME STATUS
0 192.1.2.152 56 60 19ms
1 192.1.2.152 56 60 27ms
2 192.1.2.152 56 60 20ms
3 192.1.2.152 56 60 19ms
sent=4 received=4 packet-loss=0% min-rtt=19ms avg-rtt=21ms max-rtt=27ms

In the connection tab i get:

What i’m doing wrong?

Without seeing the complete export of your configuration, I can only speculate that there is either some action=notrack rule in chain=prerouting of /ip firewall raw which prevents the “un-src-nat” from working, or that you have an unusual setup in chain=forward of /ip firewall filter, which prevents the responses from being delivered to the client.

See my automatic signature on how to post your configuration safely.

Yes, i have a couple of rules in raw for that, cause the manual suggest to use raw rules for site to site vpn instead of masquerading.

Anyways here is the config of my mikrotik at work

may/05/2020 19:03:57 by RouterOS 6.46.4

software id =

model = RB4011iGS+

serial number =

/interface bridge
add admin-mac=C4:AD:34:59:22:9F auto-mac=no comment=defconf name=bridge
/interface ethernet
set [ find default-name=ether5 ] name=->Netgear
set [ find default-name=ether1 ] name=Tim
/interface gre
add allow-fast-path=no name=Gre->Deunan remote-address=EE.FF.GG.HH
/interface ethernet switch port
set 0 default-vlan-id=0
set 1 default-vlan-id=0
set 2 default-vlan-id=0
set 3 default-vlan-id=0
set 4 default-vlan-id=0
set 5 default-vlan-id=0
set 6 default-vlan-id=0
set 7 default-vlan-id=0
set 8 default-vlan-id=0
set 9 default-vlan-id=0
set 10 default-vlan-id=0
set 11 default-vlan-id=0
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip ipsec policy group
add name=RoadWarrior
/ip ipsec profile
set [ find default=yes ] dpd-interval=disable-dpd enc-algorithm=3des
add dh-group=modp1024 dpd-interval=5m enc-algorithm=3des hash-algorithm=md5
name=profile_1
add dh-group=modp1024 enc-algorithm=3des lifetime=8h name="Customer Profile"
/ip ipsec peer
add address=AA.BB.CC.DD/32 name=Customer profile="Customer Profile"
add name=Vpn-RoadWarrior passive=yes profile=profile_1
/ip ipsec proposal
set [ find default=yes ] auth-algorithms=sha1,md5 enc-algorithms=3des
add auth-algorithms=sha1,md5 enc-algorithms=3des name=VpnGenericaRW
add enc-algorithms=3des lifetime=8h name=Customer pfs-group=none
/ip pool
add name=dhcpvlan254 ranges=192.168.1.2-192.168.1.199
add name=ipsec-RW ranges=192.168.77.2-192.168.77.254
/ip dhcp-server
add address-pool=dhcpvlan254 interface=bridge name=dhcp1
/ip ipsec mode-config
add address-pool=ipsec-RW name=RW-cfg split-include=192.168.1.0/24
/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=->Netgear
add bridge=bridge comment=defconf interface=ether6
add bridge=bridge comment=defconf interface=ether7
add bridge=bridge comment=defconf interface=ether8
add bridge=bridge comment=defconf interface=ether9
add bridge=bridge comment=defconf interface=ether10
add bridge=bridge comment=defconf interface=sfp-sfpplus1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface ethernet switch vlan
add independent-learning=no ports=->Netgear switch=switch1 vlan-id=254
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=Tim list=WAN
add interface=Gre->Deunan list=LAN
/ip address
add address=public.ip/29 interface=Tim network=94.85.120.224
add address=192.168.1.1/24 interface=bridge network=192.168.1.0
add address=172.16.10.1/24 interface=bridge network=172.16.10.0
add address=192.168.20.1/24 interface=bridge network=192.168.20.0
add address=10.0.0.2/30 interface=Gre->Deunan network=10.0.0.0
add address=172.16.10.250/24 interface=bridge network=172.16.10.0
/ip cloud
set ddns-enabled=yes
/ip dhcp-client
add comment=defconf interface=Tim
/ip dhcp-server lease
add address=192.168.254.248 mac-address=8C:3B:AD:68:C9:34 server=dhcp1
/ip dhcp-server network
add address=192.168.1.0/24 dns-server=8.8.8.8 gateway=192.168.1.1
/ip dns
set servers=8.8.8.8
/ip dns static
add address=192.168.1.1 comment=defconf name=router.lan
/ip firewall address-list
add address=collina.dyndns list=Winbox
add address=mikrotik.dyndns list=Winbox
add address=mikrotik2.dyndns list=Winbox
/ip firewall filter
add action=accept chain=input dst-port=8291 protocol=tcp src-address-list=
Winbox
add action=accept chain=input dst-port=500 log-prefix="Udp 500" protocol=udp
add action=accept chain=input dst-port=4500 log-prefix="Udp 500" 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
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
/ip firewall mangle
add action=log chain=forward dst-address=192.1.0.0/22 log=yes log-prefix=
"-> Mangle Customer"
/ip firewall nat
add action=src-nat chain=srcnat dst-address=192.1.0.0/22 log=yes log-prefix=
"Srcnat Customer" src-address=192.168.1.0/24 to-addresses=172.16.10.1
add action=src-nat chain=srcnat dst-address=192.1.0.0/22 log=yes log-prefix=
"Srcnat Customer" src-address=192.168.20.0/24 to-addresses=172.16.10.1
add action=masquerade chain=srcnat comment="defconf: masquerade"
ipsec-policy=out,none out-interface-list=WAN
add action=dst-nat chain=dstnat disabled=yes dst-port=22 in-interface-list=
WAN protocol=tcp src-address-list=Winbox to-addresses=192.168.1.251
add action=dst-nat chain=dstnat disabled=yes dst-port=3389 in-interface-list=
WAN protocol=tcp src-address-list=Winbox to-addresses=192.168.1.251
add action=dst-nat chain=dstnat dst-port=80 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.40
add action=dst-nat chain=dstnat dst-port=10000 in-interface-list=WAN
protocol=tcp to-addresses=192.168.1.40
add action=dst-nat chain=dstnat dst-port=8888 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.40 to-ports=80
add action=dst-nat chain=dstnat dst-port=22 in-interface-list=WAN protocol=
tcp src-address-list=Winbox to-addresses=192.168.1.40
add action=dst-nat chain=dstnat dst-port=36330 in-interface-list=WAN
protocol=tcp src-address-list=Winbox to-addresses=192.168.1.113
add action=dst-nat chain=dstnat comment="Folding at home" dst-port=36331
in-interface-list=WAN protocol=tcp src-address-list=Winbox to-addresses=
192.168.1.35 to-ports=36330
add action=dst-nat chain=dstnat dst-port=3478 in-interface-list=WAN protocol=
udp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=5514 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=8080 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=8880 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=8843 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=6789 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=27117 in-interface-list=WAN
protocol=tcp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=5656-5699 in-interface-list=WAN
protocol=udp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=10001 in-interface-list=WAN
protocol=udp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=8443 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.35
add action=dst-nat chain=dstnat dst-port=110 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.40
add action=dst-nat chain=dstnat disabled=yes dst-port=443 in-interface-list=
WAN protocol=tcp to-addresses=172.16.10.200
add action=dst-nat chain=dstnat dst-port=143 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.40
add action=dst-nat chain=dstnat dst-port=25 in-interface-list=WAN log-prefix=
Smtp-In protocol=tcp to-addresses=192.168.1.40
add action=dst-nat chain=dstnat dst-port=587 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.40
add action=dst-nat chain=dstnat dst-port=993 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.40
add action=dst-nat chain=dstnat dst-port=995 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.40
add action=dst-nat chain=dstnat dst-port=465 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.40
add action=dst-nat chain=dstnat disabled=yes dst-port=8080 in-interface-list=
WAN protocol=tcp to-addresses=192.168.1.44
add action=dst-nat chain=dstnat disabled=yes dst-port=21 in-interface-list=
WAN log=yes protocol=tcp to-addresses=192.168.1.96
add action=dst-nat chain=dstnat disabled=yes dst-port=3000 in-interface=Tim
protocol=tcp to-addresses=192.168.1.51
add action=dst-nat chain=dstnat dst-port=5000 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.96
add action=dst-nat chain=dstnat dst-port=5001 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.103
add action=dst-nat chain=dstnat disabled=yes dst-port=5060 in-interface=Tim
protocol=tcp to-addresses=192.168.1.103
add action=dst-nat chain=dstnat disabled=yes dst-port=5060 in-interface=Tim
protocol=udp to-addresses=192.168.1.103
add action=dst-nat chain=dstnat disabled=yes dst-port=5061 in-interface=Tim
protocol=udp to-addresses=192.168.1.103
add action=dst-nat chain=dstnat disabled=yes dst-port=5090 in-interface=Tim
protocol=udp to-addresses=192.168.1.103
add action=dst-nat chain=dstnat disabled=yes dst-port=5090 in-interface=Tim
protocol=tcp to-addresses=192.168.1.103
add action=dst-nat chain=dstnat dst-port=16881 in-interface-list=WAN
protocol=udp to-addresses=192.168.1.96
add action=dst-nat chain=dstnat dst-port=6881 in-interface-list=WAN protocol=
udp to-addresses=192.168.1.96
add action=dst-nat chain=dstnat dst-port=16881 in-interface-list=WAN
protocol=tcp to-addresses=192.168.1.96
add action=dst-nat chain=dstnat dst-port=4500 in-interface-list=WAN protocol=
tcp to-addresses=192.168.1.1
/ip firewall raw
add action=accept chain=prerouting dst-address=192.168.77.0/24 src-address=
192.168.1.0/24
add action=accept chain=prerouting dst-address=192.168.1.0/24 src-address=
192.168.77.0/24
add action=notrack chain=prerouting dst-address=192.1.0.0/22 src-address=
172.16.10.0/24
add action=notrack chain=prerouting dst-address=192.1.0.0/22 src-address=
192.168.0.0/24
add action=notrack chain=prerouting dst-address=172.16.10.0/24 src-address=
192.1.0.0/22
add action=notrack chain=prerouting disabled=yes dst-address=192.168.1.0/24
src-address=192.1.0.0/22
add action=notrack chain=prerouting disabled=yes dst-address=192.1.0.0/22
src-address=192.168.1.0/24
add action=accept chain=prerouting dst-address=192.168.0.0/24 src-address=
192.168.20.0/24
add action=accept chain=prerouting dst-address=192.168.20.0/24 src-address=
192.168.0.0/24
/ip ipsec identity
add generate-policy=port-strict mode-config=RW-cfg peer=Vpn-RoadWarrior
policy-template-group=RoadWarrior
add peer=Customer
/ip ipsec policy
set 0 disabled=yes group=RoadWarrior
add dst-address=192.168.77.0/24 group=RoadWarrior proposal=VpnGenericaRW
src-address=192.168.1.0/24 template=yes
add dst-address=192.1.0.0/22 peer=Customer proposal=Customer sa-dst-address=
AA.BB.CC.DD sa-src-address=94.85.120.227 src-address=172.16.10.0/24
tunnel=yes
/ip route
add distance=1 gateway=public.ip gw
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set ssh disabled=yes
set api disabled=yes
set api-ssl disabled=yes
/routing ospf network
add area=backbone network=10.0.0.0/30
add area=backbone network=192.168.20.0/24
add area=backbone network=172.16.10.0/24
/system clock
set time-zone-name=Europe/Rome
/system logging
add disabled=yes topics=ipsec
add disabled=yes topics=ospf
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN

Okay, that’s the problem. The NAT operations depend on connection tracking, and an action=notrack rule in /ip firewall raw makes the packets from 192.1.0.0/22 to 172.16.10.0/24 bypass connection tracking.

The manual works with the typical case, which expects that if you connect to some network using an IPsec tunnel, you don’t need advanced firewall functions because that network is considered secure. So they kill several flies by one smash, reduce CPU consumption and exclude connections via the tunnel from the effect of the commonly used “masquerade whatever should leave via WAN” srcnat rule.

My personal opinion is that having no firewall between own network and other company’s one is a Bad Idea.

Plus you have excluded the traffic between 192.1.0.0/22 and 172.16.10.0/24 from connection tracking only in one direction (client to you), which made the NAT rule “half work” - all the packets from you to client get src-nated but the responses don’t get “un-src-nated”.

So disable that action=notrack rule and try again.

Thank you a lot!
It’s working now.
After i have disabled the no-track in the office Mikrotik the ping from the office pc was successfull. Then i applyied again the routes to reach my home but it was KO.
So with the connections tab i tracked the src address and it was the IP of my Gre tunnel. To solve it i have src natted the 10.0.0.1 but was still not working. Then i applied the same rule to my home Mikrotik and src-natted the 192.168.0.0/24 to 10.0.0.1 and voilà! Now i can reach their whole network from home.
Thank you again.

Kidrash

It should not be necessary to use src-nat on the path between your home and the office - a route to 192.1.0.0/22 via the GRE tunnel at your home Tik, and a route to your home subnet via the GRE tunnel at your office Tik, is the right way. And of course the src-nat rule at the office Tik has to refer to your home subnet as src-address.

The route from home to office, 192.1.0.0/22 via 10.0.0.2 (the ip on gre interface at work) was already in place.
Of course from office and home the routes for and to 192.168.0.0/24<>192.168.1.0/24 were alredy set. Ospf made its work :smiley:
I will investigate why not works without src-nat. I have this working configuration as backupplan so i can both work and test things.