The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,776 other followers

Mikrotik – splitting your local LAN so you can assign different gateways and DNS servers by the DHCP server

Posted by jpluimers on 2017/06/09

When you want your Mikrotik DHCP Server handout different gateways (or DNS/WINS/NTP/.. servers and other settings), many of the answers tell you to fiddle with the DHCP networks like DHCP Server different gateways – MikroTik RouterOS [WayBack] but lack concrete examples, so here we go elaborating a lot on DHCP server with static leases – MikroTik RouterOS [WayBack]:

DHCP on a Mikrotik starts with one or more DHCP servers each services on a certain interface from an address pool:

In my case, the pool spans most of a /24 network leaving some room for non-DHCP configured hosts at the bottom and top of the /24 range:

The DHCP server hands out addresses from that pool either static or dynamic as you can make each entry static using the Make Static button:

With a static entry, you can change other options (and revert to dynamic by pressing the Remove button) like the Address or Server:

Back to the DHCP server: it matches the address handed out by the pool (either static or dynamic) with the configured DHCP networks and based on the match the DHCP server will send specific information the gateway/DNS/WINS/NTP servers and other options from the DHCP network to the client.

Most configurations start out with just one configured DHCP network which means they have one set of gateway/DNS/WINS/NTP servers and other options:

The trick to get multiple sets of gateway/DNS/WINS/NTP servers and other DHCP options is two-fold:

  1. Split the DHCP network into multiple subnets
  2. Use static DHCP leases to force certain hosts in certain subnets

An important thing to remember here: be sure to care for IP addresses that were handed out but after the split fall into the “reserved” part of a network (the network address at the bottom and broadcast address at the top of each subnet) and re-assign any of those addresses

So i used wanted to split my 192.168.71.128/24 local network into a few sub-networks: one /25 and two /26 networks.

For this I used ipcalc (an online version is at IP Calculator / IP Subnetting aka http://jodies.de/ipcalc) which I mentioned before in Getting the IP addresses of gmail MX servers – via Super User – dig isn’t enough.

I used these to split up the network

Note I could have split them in four /26 subnets but that meant going from 254 hosts back to 248 (62+62+62+62). Now I go back to 250 (126 + 62 + 62) hosts:

Subnet:
Address:   192.168.71.0          11000000.10101000.01000111 .00000000
Netmask:   255.255.255.0 = 24    11111111.11111111.11111111 .00000000
Wildcard:  0.0.0.255             00000000.00000000.00000000 .11111111
=>
Network:   192.168.71.0/24       11000000.10101000.01000111 .00000000 (Class C)
Broadcast: 192.168.71.255        11000000.10101000.01000111 .11111111
HostMin:   192.168.71.1          11000000.10101000.01000111 .00000001
HostMax:   192.168.71.254        11000000.10101000.01000111 .11111110
Hosts/Net: 254                   (Private Internet)

Subnets

Netmask:   255.255.255.128 = 25  11111111.11111111.11111111.1 0000000
Wildcard:  0.0.0.127             00000000.00000000.00000000.0 1111111
Network:   192.168.71.0/25       11000000.10101000.01000111.0 0000000 (Class C)
Broadcast: 192.168.71.127        11000000.10101000.01000111.0 1111111
HostMin:   192.168.71.1          11000000.10101000.01000111.0 0000001
HostMax:   192.168.71.126        11000000.10101000.01000111.0 1111110
Hosts/Net: 126                   (Private Internet)

Netmask:   255.255.255.192 = 26  11111111.11111111.11111111.11 000000
Wildcard:  0.0.0.63              00000000.00000000.00000000.00 111111
Network:   192.168.71.128/26     11000000.10101000.01000111.10 000000 (Class C)
Broadcast: 192.168.71.191        11000000.10101000.01000111.10 111111
HostMin:   192.168.71.129        11000000.10101000.01000111.10 000001
HostMax:   192.168.71.190        11000000.10101000.01000111.10 111110
Hosts/Net: 62                    (Private Internet)
Network:   192.168.71.192/26     11000000.10101000.01000111.11 000000 (Class C)
Broadcast: 192.168.71.255        11000000.10101000.01000111.11 111111
HostMin:   192.168.71.193        11000000.10101000.01000111.11 000001
HostMax:   192.168.71.254        11000000.10101000.01000111.11 111110
Hosts/Net: 62                    (Private Internet)

Subnets:   3 
Hosts:     250

Since ipcalc cannot do that in one step, I’ve done 2 steps.

Going from 254 to 250 hosts means these addresses cannot be used any more:

  • 192.168.71.127
  • 192.168.71.128
  • 192.168.71.191
  • 192.168.71.192

Luckily I didn’t have these in use, so now my DHCP networks are these:

Which now I can experiment getting the second gateway working correctly by moving a static DHCP lease into the 3rd network (192.168.71.192/26), in this case from dynamic into static:

And after some waiting:

Turned into:

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: