Yes, it is possible to change the rule settings on and off for a device using the CLI command. If you have already created a specific rule or are using the default rule, you can modify its behavior by adjusting certain parameters. Here’s an example of how you can achieve this:
1. Check Firewall Rule: First, you need to identify the specific firewall rule that you want to enable or disable. To do this, open the terminal or SSH into your system and list the current firewall rules using a command such as:
This command will display the existing rules, including their statuses (enabled or disabled).
Option enabled ‘0’ means disabled, if you want to enable it we need to change this to ‘1’ and vice versa.
2. Edit the Rule using vi: Once you’ve identified the rule you want to modify, you can use the vi text editor to make the necessary changes. For example, if you want to enable or disable a rule by editing the /etc/config/firewall file, use the following command:
The vi editor will open the file for editing
3. Change the Parameter: In the vi editor, navigate to the specific line corresponding to the rule you want to modify. Look for the parameter that controls whether the rule is enabled or disabled. It is usually represented by “1” for enabled and “0” for disabled. Modify the parameter according to your needs: set it to “1” to enable the rule or “0” to disable the rule.
4. Save and Exit: After making the necessary changes, save the file and exit the vi editor. Press Esc key to ensure you are in command mode, then type :wq and press Enter. This will write the changes to the file and quit the editor.
5. Restart Firewall: To apply the changes, you need to restart the firewall service, you can typically restart the firewall with the following command:
By following these steps, you can effectively enable or disable a specific firewall rule and apply the changes by restarting the firewall service. Additionally, exercise caution while modifying firewall rules as incorrect configurations can potentially compromise the security of your system.
Thanks and regards.