Firewall-cmd cheat sheet

As I find myself infrequently changing firewall rules I often have to look up the syntax again and these tips cover 90% of what I want to do.

Get zone details; here is a quick reminder on how to find the default zone, find the active zone and finally list all the current rules.

firewall-cmd --get-default-zone
firewall-cmd --get-active-zone
firewall-cmd --list-all

Adding rules for https traffic

firewall-cmd --get-default-zone
firewall-cmd --zone=public --permanent --add-service=https
firewall-cmd --reload
firewall-cmd --zone=public --list-all

Adding rules for port 53 tcp

firewall-cmd --get-default-zone
firewall-cmd --zone=public --permanent --add-port=53/tcp
firewall-cmd --reload
firewall-cmd --zone=public --list-all

tail me some less…

One of my favorite tricks when using less is the ability to switch to a data stream in a log file or any file that might have dynamic content being added

  1. Typically I open the file in question using less then, review as required.
    here you use your standard Vi related navigation tricks.
  2. Move to the bottom of the file using SHIFT + g
  3. Switch to data stream mode using SHIFT + f
  4. Once you want to exit from the data stream use CTRL + c to quit
  5. Return to navigating around the file using the Vi style commands
  6. Finally exit the file
  7. Ask yourself if you will need tail -f much longer…

Stop Network Manager overwriting resolv.conf

Arg.. I updated /etc/resolv.conf and later after a reboot or restarting my network services NetworkManager pulls out my updates. So to stop this here is what have found works for me.

  1. Update /etc/resolv.conf as I wish
  2. edit NewtworkManager.conf
    sudo vi /etc/NetworkManager/NetworkManager.conf
  3. add dns=none under [main]
  4. restart NetworkManager to ensure my /etc/resolv.conf is left alone
  5. Wonder why I didn’t sort this out sooner 🙂