Community discussions

 
rmkhurram
just joined
Topic Author
Posts: 5
Joined: Mon Feb 04, 2019 6:05 am

HELP! My Static IP gets changes to Dynamic everyday automatically.

Mon Feb 04, 2019 6:41 am

I need a script which can detect my MAC address then delete the Dynamic ip assigned to it and reassign it the Static IP from one of the IP Pools that i have created.


I am running following setup:
One DHCP server serving 300+ users
Up to 6 ip pools.
Firewall set to pass internet from 5 ip pools and blocks on 1 ip pool.
4 Queues each delivering different internet speed to different IP pools.

Now here is the problem, I assign static ip to my pc without limitations on speed from one of the ip pools that is not attached to any queues and it works fine, but someone deletes my ip from static ip pool and i get disconnected and reconnected to the dynamic ip pool assigned by dhcp server. I have checked the LOG and also changed the user name and password for mikrotik. I have no idea how it happens, I assigned static ips to other people as well and their ip never gets deleted which makes me sure that someone messing with my MAC and IP.


So I need an automated script which checked my MAC address every 10 minute or hour and makes sure that i have the static IP address from the pool that i have chosen, and If not then it deletes my IP from the Dynamic DHCP pool and assign Static ip to my Mac address.

Thankyou people I hope i made my question clear. Looking forward for response from you geniuses...
 
masterpianist
just joined
Posts: 10
Joined: Wed Sep 12, 2018 10:19 am

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Tue Feb 05, 2019 12:51 pm

That can be done on Leases on DHCP Server menu
You just have to click the device mac address, Make static and set the desired IP
 
int21
just joined
Posts: 17
Joined: Thu Apr 16, 2009 1:31 am

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Tue Feb 05, 2019 4:45 pm

:foreach ia in=[/ip arp find] do={
:global address [/ip arp get $ia address];
:global mac [/ip arp get $ia mac-address];
:foreach ix in=[/ip arp find] do={/ip arp make-static $ix};
:foreach iz in=[/ip dhcp-server lease find] do={/ip dhcp-server lease make-static $iz};
}
 
rmkhurram
just joined
Topic Author
Posts: 5
Joined: Mon Feb 04, 2019 6:05 am

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Wed Feb 06, 2019 6:10 am

That can be done on Leases on DHCP Server menu
You just have to click the device mac address, Make static and set the desired IP
Thankyou for reply, I do this all the time but after some time it does not stay that way and it gets deleted from Static Ip and i find it in automatic dhcp ip address.
 
rmkhurram
just joined
Topic Author
Posts: 5
Joined: Mon Feb 04, 2019 6:05 am

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Wed Feb 06, 2019 6:12 am

:foreach ia in=[/ip arp find] do={
:global address [/ip arp get $ia address];
:global mac [/ip arp get $ia mac-address];
:foreach ix in=[/ip arp find] do={/ip arp make-static $ix};
:foreach iz in=[/ip dhcp-server lease find] do={/ip dhcp-server lease make-static $iz};
}
Thankyou so much for response,I appreciate it, can you please explain it little bit what do i have to change in the above code to fit my scenario. I
 
User avatar
vecernik87
Member
Member
Posts: 454
Joined: Fri Nov 10, 2017 8:19 am

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Wed Feb 06, 2019 6:43 am

If someone is changing your dhcp-server config, why do you think he will not change delete/disable the script as well?
Trying to fix the consequence is usually doomed to fail. Fixing the cause is way more important.
 
rmkhurram
just joined
Topic Author
Posts: 5
Joined: Mon Feb 04, 2019 6:05 am

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Wed Feb 06, 2019 6:59 am

If someone is changing your dhcp-server config, why do you think he will not change delete/disable the script as well?
Trying to fix the consequence is usually doomed to fail. Fixing the cause is way more important.
Hi, Thankyou for reply, actually Mikrotik Login user was Admin before and i removed that default and created 2 user accounts, me and my assistant. I think that he might be that one guy who mess with my static Ip but when I check the Log there is no entry for his user name doing such thing and most of the log is filled with changes made by dhcp server name that we have. anyways i need the script before I investigate deeply. I am not programmer and most of the setup of Mikrotik, I watched youtube and forum posts by you people for help. If you can suggest me a way to prevent this I will appreciate if you can share with me. thankyou.
 
User avatar
Jotne
Forum Veteran
Forum Veteran
Posts: 865
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Wed Feb 06, 2019 9:52 am

I do 100% agree with vecernik87 do find the source of the problem. If its not you and not your assistent, then there may be someone else.
If that is the case, you may need to reinstall your router. Changing password may not be enough.

If you need a script that makes all DHCP leases static, then I have cleaned up the script above some.
:local date [/system clock get date]
:local time [/system clock get time]
:foreach lease in=[/ip dhcp-server lease find dynamic] do={
	/ip dhcp-server lease make-static $lease
	/ip dhcp-server lease comment comment="$date $time" $lease
	}
.
Use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
User avatar
user10jmk
just joined
Posts: 2
Joined: Fri Jan 12, 2018 4:04 pm

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Thu Feb 07, 2019 4:27 pm

I also have an issue close to that. I have 2 devices (hAP) connected through LAN. On the 2nd device all ether-ports are on a bridge. The first which runs the DHCP Server gives everyday a new dynamic IP to the 2nd device which has static IP (there's no DHCP Client enabled). The old leases still apear untill their lease time is done. Those leases regularly should not apear on the ARP table. What would be wrong on my config?
 
User avatar
k6ccc
Member
Member
Posts: 390
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Wed Feb 13, 2019 4:40 pm

Until you can find out who is messing with your router, you can also set the computer to a static IP, and then it never will look for a DHCP address at all.
But I agree with the others, you need to figure out who is changing your router configuration.
RB750Gr3, RB750r2, CRS326-24G-2S (in SwitchOS), CSS326-24G-2S, CSS106-5G-1S, RB260GS
Not sure if I beat them in submission, or they beat me into submission


Jim
 
rmkhurram
just joined
Topic Author
Posts: 5
Joined: Mon Feb 04, 2019 6:05 am

Re: HELP! My Static IP gets changes to Dynamic everyday automatically.

Thu Feb 14, 2019 5:27 am

Guys please help me with the script .. I will appreciate it tooo much..

Mikrotik should do this
1. When I will connect to Mikrotik, it detect my MAC address and assign it IP from predefined ip pool which i have for example "ROUTERS".
2. A Script which should Check every 10 minute for my Mac that if it has ip from the ROUTERS pool, If Not, then it should delete my ip from other pools or dynamic pool and assign it to ROUTERS pool, otherwise do nothing.

Please guys I could not figure out what is causing this, but i need your help on script.
following is Configuration
DHCP server name= Scarsdale
Network = 172.169.0.0/16
subnet=255.255.0.0

ROUTERS pool ip addresses= 172.169.10.0/24
Dynamic pool ip address=172.169.3.0/24

Thankyou all for replying me .. I really really appreciate your help people. :)

Who is online

Users browsing this forum: No registered users and 3 guests