Community discussions

MikroTik App
 
kei888
newbie
Topic Author
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Logging of Dynamically obtain IP Address from ISP

Wed Mar 05, 2014 2:56 pm

Hi folks!

Is Mikrotik RouterOS capable to log Public/ Private IP Addresses obtain dynamically from ISP?

If yes, how?

Thank you so much.
 
efaden
Forum Guru
Forum Guru
Posts: 1711
Joined: Sat Mar 30, 2013 1:55 am
Location: New York, USA

Re: Logging of Dynamically obtain IP Address from ISP

Wed Mar 05, 2014 11:22 pm

What do you mean?

Sent from my SCH-I545 using Tapatalk
 
kei888
newbie
Topic Author
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: Logging of Dynamically obtain IP Address from ISP

Fri Mar 07, 2014 4:15 pm

What I mean is, I want my RB951G-2HnD to log each dynamic Public IP Address that my router is getting from my ISP.

Is it possible?

Thank you.
 
efaden
Forum Guru
Forum Guru
Posts: 1711
Joined: Sat Mar 30, 2013 1:55 am
Location: New York, USA

Re: Logging of Dynamically obtain IP Address from ISP

Fri Mar 07, 2014 6:47 pm

Yeah. You could script that. Similar to the dynamic dns scripts people use.

Sent from my SCH-I545 using Tapatalk
 
kei888
newbie
Topic Author
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: Logging of Dynamically obtain IP Address from ISP

Sat Mar 08, 2014 4:07 am

Nice.

Can you guide me on how I can learn to construct that script? or much better if you can show me a sample script?

Thank you so much, Sir.
 
efaden
Forum Guru
Forum Guru
Posts: 1711
Joined: Sat Mar 30, 2013 1:55 am
Location: New York, USA

Re: Logging of Dynamically obtain IP Address from ISP

Sat Mar 08, 2014 3:05 pm

I'd basically have to write the script. I'll do it later today or tomorrow if I get a chance.

-Eric

Sent from my SCH-I545 using Tapatalk
 
efaden
Forum Guru
Forum Guru
Posts: 1711
Joined: Sat Mar 30, 2013 1:55 am
Location: New York, USA

Re: Logging of Dynamically obtain IP Address from ISP

Sun Mar 09, 2014 8:07 pm

Basically this...

ros code

#
# Variables
#

:local currentLocalSiteInterface "ether01-gateway"
:local currentLocalSite
:local forceUpdate false

#
# Script
#
:global localSite

:if ($currentLocalSiteInterface != "" && $currentLocalSite = "") do={
#	:set currentLocalSite [/ip address get [/ip address find interface=$currentLocalSiteInterface] address]
	:set currentLocalSite [/ip dhcp-client get [/ip dhcp-client find interface=$currentLocalSiteInterface] address]
	:set currentLocalSite [:pick $currentLocalSite 0 [:find $currentLocalSite "/" -1]]
}

:if ([:typeof $localSite] = "nothing") do={
	:set localSite ""
}

:if ($currentLocalSite != $localSite) do={
	:set forceUpdate true
	:set localSite $currentLocalSite
}

:if ($forceUpdate) do={
# DO WHATEVER YOU WANT HERE ... 
}

Who is online

Users browsing this forum: censored224, Sob and 99 guests