Community discussions

MikroTik App
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

local address get network

Fri Jul 02, 2021 1:24 pm

is there a possibility to get the network in /ip address
heres my script but i cant get the network. i can only get the address and put it on the routes

:local ipx [/ip address get [find where interface=GL] network]
:local ip [:pick $ipx -1 [:find $ipx "/" -1]]
/ip route
:local idwatch [find where comment=WAN3]
:if ($ip != $idwatch) do={
/ip route set [find comment="WAN3"] gateway=$ip;
}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address get network

Fri Jul 02, 2021 1:58 pm

Ask this to the author of the script...
viewtopic.php?f=9&t=176417&p=864755&hil ... px#p864755

If the IP is coming from pppoe-client the IP is /32 (255.255.255.255)

what do you mean for "network"?

on this script network go on network var....
:local ipx [/ip address get [find where interface=GL] address]
:local ip [:pick $ipx -1 [:find $ipx "/" -1]]
:local network [/ip address get [find where interface=GL] network]
Last edited by rextended on Fri Jul 02, 2021 2:10 pm, edited 1 time in total.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: local address get network

Fri Jul 02, 2021 2:09 pm

yes sir its coming from the pppoe-client

:local ipx [/ip address get [find where interface=GL] network]

i cant get the network in /ip address and put it in routes
if i change like this

:local ipx [/ip address get [find where interface=GL] address]

i successfully get it and go to routes gatewat
Last edited by runbound on Fri Jul 02, 2021 2:11 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address get network

Fri Jul 02, 2021 2:11 pm

if you paste this on terminal do not write nothing?
:put [/ip address get [find where interface=GL] network]
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: local address get network

Fri Jul 02, 2021 2:14 pm

if you paste this on terminal do not write nothing?
:put [/ip address get [find where interface=GL] network]
i get the network sir :-)

but how can i send it to routes
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address get network

Fri Jul 02, 2021 2:15 pm

(do not quote uselessy)

where you need to put the network on route?
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: local address get network

Fri Jul 02, 2021 2:16 pm

sorry sir

in route gateway sir
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address get network

Fri Jul 02, 2021 2:20 pm

Let me explain better,
on "gateway" must be put: or interface or IP address,
can't be put a "network" as gateway for a destination in a route,
I do not know if I'm explaining well
Last edited by rextended on Fri Jul 02, 2021 2:29 pm, edited 1 time in total.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: local address get network

Fri Jul 02, 2021 2:29 pm

from ip address network to routes gateway sir

sorry for my bad english
You do not have the required permissions to view the files attached to this post.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address get network

Fri Jul 02, 2021 2:31 pm

must be set gayeway=GL
the name of the interface
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address get network

Fri Jul 02, 2021 2:39 pm

about the script:

/ip route
:local idwatch [find where comment=WAN3]
# now idwatch contain only the id of the route entry where comment is WAN3, if exist
:if ($ip != $idwatch) do={
# now you compare one ip address with one internal id, always is false, but with ! always is true
/ip route set [find comment="WAN3"] gateway=$ip;
# now you update the gateway with "network" instead of use "interface" name
}

The correction for this script, without checking the logic what it is for:
/ip route
:local idwatch [get [find where comment=WAN3] gateway]
:if ($idwatch != "GL") do={
    /ip route set [find where comment="WAN3"] gateway="GL";
}


or better to do nothing, no matter what IP the pppoe-client GL have, everytime the interface name still the same.....
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: local address get network

Fri Jul 02, 2021 2:51 pm

thanks sir
but what is the full script sir


the script is not working sir

:local ipx [/ip address get [find where interface=GL] network]
:local ip [:pick $ipx -1 [:find $ipx "/" -1]]

/ip route
:local idwatch [get [find where comment=WAN3] gateway]
:if ($idwatch != "GL") do={
/ip route set [find where comment="WAN3"] gateway="GL";
}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address get network

Fri Jul 02, 2021 3:16 pm

Is not better to leave the route simply with GL on gateway?

GL interface never change
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: local address get network

Fri Jul 02, 2021 3:28 pm

ok sir. thanks sir it helps me a lot.

Who is online

Users browsing this forum: No registered users and 23 guests