Cloud Network

Networking | Support | Tricks | Troubleshoot | Tips

Buymecoffe

Buy Me A Coffee

Monday, October 21, 2019

How to Start/Stop and Enable/Disable FirewallD and Iptables CentOS/RHEL 7 & Fedora 25

October 21, 2019
How to Start/Stop and Enable/Disable FirewallD and Iptables CentOS/RHEL 7 & Fedora 25
 


 What is FirewallD ?


FirewallD is the Dynamic Firewall Manager of Linux systems. This service is used to configure the network connections, thus deciding which external network or internal packets to allow traversing the network and which to block.

It allows two types of configurations, permanent and runtime. Runtime configurations will get lost ones the service is restarted while the permanent ones get retained across the system boot so that they are followed every time the service gets active.

Corresponding to these configurations, firewallD has two directories, default/fallback one (/usr/lib/firewall) which is lost ones system is updated and the system configuration (/etc/firewall) which remains permanent and overrides the default one if given.

This is found as a default service in RHEL/CentOS 7 and Fedora 18.

What is Iptables ?


Iptables is another service which decides to allow, drop or return IP packets. Iptables service manages Ipv4 packets while Ip6tables manages Ipv6 packets.

This service manages a list of tables where each table is maintained for different purpose like: ‘filter‘ table is for firewall rules, ‘nat‘ table is consulted in case of new connection, ‘mangle‘ in case of packet alterations and so on.

Each table further has chains which can be built-in or user-defined where a chain signifies a set of rules which are applies to a packet, thus deciding what the target action for that packet should be i.e. it must be ALLOWED, BLOCKED or RETURNED.

This service is a default service on systems like: RHEL/CentOS 6/7 and Fedora 25, Arch Linux, Ubuntu etc.

How to Start/Stop & Enable/Disable FirewallD Service


If you’re using CentOS/RHEL 7 or Fedora 18-25 versions,
you should follow below instructions to manage FirewallD service.




Start FirewallD Service
Step1 :-  systemctl start firewalld

Stop FirewallD Service
Step2 :- systemctl stop firewalld

Check the Status of FirewallD
Step3 :- systemctl status firewalld

Check the State of FirewallD
Step4 :- firewall-cmd --state

As an alternative, you can disable the firewalld service so that it doesn’t apply rules to packets and enable ones needed again.

Disable FirewallD Service
Step5 :- systemctl disable firewalld

Enable FirewallD Service
Step6 :- systemctl enable firewalld

Mask FirewallD Service
Step7 :- systemctl mask firewalld

Also, you can mask the firewall service which creates a symbolic link of the firewall.service to /dev/null, thus disabling the service.

Unmask FirewallD Service
Step8 :- systemctl unmask firewalld

This is reverse of masking the service.

This removes the symlink of the service created during masking, thus re-enabling the service.

How to Start/Stop & Enable/Disable IPtables Service


On RHEL/CentOS 6/7 and Fedora 18-25 iptables firewall comes as pre and later, the iptables service can be installed via:

Step9 :- yum install iptables-services

Then, the service can be started, stopped or restarted via following commands:

Start Iptables Service
Step10 :- systemctl start iptables
OR
# service iptables start

Stop Iptables Service
Step11 :- systemctl stop iptables
OR
# service iptables stop

Disable Iptables Service
Step12 :- systemctl disable iptables
Or
# service iptables save
# service iptables stop

Enable Iptables Service
Step13 :- systemctl enable iptables
Or
# service iptables start

Check Status of Iptables Service
Step14 :- systemctl status iptables
OR
# service iptables status


On Ubuntu and some other Linux distributions however, ufw is the command which is used to manage the iptables firewall service.

Ufw provides an easy interface for the user to handle the iptables firewall service.

Enable Ufw Iptables Firewall
Step15 :- sudo ufw enable

Disable Ufw Iptables Firewall
Step16 :- sudo ufw disable

Check Status of Ufw Iptables Firewall
Step17 :- sudo ufw status

However, if you want to list chains in iptables which contains all the rules following command can help you achieve the same:
Step18 :- iptables -L -n -v

How to Upgrade MariaDB 5.5 to MariaDB 10.4 on CentOS/RHEL 7, Ubuntu 19.10 & Debian 9

October 21, 2019
How to Upgrade MariaDB 5.5 to MariaDB 10.4 on CentOS/RHEL 7, Ubuntu 19.10 & Debian 9
 
 




MariaDB is a famous MySQL community fork that gained lots of popularity after Oracle acquisition of the MySQL project.

Website:- https://downloads.mariadb.org/mariadb/+releases/

In this tutorial we are going to show you how to upgrade MariaDB 5.5 to MariaDB 10.4.8 latest stable version. You will need to have root access to the machine, where you will be performing the upgrade.

For example MariaDB 5.1 -> 5.5 -> 10.4.8

1. Backup or Dump All MariaDB Databases

As always when performing an upgrade creating backup of your existing databases is important.

You can either dump the databases with command such:
Step1:-  mysqldump -u root -ppassword --all-databases > /tmp/all-database.sql

Or alternatively, you can stop the MariaDB service with:
Step2:-  systemctl stop mysql

And copy the databases directory in a separate folder like this:
Step3:-  cp -a /var/lib/mysql/  /var/lib/mysql.bak


In case of failure of the upgrade you can use one of the above copies to restore your databases.

2. Add the MariaDB Repositorypackages are up to date

Step4:- yum update  [Redhat Linux, CentOS & Fedora]

Step5:- apt-get update  [Ubuntu, Linux Mint & Debian ]

On Redhat Linux, CentOS  & Fedora 
Step6:- vim /etc/yum.repos.d/MariaDB10.repo

Add the following text in it:
# MariaDB 10.1 CentOS repository list - created 2016-01-18 09:58 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

On Ubuntu, Linux Mint & Debian

Run the following series of commands to add the MariaDB PPA on your system:

Step7:- apt-get install software-properties-common

Step8:- apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:800xcbcb082a1bb943db

Step9:- add-apt-repository 'deb [arch=amd64,i386] http://kartolo.sby.datautama.net.id/mariadb/repo/10.1/ubuntu wily main'

Important: Don’t forget to replace the ubuntu wily with your distribution name and release.

3. Remove MariaDB 5.5

Step10:- yum remove mariadb-server mariadb mariadb-libs   [On On Redhat Linux, CentOS & Fedora]

Step11:- apt-get purge mariadb-server mariadb mariadb-libs  [On Ubuntu, Linux Mint & Debian]



Next, clean the repository cache:
Step12:-  yum clean all    [On Redhat Linux, CentOS & Fedora]
Step13:- apt-get clean all      [On Ubuntu, Linux Mint & Debian]

4. Installing MariaDB 10.4.8
Now it’s time to install the newer version of MariaDB, by using:

Step14:-  yum -y install MariaDB-server MariaDB-client   [On Redhat Linux, CentOS & Fedora]
Step15:-  apt-get install mariadb-server MariaDB-client     [On Ubuntu, Linux Mint  & Debian]

Start the MariaDB service
Step16:- systemctl start mariadb

MariaDB to automatically start after system boot
Step17:- systemctl enable mariadb

Finally run the upgrade command to upgrade MariaDB
Step18:- mysql_upgrade

To verify that the upgrade was successful
Step19:- mysql -V