Hope that you are enjoying Linux learning. So lets see, what is in todays post? Today I’m going to share about some knowledge about the configuration of Firewall in Linux (CentOS/Red Hat)
So lets start the firewall configuration:
Firewall configuration in Linux (CentOS/Red Hat)
At first we’ll log in as super user. (By “su-” or “su root”)
[ece@localhost Desktop]$ su –Password:
Last login: Mon May 9 10:33:15 EDT 2016 on pts/1
just checked our firewal is working well or not.
[root@localhost ~]# systemctl enable firewalld [root@localhost ~]# systemctl restart firewalld [root@localhost ~]# systemctl status firewalld            ; =>> Recent status of firewall
So we got the output of the system:
- firewalld.service – firewalld – dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2016-05-10 00:22:22 EDT; 7s ago
Main PID: 4299 (firewalld)
CGroup: /system.slice/firewalld.service
└─4299 /usr/bin/python -Es /usr/sbin/firewalld –nof…
May 10 00:22:23 localhost.localdomain firewalld[4299]: 2016-05-…
May 10 00:22:23 localhost.localdomain firewalld[4299]: 2016-05-…
May 10 00:22:23 localhost.localdomain firewalld[4299]: 2016-05-…
May 10 00:22:23 localhost.localdomain firewalld[4299]: 2016-05-…
May 10 00:22:23 localhost.localdomain firewalld[4299]: 2016-05-…
May 10 00:22:23 localhost.localdomain firewalld[4299]: 2016-05-…
May 10 00:22:23 localhost.localdomain firewalld[4299]: 2016-05-…
May 10 00:22:23 localhost.localdomain firewalld[4299]: 2016-05-…
May 10 00:22:24 localhost.localdomain firewalld[4299]: 2016-05-…
May 10 00:22:24 localhost.localdomain firewalld[4299]: 2016-05-…
Hint: Some lines were ellipsized, use -l to show in full.
Now we’ll examine the status of IP table:
[root@localhost ~]# systemctl status iptables
- iptables.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
[root@localhost ~]# systemctl mask iptables
Created symlink from /etc/systemd/system/iptables.service to /dev/null.
[root@localhost ~]# firewall-cmd –state
running
[root@localhost ~]# firewall-config [root@localhost ~]# firewall-cmd –get-default-zone
public
[root@localhost ~]# firewall-cmd –permanent –zone=public –list-all
public (default)
interfaces:
sources:
services: dhcpv6-client ssh
ports: 53/tcp 80/tcp 53/udp
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
[root@localhost ~]# firewall-cmd –zone=public –list-all
public (default)
interfaces:
sources:
services: dhcpv6-client ssh
ports: 80/tcp 53/udp 53/tcp
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
[root@localhost ~]# firewall-cmd –set-default-zone public
Warning: ZONE_ALREADY_SET: public
[root@localhost ~]# firewall-cmd –set-default-zone publicWarning: ZONE_ALREADY_SET: public
[root@localhost ~]# echo ‘welcome to https’ > /var/www/html/index.html [root@localhost ~]# firewall-cmd –permanent –zone=public –add-port 443/tcpsuccess
[root@localhost ~]# firewall-cmd –reload
success
[root@localhost ~]# firewall-cmd –permanent –zone=public –add-service=httpssuccess
Finally we’ve reloaded firewall.
[root@localhost ~]# firewall-cmd –reloadsuccess
[root@localhost ~]#
Screenshots:
So hope that you’ve learn some thing about the configuration of firewall in Linux (CentOS/Red Hat).
Leave a Reply