{ :if ([:len [/interface find name="Wan" disabled=no]] != 0) do={ :local wanIP "Wan interface has no IP address" :if ([:len [/ip address find actual-interface="Wan" disabled=no]] != 0) do={ :set wanIP [/ip address get [:pick [/ip address find interface="Wan"] 0] address] } :put $wanIP } else={ :put "No interface by that name" } }First I check if there is an interface named "Wan", if there is check if it has an IP address, if it does get it.
:put [/ip address get [:pick [/ip address find interface="Wan"] 0] address]Test it in the terminal.
So it has nothing to do with making a script on the router?I have to try some PHP that connects to the router via IP address and in local with subnet IP address (192.168.5.1) it works ... But from a server?
Vodafone Station | RB750 (192.168.5.1) _____|_____ | | PHP page on localhost on my PC
$client = new RouterOS\Client('192.168.5.1', 'admin', 'password');and it works...
Vodafone Station | RB750 (192.168.5.1) _____|_____ | | my PC GUEST ___ | | |___PHP page on a server on the internet
$client = new RouterOS\Client('?????', 'admin', 'password');Which IP address must I to use?
# Snippet from Deantwo's RouterStatus script 2014-10-07 { # Get the Wan interface's IP. :local wanIP :if ([:len [/interface find name="Wan" disabled=no]] != 0) do={ :set wanIP "Wan%20interface%20has%20no%20IP%20address" :if ([:len [/ip address find actual-interface="Wan" disabled=no]] != 0) do={ :set wanIP [/ip address get [:pick [/ip address find interface="Wan"] 0] address] } } else={ :set wanIP "No%20interface%20by%20that%20name" } :local urlParameters ("\?wan-ip=" . $wanIP) # Define name of the file once it is downloaded. Not all that important. :local filename "tempfile.html" # Delete the file if it exists already. :if ([:len [/file find name=$filename]] != 0) do={ /file remove $filename } # Define the full URL for the PHP script and concatenate the parameter ($urlParameters) string to it. :local urlFull ("http://www.mikrotik.com/" . "ReportIP.php" . $urlParameters) # Show the full url for testing. :put $urlFull # HTTP GET request is done here towards the webserver. /tool fetch mode=http url=$urlFull dst-path=$filename :delay 5 # Delete the file when done. If run in the terminal, show the content of the file before deleting it. :if ([:len [/file find name=$filename]] != 0) do={ :put [/file get [/file find name=$filename] contents] /file remove $filename } }Then you can make a PHP script that saves that IP address in some way and use it in your other script.
http://www.mikrotik.com/ReportIP.php?wan-ip=10.0.0.1/24
/ip address printUnless your router is behind another router that is.
http://lmgtfy.com/?q=what+is+my+ipBut my router is behind another router ...
how ?Just be sure you have port-forwarded the correct ports on your gateway router.
Depends a lot on the router.how ?Just be sure you have port-forwarded the correct ports on your gateway router.
Only if your gateway router is also a Mikrotik router.
Not sure what you mean by "compile it".how to compile it ??
/ip address printto find out the WAN IP of your MikroTik router. We already know 192.168.5.1 is your LAN one, but your WAN is probably another IP in the 192.168.1.0/24 subnet (i.e. 192.168.1.2 or 192.168.3 or 192.168.1.7 or something else entirely).
It means you didn't enter a port number in one of the required fields.I had already tried, but I get the error: "Enter a port or range of ports valid"
And I think the IP address you need to enter is "192.168.1.2".Code: Select all> /ip address print Flags: X - disabled, I - invalid, D - dynamic # ADDRESS NETWORK INTERFACE 0 X 192.168.23.1/24 192.168.23.0 bridge2 1 ;;; hotspot network 172.16.0.1/24 172.16.0.0 ether5-GUEST 2 192.168.5.1/24 192.168.5.0 ether2-TX 3 D 192.168.1.2/24 192.168.1.0 ether4_OUTSIDE >
but This http://wiki.mikrotik.com/wiki/Manual:IP/Cloud Applies to RouterOS: v6.14+use ip cloud, in the advanced section set that the local address should be used.
your PHP code will happily take FQDN.
I have tried both without success"Porta esterna" has two boxes, try adding the port number to both of them.
And I think the IP address you need to enter is "192.168.1.2".
That wouldn't help if the outside router doesn't forward the port.use ip cloud, in the advanced section set that the local address should be used.
your PHP code will happily take FQDN.
Forgive me for not trusting you, but... A screenshot of right before you press OK, and another one with what the router shows right after please?I have tried both without success"Porta esterna" has two boxes, try adding the port number to both of them.
And I think the IP address you need to enter is "192.168.1.2".
ok now from ether5-GUEST I open logs.php but I get "Unable to connect to RouterOS."Specify 192.168.1.2 as the IP, not 192.168.5.1.
This saved my day as well. Thank youBasic way of getting the an interface's IP address is just to use this:ros code
:put [/ip address get [:pick [/ip address find interface="Wan"] 0] address][/code] Replace "Wan" with whatever the interface's name is.