Few questions about DHCP,DNS,NTP,routing

  1. DHCP
    I need discover this options to users:
  • ntp server (192.168.2.1 - NTP server on router)
  • static route (route add 100.0.0.0 MASK 255.255.255.0 192.168.2.51 -p)

I create “option” 42 with ntp address server - 192.168.2.1, set check opposite “NTP Server” label in /ip dhcp-server network and select option (42) from list, but Windows doesn’t user this, may be becouse my computer inside domain. But how to confiure windows to use only NTP for time sync?

For routing I try options 121,249:
100.0.0.0/24 192.168.2.51
dec: 24,100,0,0,0,192,168,2,51,0,192,168,2,1
hex: 0x1864000000c0a8023300c0a80201

but when windows try get ip address by DHCP it’s get error, so routing just ruined my network connection.

  1. DNS
    Inside network we have WINS server on SAMBA for resolving computer names. But I want use normal DNS with autoregistered computers on DNS server, thus if I change computer IP - all users can connect to my machine by new address or this not possible by security reson& Hot to do?

Ok, finally I win with static routes:

(DO NOT ADD THIS ROUTE TO YOUR WORKING NETWORK, OTHERWISE ALL OUTGOING LOCAL NETWORK TRAFFIC HAS BEEN TRANSFER THROUGH ROUTER (NOT PEER TO PEER))
192.168.2.0 - my network
255.255.255.0 - my mask (192.168.2.0/24)
192.168.2.1 - my router

(THIS ROUTE YOU CAN ADD)
100.0.0.0 - subnet 2
255.255.255.0 - subnet 2 mask
192.168.2.51 - router 2 (100.0.0.0/24)

So, by RFC3442:
------------- First entry ---------------

  1. Mask: 24 (HEX:0x18)
  2. 1 octet of network IP address: 192 (HEX:0xC0)
  3. 2 octet of network IP address: 168 (HEX:0xA8)
  4. 3 octet of network IP address: 2 (4 octet of network IP address is OMIT) (HEX:0x02)
  5. 1 octet of router IP address: 192 (HEX:0xC0)
  6. 2 octet of router IP address: 168 (HEX:0xA8)
  7. 3 octet of router IP address: 2 (HEX:0x02)
  8. 4 octet of router IP address: 1 (HEX:0x01)
    ------------- Second entry ------------
  9. Mask: 24 (HEX:18)
  10. 1 octet of network IP address: 100 (HEX:0x64)
  11. 2 octet of network IP address: 0 (HEX:0x0)
  12. 3 octet of network IP address: 0 (4 octet of network IP address is OMIT) (HEX:0x0)
  13. 1 octet of router IP address: 192 (HEX:0xC0)
  14. 2 octet of router IP address: 168 (HEX:0xA8)
  15. 3 octet of router IP address: 2 (HEX:0x02)
  16. 4 octet of router IP address: 51 (HEX:0x33)
    ------------- n entry (simple concatenated HEX) ------------

Now just concatenate all HEX into one string for add to mikrotik:

/ip dhcp-server option
add code=249 name=static-alt-249 value=0x18c0a802c0a8020118640000c0a80233
add code=121 name=static-alt-121 value=0x18c0a802c0a8020118640000c0a80233

# And add this names options to our network configuration
/ip dhcp-server network
add address=192.168.2.0/24 comment=\
    "default configuration" dhcp-option=static-alt-121,static-alt-249 \
    dns-server=192.168.2.1 gateway=192.168.2.1 netmask=24 next-server=\
    192.168.2.1 ntp-server=192.168.2.1 wins-server=192.168.2.51

On windows (I have Windows 7) machine with enabled DHCP:

ipconfig /renew
route print
IPv4 таблица маршрута
===========================================================================
Активные маршруты:
Сетевой адрес Маска сети Адрес шлюза Интерфейс Метрика
0.0.0.0 0.0.0.0 192.168.2.1 192.168.2.248 20
100.0.0.0 > > 255.255.255.0 > 192.168.2.51 > 192.168.2.248 21
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306
192.168.2.0 > 255.255.255.0 > 192.168.2.1 > 192.168.2.248 21
192.168.2.248 255.255.255.255 On-link 192.168.2.248 276
224.0.0.0 240.0.0.0 On-link 127.0.0.1 306
224.0.0.0 240.0.0.0 On-link 192.168.2.248 276
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 192.168.2.248 276
===========================================================================

Wireshark captured:
staticroutes.jpg
Mikrotik script for fast generated HEX string: link

But you need add all routes to /ip route and it routes can be disabled, not matter. For get result

#
# Script converting network and gateway from routing table to hexadecimal string
# dst-address=192.168.2.0/24 gateway=192.168.1.1 => result=0x18c0a80200c0a80101
#
# (c) Daniel Starnowski 2011
#
:foreach route in=[/ip route find] do={
:local dst [/ip route get $route dst-address];
:local gateway [/ip route get $route gateway];
:if ($gateway=[:toip $gateway]) do={
  :local total ($dst . "." . $gateway);
  :local result "0x";
  :local hextable [:toarray "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f"];
  :local total2 "";
  :local decimal;
  :local division;
  :local i;
  :local j;
  :for i from=1 to=[:len $total] step=1 do={
   :set j [:pick $total ($i-1) $i];
   :if (($j=".") or ($j="/")) do={:set j ","};
   :set total2 ($total2 . $j);
   };
  :set total2 [:toarray $total2];

  :for i from=0 to=8 step=1 do={
   :set j $i;
   :if ($j<5) do={if ($j=0) do={:set j 4;} else={:set j ($j-1);};};
   :set decimal [:pick $total2 $j ($j+1)]
   :set division ($decimal / 16);
   :set result ($result . [:pick $hextable $division]);
   :set result ($result . [:pick $hextable ($decimal - (16 * $division))]);
   };
  :put $result;
} else={:put ("Gateway is not a single IP address for ".$dst);}
}



[admin@gw1] /system script> run RouteToHex 
0x000000000055ec1405
Gateway is not a single IP address for 85.236.20.4/30
0x1864000000c0a80233
Gateway is not a single IP address for 192.168.2.0/24

WARNING: Samsung mobile phone with Android can’t enter to Internet if get option 121 by DHCP.