Community discussions

MikroTik App
 
User avatar
stefki
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Mon Aug 29, 2016 2:13 pm

Routing between two dhcp-servers across two routers

Thu Mar 11, 2021 1:19 pm

Hello, I have spend few days in thinking about how this can be done. I have two rooms in my house with two routers connected to ISP 1 and ISP2, and two local networks.

Room1 has CRS125-24G-1S which is connected directly to WAN ISP1 and local dhcp network 192.168.81.0/24. On this network i have few devices connected pc, synology etc.
Room2 has RB2011UiAS-2HnD which is connected to another WAN ISP2 and local network dhcp network 192.168.82.0/24 , on this network also I have another machines connected laptop, satbox etc.

Both routers are connected on ether3 directly with 7 meters UTP cable. I want all local traffic to be routed between these two ether points.
The problem is that I can't ping or reach the devices from room1 to room2 and vice versa.

example:
I want to access to my synology from room 2 with network 192.168.82.0/24

Synology is on network 192.168.81.0/24

Here is the topology on my network
Home routers.png
setup config from room1 CRS125-24G-1S
/interface ethernet
set [ find default-name=ether1 ] comment=WAN
set [ find default-name=ether2 ] comment="DHCP Server"
set [ find default-name=ether3 ] comment="Local to RB2011UiAS-2HnD"
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool0 ranges=192.168.81.2-192.168.81.254
/ip dhcp-server
add address-pool=dhcp_pool0 disabled=no interface=ether2 name=dhcp1
/ip address
add address=192.168.81.1/24 interface=ether2 network=192.168.81.0
add address=5.5.5.1/24 interface=ether3 network=5.5.5.0
/ip dhcp-client
add disabled=no interface=ether1
/ip dhcp-server network
add address=5.5.5.0/24 gateway=5.5.5.2
add address=192.168.81.0/24 gateway=192.168.81.1
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1 src-address=192.168.81.0/24
/system identity
set name=CRS125-24G-1S

setup config room2 RB2011UiAS-2HnD
/interface ethernet
set [ find default-name=ether1 ] comment=WAN
set [ find default-name=ether2 ] comment=DHCP-Server
set [ find default-name=ether3 ] comment="Local to CRS125-24G-1S"
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool0 ranges=192.168.82.2-192.168.82.254
/ip dhcp-server
add address-pool=dhcp_pool0 disabled=no interface=ether2 name=dhcp1
/ip address
add address=192.168.82.1/24 interface=ether2 network=192.168.82.0
add address=5.5.5.2/24 interface=ether3 network=5.5.5.0
/ip dhcp-client
add disabled=no interface=ether1
/ip dhcp-server network
add address=5.5.5.0/24 gateway=5.5.5.1
add address=192.168.82.0/24 gateway=192.168.82.1
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1 src-address=192.168.82.0/24
/system identity
set name=RB2011UiAS-2HnD
You do not have the required permissions to view the files attached to this post.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11547
Joined: Thu Mar 03, 2016 10:23 pm

Re: Routing between two dhcp-servers across two routers  [SOLVED]

Thu Mar 11, 2021 1:59 pm

  1. You really should use a private subnet address numbering in the CRS125-RB2011 connection subnet. The ones you're using now are in principle public IP addresses and you could run into some issues later.
  2. You don't need DHCP server running on connection subnet. Both routers have statically set addresses on those two interfaces, hence DHCP servers on those interfaces are not used at all.
  3. Instead you should add static routes on both routers.
    CRS125:
    /ip route
    add dst-address=192.168.82.0/24 gateway=5.5.5.2
    
    RB2011:
    /ip route
    add dst-address=192.168.81.0/24 gateway=5.5.5.1
    
    You have to adjust gateway addresses to ones you'll be using eventually.

I'm tempted to mention that you really should add some firewall to both devices ... but I won't ;-)
 
User avatar
stefki
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Mon Aug 29, 2016 2:13 pm

Re: Routing between two dhcp-servers across two routers

Fri Mar 12, 2021 3:51 pm

@mkx: thank you very much , works perfectly.

Now I have another problem with routing between lan networks and openvpn client.

I have OpenVPN server on my CRS125-24G-1S, when my laptop connects from remote place trough VPN , I got all remote devices from this network only 192.168.81/0/24, but I am not able to get access to my other devices from 192.168.82.0/24 (RB2011UiAS-2HnD)

Code from CRS125-24G-1S
/ppp profile
add local-address=192.168.3.1 name=vpn-profile remote-address=vpn-pool use-encryption=yes
/ppp secret
add name=lenovoT430 password=xxxx profile=vpn-profile service=ovpn
/ip pool
add name=vpn-pool ranges=192.168.3.2-192.168.3.20
/interface ovpn-server server
set auth=sha1 certificate=server-template cipher=aes256 default-profile=vpn-profile enabled=yes port=23xxx require-client-certificate=yes
/ip firewall nat
add action=masquerade chain=srcnat comment=VPN out-interface=ether1 src-address=192.168.3.0/24
/ip route rule
add dst-address=192.168.0.0/16 src-address=192.168.0.0/16 table=main

 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11547
Joined: Thu Mar 03, 2016 10:23 pm

Re: Routing between two dhcp-servers across two routers

Fri Mar 12, 2021 4:15 pm

Technically you have 2 LAN subnets at CRS125: 192.168.81.0/24 and 192.168.3.0/24 (doesn't matter if they're behind VPN or ethernet interface) ... if you want clients in 192.168.82.0/24 to access either of CRS125's subnets (and vice versa), you have to add a corresponding static route on RB2011. And review firewall rules, those might block connectivity as well.

Who is online

Users browsing this forum: enricosm60, UkRainUa and 28 guests