Community discussions

MikroTik App
 
ignoranceisbliss
just joined
Topic Author
Posts: 15
Joined: Sun Feb 19, 2023 12:24 am

how to use EDIT command in terminal?

Mon Feb 20, 2023 5:31 am

Searched far and wide. mikrotik documentation is lacking.

For example in terminal I want to edit the IP pool ranges.
/ip pool
edit
terminal number: 0
value-name: ranges

The terminal gets a cursor under but nothing can be done with it, i.e., it takes no input from keyboard. The only thing is to escape to root without completing the task of changing the IP pool ranges.

Question:

how do I use edit in this case?
 
holvoetn
Forum Guru
Forum Guru
Posts: 5478
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: how to use EDIT command in terminal?

Mon Feb 20, 2023 10:08 am

Winbox might be easier for you ?

Help on terminal:
F1 = help on current command
TAB = (usually) will display available options at that point.
It's in the documentation :lol:
https://help.mikrotik.com/docs/display/ ... Management

In this specific case you would have to use
/ip pool edit 0 ranges
then edit screen will appear
and ctrl-o to save&quit as displayed on screen.

Personally I would use print , remove and then add.
Ex. changing pool on ETH5:
[xyz@hAPAX3-1] /ip/pool> print
Columns: NAME, RANGES
# NAME RANGES
0 VLAN2 192.168.2.100-192.168.2.254
1 VLAN99 192.168.99.10-192.168.99.19
2 VLAN20 192.168.20.100-192.168.20.199
3 VLAN10 192.168.10.100-192.168.10.199
4 ETH5 10.20.20.2/31
5 VLAN30 192.168.30.100-192.168.30.199

/ip pool remove 4
or
/ip pool remove ETH5

/ip pool add name=ETH5 ranges=10.20.20.4/31

Winbox is a lot easier for such things, though ...
 
ignoranceisbliss
just joined
Topic Author
Posts: 15
Joined: Sun Feb 19, 2023 12:24 am

Re: how to use EDIT command in terminal?

Mon Feb 20, 2023 8:18 pm

Yes, thanks I did all that. You guys and the community are what makes buying mikrotik!

This was only an example (of course, fixed with Winbox) but other edits do not work either this is why I wanted to clarify.

I did

/ip pool edit 0 ranges

but it took me to a cursor where nothing could be entered.

Even tried
/ip pool edit 0 ranges=192.168.3.100-192.168.3.150
but this exited with an error.

I was afraid deleting the pool for DHCP would lock me out of the router.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5478
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: how to use EDIT command in terminal?

Mon Feb 20, 2023 8:27 pm

The ethernet itf on your computer does need a working ip config, strange but true, but winbox itself can work on MAC level without a functioning ip config on router.
Provided there is no firewall blocking you. For that reason most foresee one physical port not tied to the bridge as entry.

You might be better off using winbox in these early phases of your learning process.
And there is always the option of Safe Mode. Very helpful when you goof things up.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11590
Joined: Thu Mar 03, 2016 10:23 pm

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 8:50 am

I'm not really sure what "edit" command does, I never used it. In ROS 6.49.7 (and ROS 7.7) it doesn't even have short description shown:
[user@mikrotik] /ip pool> edit

.. -- go up to ip
add -- Create a new item
comment -- Set comment for items
edit -- 
export -- Print or save an export script that can be used to restore configuration
find -- Find items by value
get -- Gets value of item\'s property
print -- Print values of item properties
remove -- Remove item
set -- Change item properties
used -- Used pools

However, using set command does the trick for me:
/ip pool set 0 ranges=192.168.3.100-192.168.3.150

Note that using index numbers ("0" in example above) only works after using print command ... indices are not constant properties, they are created by print command and can be used until next print command is executed (even in a different configuration tree branch). So if one wants to execute command above without first executing print command, the correct command would be like this:
/ip pool set [ find where name=pool0 ] ranges=192.168.3.100-192.168.3.150
Adapt the where part of find to match setting that needs to be updated ... and make sure it doesn't match any other setting which has to remain unchanged. It is fine to create "find ..." construct so that it matches multiple settings ... if all of settings need to be changed in exactly the same way.
 
ignoranceisbliss
just joined
Topic Author
Posts: 15
Joined: Sun Feb 19, 2023 12:24 am

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 9:23 am

Perfect. Basically, instead of editing a property the same property is (re)set/rewritten.

I should have tried that in the first place but I am stubborn. It might be that edit is superseded by set altogether. Wondering why not remove it completely from ROS.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11590
Joined: Thu Mar 03, 2016 10:23 pm

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 12:07 pm

Could be that edit is supposed to work like set, but without first (manually) checking old contents ... and interactively so. I most likely won't even try to find out about it :wink:

Don't forget about "unset" command ... sometimes setting of certain property is undone by setting it to empty value ... but sometimes empty value is not the same as not being set at all. So if a property is set and one wants to completely remove it from configuration, the "unset" command is the one.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5478
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 12:12 pm

Winbox is so much easier for these things ...
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 12:27 pm

Don't forget about "unset" command ... sometimes setting of certain property is undone by setting it to empty value ... but sometimes empty value is not the same as not being set at all. So if a property is set and one wants to completely remove it from configuration, the "unset" command is the one.
Unset? from 2007 i never used that command or remember that exist...

Usually I use !field to "unset" the field on set with other things.
Like
/ip route> unset 1 routing-mark
# is the same as
/ip route> set 1 !routing-mark

# but on set lines I can do more operations at once, if is needed:
/ip route> set 1 !routing-mark gateway=6.9.8.7

"unset" do not cover all fields or all menu covered by set.
"set" do it.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11590
Joined: Thu Mar 03, 2016 10:23 pm

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 6:16 pm

Unset? from 2007 i never used that command or remember that exist...

Well, I've never thought of using set !<property>. It seems non-intuitive to me, to me "set not something" is different than "unset something". The same way as "set something to empty" is different than "unset something".

Anyway, I'm glad you have your own ways which work for you :wink:

"unset" do not cover all fields or all menu covered by set.
Can you give an example where "unset <property>" doesn't work while "set !<property>" does? This really intrigues me.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 6:18 pm

Anyway, I'm glad you have your own ways which work for you :wink:
It's just more comfortable like in the third example to do more things together...
¯\_(ツ)_/¯
Every day I discover or invent something new on the forum, we never stop learning ;)
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 6:21 pm

Can you give an example where "unset <property>" doesn't work while "set !<property>" does? This really intrigues me.
Let me explain better, it's not that "it doesn't", but in some menus it just isn't there...
Just one example:
/ip address set ([find]->0) unset comment
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11590
Joined: Thu Mar 03, 2016 10:23 pm

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 6:33 pm

Well, the example above is one of those where setting to empty value does the trick, hence no unset command. And setting !comment doesn't do the trick either. I'd really like to see the example where setting property to empty value isn't the same as unsetting it ... and that it is not possible to unset it while set !<property> works.

Other than that ... where unset works, it's not "set <index> unset <property>" ... it's "unset <index> <property>".
Last edited by mkx on Tue Feb 21, 2023 6:36 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 6:35 pm

the menus lack uniformity...
like as-value for some commands, added just for some on v7...
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11590
Joined: Thu Mar 03, 2016 10:23 pm

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 6:41 pm

It seems that unset is only available in menus where items have optional parameters. In IP address, only optional parameter is comment. Any other missing and configuration item doesn't make any sense. Other configuration items (like firewall filter) have many properties and not all have to be present. Further more, empty value of some properties make perfect sense (as matcher) and treating property with empty calue same as not set property would be wrong. In those configuration parts "unset" exists and makes sense. And I guess (not sure I want to try) in those also "set !<property>" works.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 6:44 pm

It probably is. I've never found a value where !field didn't work, on purpose I didn't notice "unset".
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11590
Joined: Thu Mar 03, 2016 10:23 pm

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 6:49 pm

Well, I tried in /ip firewall filter ... one can not remove comment (i.e. field where empty value is as good as not set) with either of constructs, only setting with empty value does. But for optional property (I tried with in-interface) both ways (unset X in-interface ... and ... set X !in-interface) worked the same.

So I guess we'll continue to use the way we're already accustomed to.

BTW, where did you learn "your" way? I never noticed it in any of official documents and/or examples. unset is documented (at least in tge self-documenting way in CLI).
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: how to use EDIT command in terminal?

Tue Feb 21, 2023 6:58 pm

not knowing unset.. I try to logically set not-set with !set :lol: :lol: :lol:

try:
/ip route export verbose
;)

terminal code

/ip route
add !bgp-as-path !bgp-atomic-aggregate !bgp-communities !bgp-local-pref \
    !bgp-med !bgp-origin !bgp-prepend !check-gateway disabled=no distance=1 \
    dst-address=0.0.0.0/0 gateway=ex.am.pl.e !route-tag !routing-mark scope=\
    30 target-scope=10

Who is online

Users browsing this forum: Kanzler, MarkusT and 49 guests