SuSEFirewall2 is a script that reads the variables set in /etc/sysconfig/SuSEfirewall2 to generate a set of iptables rules. It defines three security zones, although only the first and the second one are considered in the following sample configuration:
Given that there is no way to control what is happening on the external network, the host needs to be protected from it. Usually, the external network is the Internet, but it could be another insecure network, such as a Wi-Fi.
This refers to the private network, usually the LAN. If the
hosts on this network use IP addresses from the private range (see
Netmasks and Routing, (↑Administration Guide)), enable network
address translation (NAT), so hosts on the internal network can access
the external one. All ports are open in the internal zone. The main
benefit of putting interfaces into the internal zone (rather than
stopping the firewall) is that the firewall still runs, so when you
add new interfaces, they will be put into the external zone by
default. That way an interface is not accidentally
While hosts located in this zone can be reached both from the external and the internal network, they cannot access the internal network themselves. This setup can be used to put an additional line of defense in front of the internal network, because the DMZ systems are isolated from the internal network.
NOTE: No Zone Assigned Behavior
By default, all network interfaces are set to no zone assigned. This mode behaves as the External Zone profile.
Any kind of network traffic not explicitly allowed by the filtering rule set is suppressed by iptables. Therefore, each of the interfaces with incoming traffic must be placed into one of the three zones. For each of the zones, define the services or protocols allowed. The rule set is only applied to packets originating from remote hosts. Locally generated packets are not captured by the firewall.
The configuration can be performed with YaST (see Section 15.4.1, Configuring the Firewall with YaST). It can also be made manually in the file /etc/sysconfig/SuSEfirewall2, which is well commented. Additionally, several example scenarios are available in /usr/share/doc/packages/SuSEfirewall2/EXAMPLES.
In case your network interfaces are located in a firewall zone where network traffic is blocked on most ports, services that manage their network traffic via a blocked port, will not work. For example, SSH is a popular service that uses port 22. By default, this port is blocked on interfaces located in the external or demilitarized zone. To make SSH work, you need to open port 22 in the firewall configuration. This can be done with the YaST module.
Figure 15-2 Firewall Configuration: Allowed Services
IMPORTANT: Automatic Firewall Configuration
After the installation, YaST automatically starts a firewall on all configured interfaces. If a server is configured and activated on the system, YaST can modify the automatically generated firewall configuration with the optionsor in the server configuration modules. Some server module dialogs include a button for activating additional services and ports. The YaST firewall configuration module can be used to activate, deactivate, or reconfigure the firewall.
Manually Open Firewall Ports with YaST
Openand switch to the tab.
Select a zone atin which to open the port. It is not possible to open a port for several zones at once.
Select a service fromand choose to add it to the list of . The port this service uses will be unblocked.
In case your service is not listed, you need to manually specify the port(s) to unblock. Chooseto open a dialog where you can specify TCP, UPD, RPC ports and IP protocols. Refer to the help section in this dialog for details.
Chooseto display a summary of your changes. Modify them by choosing or apply them by choosing .
The following paragraphs provide step-by-step instructions for a successful configuration. Each configuration item is marked whether it is relevant to firewalling or masquerading. Use port range (for example, 500:510) whenever appropriate. Aspects related to the DMZ (demilitarized zone) as mentioned in the configuration file are not covered here. They are applicable only to a more complex network infrastructure found in larger organizations (corporate networks), which require extensive configuration and in-depth knowledge about the subject.
To enable SuSEFirewall2, use sudo systemctl enable SuSEfirewall2 or use the YaST module Services Manager.
The device linked to the Internet. For a modem connection, enter ppp0. DSL connections use dsl0. Specify auto to use the interface that corresponds to the default route.
The device linked to the internal, private network (such as eth0). Leave this blank if there is no internal network and the firewall protects only the host on which it runs.
If you need the masquerading function, set this to yes. Your internal hosts will not be visible to the outside, because their private network addresses (for example 192.168.x.x) are ignored by Internet routers.
For a firewall without masquerading, set this to yes if you want to allow access to the internal network. Your internal hosts need to use officially registered IP addresses in this case. Normally, however, you should not allow access to your internal network from the outside.
Set this to yes if you need the masquerading function. This provides a virtually direct connection to the Internet for the internal hosts. It is more secure to have a proxy server between the hosts of the internal network and the Internet. Masquerading is not needed for services that a proxy server provides.
Specify the hosts or networks to masquerade, leaving a space between the individual entries. For example:
Set this to yes to protect your firewall host from attacks originating in your internal network. Services are only available to the internal network if explicitly enabled. Also see FW_SERVICES_INT_TCP and FW_SERVICES_INT_UDP.
Enter the TCP ports that should be made available. Leave this blank for a normal workstation at home that should not offer any services.
Leave this blank unless you run a UDP service and want to make it available to the outside. The services that use UDP include DNS servers, IPsec, TFTP, DHCP and others. In that case, enter the UDP ports to use.
List services to allow from the Internet. This is a more generic form of the FW_SERVICES_EXT_TCP and FW_SERVICES_EXT_UDP settings, and more specific than FW_TRUSTED_NETS. The notation is a space-separated list of NET,PROTOCOL[,DPORT][,SPORT], for example 0/0,tcp,22 or 0/0,tcp,22,,hitcount=3,blockseconds=60,recentname=ssh, which means: allow a maximum of three SSH connects per minute from one IP address.
With this variable, define the services available for the internal network. The notation is the same as for FW_SERVICES_EXT_TCP, but the settings are applied to the internal network. The variable only needs to be set if FW_PROTECT_FROM_INT is set to yes.
List services to allow from internal hosts. See FW_SERVICES_ACCEPT_EXT.
This is how the SuSEFirewall2 implementation considers packets RELATED by netfilter.
For example, to allow finer grained filtering of Samba broadcast packets, RELATED packets are not accepted unconditionally. Variables starting with FW_SERVICES_ACCEPT_RELATED_ allow restricting RELATED packets handling to certain networks, protocols and ports.
This means that adding connection tracking modules (conntrack modules) to FW_LOAD_MODULES does not automatically result in accepting the packets tagged by those modules. Additionally, you must set variables starting with FW_SERVICES_ACCEPT_RELATED_ to a suitable value.
Uncomment this variable to install custom rules. Find examples in /etc/sysconfig/scripts/SuSEfirewall2-custom.
After configuring the firewall, test your setup. The
firewall rule sets are created by entering systemctl start
root. Then use
telnet, for example, from an external host to see
whether the connection is actually denied. After that, review the output
of journalctl (see Section 15.0,
journalctl: Query the systemd Journal, (↑Administration Guide)),
where you should see something like this:
Mar 15 13:21:38 linux kernel: SFW2-INext-DROP-DEFLT IN=eth0 OUT= MAC=00:80:c8:94:c3:e7:00:a0:c9:4d:27:56:08:00 SRC=192.168.10.0 DST=192.168.10.1 LEN=60 TOS=0x10 PREC=0x00 TTL=64 ID=15330 DF PROTO=TCP SPT=48091 DPT=23 WINDOW=5840 RES=0x00 SYN URGP=0 OPT (020405B40402080A061AFEBC0000000001030300)
Other packages to test your firewall setup are Nmap (portscanner) or OpenVAS (Open Vulnerability Assessment System). The documentation of Nmap is found at /usr/share/doc/packages/nmap after installing the package and the documentation of openVAS resides at http://www.openvas.org.