Community discussions

MikroTik App
 
nevolex
Member Candidate
Member Candidate
Topic Author
Posts: 167
Joined: Mon Apr 20, 2020 1:09 pm

DHCP override

Mon May 25, 2020 7:34 am

Hi everyone,

is it possible to override a dchp gateway for 1 client.

Let's say a getaway for my network is 192.168.1.1, can I change it for 1 client only for 192.168.1.2 (I have another gateway with such ip on the network )?

Thank you all :)

Alex
Last edited by nevolex on Mon May 25, 2020 9:38 am, edited 1 time in total.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: DHCP override

Mon May 25, 2020 8:44 am

It seems that you can mark the packet for one IP and then set a unique route for that marking.
viewtopic.php?t=65544
Dont ask me how, since I have not tested it and mangle is not my field :)

Edit:
This may help:
https://wiki.mikrotik.com/wiki/Policy_Base_Routing
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: DHCP override

Mon May 25, 2020 12:51 pm

You mean the gateway which the DHCP server instructs the client to use, correct?

You can, if you make the lease for that client static (to convert a dynamically assigned one to a static one is the simplest way to do that), and for the address you lease to that client, you create a separate row under /ip dhcp-server network, with individual value of gateway. So the address parameter of that row will be the leased address alone (i.e. with a /32 mask), but you must specify the optional netmask value on that row, to tell the client what netmask to use.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: DHCP override

Mon May 25, 2020 1:03 pm

Or if you can get my previous post to work with packed marking, you could use source mac address.
Then it does not matter what IP the client gets. The client then get routed based on its mac address.
Last edited by Jotne on Mon May 25, 2020 1:34 pm, edited 1 time in total.
 
nevolex
Member Candidate
Member Candidate
Topic Author
Posts: 167
Joined: Mon Apr 20, 2020 1:09 pm

Re: DHCP override

Mon May 25, 2020 1:11 pm

Thanks Jotne and Sindy!
 
nevolex
Member Candidate
Member Candidate
Topic Author
Posts: 167
Joined: Mon Apr 20, 2020 1:09 pm

Re: DHCP override

Mon May 25, 2020 1:46 pm

sorry just to confirm as I am very new to Mikrotik. Would that work:

/ip dhcp-server server my_dhcp network 10.0.0.18/32 gateway 10.0.0.2

Where the specific client is 10.0.0.18, second gateway 10.0.0.2

Thank you
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: DHCP override

Mon May 25, 2020 2:33 pm

Not enough, you must add netmask=xx, where xx matches the netmask of the subnet from which you assign the address, otherwise the client would get a /32 mask and would not be able to connect anywhere, as even the gateway would be outside its own subnet.
 
nevolex
Member Candidate
Member Candidate
Topic Author
Posts: 167
Joined: Mon Apr 20, 2020 1:09 pm

Re: DHCP override

Mon May 25, 2020 2:45 pm

Ah, right, something like this?

/ip dhcp-server network server=my_dhcp address=10.0.0.18/32 netmask=24 gateway=10.0.0.2
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: DHCP override  [SOLVED]

Mon May 25, 2020 3:04 pm

/ip dhcp-server network server=my_dhcp address=10.0.0.18/32 netmask=24 gateway=10.0.0.2

There is no explicit link to the server.

And if you don't specify the DNS server, the common one will not be assigned to the client - or, better to say, those specified for Mikrotik itself in /ip dns settings will be assigned to the client.

Who is online

Users browsing this forum: MauriceW, MircoADM and 107 guests