Selinux e Firewall Linux
Selinux e Firewall Linux
Related articles.
# iptables-service
# touch /etc/sysconfig/iptables
# systemctl start iptables
# systemctl enable iptables
# touch /etc/sysconfig/ip6tables
# systemctl start ip6tables
# systemctl enable ip6table
The rest of this article assumes you are going to use firewalld.
Installation
Most installations will include the firewall functionality, but if you need to
manually install it, do the following.
You can check the current status of the service using the following command.
firewall-config
The GUI screen to control the firewall is available from the menu.
Alternatively, if can be started from the command line using the firewall-
config command. If it is not already present, it can be installed using the
following command.
Once started, the "Configuration:" drop-down allows you to decide if you are
modifying currently running settings (Runtime) or those saved for future use
(Permanent). You can also configure basic trusted services, such as SSH, FTP and
HTTP, by putting a tick in the appropriate checkbox. All changes are applied
immediately.
The "Ports" tab allows you to manually open ports that are not covered in the
"Trusted Services" section.
Remember, changes to the runtime configuration will be lost after the next
reboot. If in doubt, make all changes to the permanent configuration and reload
the runtime configuration using the "Options > Reload Firewalld" menu option.
firewall-cmd
In addition to the GUI interface, the firewall rules can be amended directly using
the firewall-cmd command. The full extent of the firewall configuration is
beyond the scope of this article, so instead a few specific examples will be given
to allow you to get a feel for it. This article also assumes you have a single
network interface and are happy to keep it set to the default zone (public).
The firewall-cmd usage notes are displayed when you use the "-h" or "--help"
options.
# firewall-cmd --help
Lock down and unlock the firewall using the following commands.
# firewall-cmd --panic-on
success
# firewall-cmd --query-panic
yes
# firewall-cmd --panic-off
success
# firewall-cmd --query-panic
no
#
Reload the runtime configuration from the permanent files using the following
command.
# firewall-cmd --reload
The firewall comes with predefined services, which are XML files is the
"/usr/lib/firewalld/services/" directory.
# ls /usr/lib/firewalld/services/
amanda-client.xml http.xml libvirt.xml pmwebapis.xml
ssh.xml
bacula-client.xml imaps.xml mdns.xml pmwebapi.xml
telnet.xml
bacula.xml ipp-client.xml mountd.xml pop3s.xml
tftp-client.xml
dhcpv6-client.xml ipp.xml ms-wbt.xml postgresql.xml
tftp.xml
dhcpv6.xml ipsec.xml mysql.xml proxy-dhcp.xml
transmission-client.xml
dhcp.xml kerberos.xml nfs.xml radius.xml
vnc-server.xml
dns.xml kpasswd.xml ntp.xml rpc-bind.xml
wbem-https.xml
ftp.xml ldaps.xml openvpn.xml samba-client.xml
high-availability.xml ldap.xml pmcd.xml samba.xml
https.xml libvirt-tls.xml pmproxy.xml smtp.xml
#
You shouldn't edit these. Instead, copy a specific service file to the
"/etc/firewalld/services/" directory and editing it there. The firewalld service
always uses files in "/etc/firewalld/services/" directory in preference to those in
the "/usr/lib/firewalld/services/" directory. Remember to reload the config after
making any changes.
# firewall-cmd --reload
As with the GUI interface, you need to decide if you want to make changes to
either the runtime configuration, permanent configuration or both. If you want
to set both the runtime and permanent configuration you have two choices. Set
them both independently, or set the permanent configuration and reload the
firewall.
or
All subsequent examples will assume you want to amend both the runtime and
permanent configuration and will only set the permanent configuration and
then reload the runtime configuration.
Open a specific port or range in a zone, check its runtime and permanent
configuration, then remove it.
# firewall-cmd --permanent --zone=public --add-port=8080-8081/tcp
# firewall-cmd --reload
Rich rules allow you to create more complex configurations. The following
command allows you to open HTTP access to a specific IP address.
The rule can be removed directly from the XML file, or removed using the "--
remove-rich-rule" option.
The following example opens and closes port 8080 for a specific source IP
address using a rich rule.
Not surprisingly, transferring the contents of this directory will allow you to
duplicate the firewall configuration in other servers.