Community discussions

 
DukeNukem3D
just joined
Topic Author
Posts: 4
Joined: Sun Mar 11, 2012 6:52 am

Change ip address of specific interface

Sun Mar 11, 2012 7:03 am

I have ether10 ip address 10.0.0.2/24.
Periodically I want to change it to 10.0.0.1/24
I read manual and saw that this is possible only using command:
/ip address set address=10.0.0.1/24 interface=ether10 numbers=
The problem is in numbers. I have to do
/ip address print
to get right item number. If item number will be changed, my script will change another interface ip address and I even can loose router's control.

I'm writng script and I need to change ip address o f specific interface, the question is:
is it possible to do something like
/ip address ?change? interface=... address=...
or is there some walkaround known, not to use item number.
 
airock
newbie
Posts: 29
Joined: Fri Oct 09, 2009 11:57 pm

Re: Change ip address of specific interface

Sun Mar 11, 2012 9:52 am

You need a "number" in order to identify the address to change because, generally, an interface might have more than one address. So the interface name is not a "key" to an unique address.

If you are sure that your interface is assigned a single address you can use the following command:
/ip address set [/ip address find interface=ether10] address=10.0.0.1/24
anyway, with exactly the same semantics, a more proper solution would be:
/ip address set [/ip address find address="10.0.0.2/24"] address=10.0.0.1/24

From the latter you can clearly see what I said: you are working with addresses, not interfaces.


Regards,
rock
"Entia non sunt multiplicanda praeter necessitatem."

If you find anything useful in this this post, please give a positive Karma. (more info about Karma)
 
DukeNukem3D
just joined
Topic Author
Posts: 4
Joined: Sun Mar 11, 2012 6:52 am

Re: Change ip address of specific interface

Sun Mar 11, 2012 12:08 pm

/ip address set [/ip address find interface=ether10] address=10.0.0.1/24
anyway, with exactly the same semantics, a more proper solution would be:
/ip address set [/ip address find address="10.0.0.2/24"] address=10.0.0.1/24
From the latter you can clearly see what I said: you are working with addresses, not interfaces.
Thanks, that's exactly what I need!
 
bastys
just joined
Posts: 10
Joined: Sun Oct 21, 2018 2:25 pm

Re: Change ip address of specific interface

Sun Oct 21, 2018 2:31 pm

You can write the command as follows:
ip address set [/ip address find address="192.168.140.*"] address=192.168.141.*
I only want to change the C subnet of the ipaddress.

THX
 
User avatar
kevigizmo
newbie
Posts: 47
Joined: Mon Dec 19, 2011 3:35 pm
Location: Norfolk, UK
Contact:

Re: Change ip address of specific interface

Mon Oct 29, 2018 12:08 pm

You can write the command as follows:
ip address set [/ip address find address="192.168.140.*"] address=192.168.141.*
I only want to change the C subnet of the ipaddress.

THX
I'm also looking for a similar command to the above where for example I have a number of sites which all have the site number set within the IP address,
so scripting wise for the "average person" to literally go in and edit 3 :global variables can change the single octet on the IP address

e.g - Change X to site number
:global SiteNumber=x

site 6 gets 10.1.6.254/24 for example,
and I need a command that does something like - add address=10.1.$SiteNumber.254/24 interface=loopback network=10.1.$SiteNumber.0

A friend had suggested something like
so address-begining = "10.10."; address-end = ".254/24"; full_address = $address-beginning . $6bit . $address-end;
But not sure whether this would work?

Any suggestions ?

Thanks
Wireless & Network Consultant

¦ MTCNA MTCRE MTCINE MTCTCE ¦ UCT UBWS UBWA UEWA ¦
¦ SimRush Accredited Installer ¦ SimRush 4G | Redefining Superfast ¦

- DISCLAIMER -
All posts are advice, Otherwise Seek advice from manufacturer

Who is online

Users browsing this forum: No registered users and 11 guests