Saturday, December 28, 2019

Set Blank or Empty Value to Rule's Property in Mikrotik by CLI

To set blank or empty value to a property in a rule in mikrotik by CLI ( Command Line Interface ) is easy. For example, a rule has been made in ip firewall mangle, then you need to set blank or empty value in property of that rule using CLI. Here's how it's done :

1. First, you need to know the number of that rule. To do so, type print or pr in new terminal :
/ip firewall mangle> pr
Flags: X - disabled, I - invalid, D - dynamic
 0    chain=prerouting action=accept src-address=192.168.1.0/24 log=no log-prefix=""
0 is the number of  the rule.

2. In this example we're gonna set empty or blank value in src-address. To do that, type this command below :
unset 0 src-address

Check if it works or not by using print command again :
/ip firewall mangle> pr
Flags: X - disabled, I - invalid, D - dynamic
 0    chain=prerouting action=accept log=no log-prefix=""

3. To set blank or empty value to many rules at one time, you can use script or command like this below. But remember, you must do print command first before you can use this script and this command.

- Script
:for x from 0 to 6 do={/ip fi ma unset $x src-address}

This script will unset src-address from rule 0 'till rule 6.

- Command
unset 0,1,5,6 src-address


This command will only set blank or empty value to rule 0,1,5 and 6.

No comments:

Post a Comment