X
X

Select Your Currency

₺ Türk Lirası $ US Dollar
X
X

Select Your Currency

₺ Türk Lirası $ US Dollar

How to Perform Firewall Configuration Safely

HomepageArticlesSecurityHow to Perform Firewall Configurati...

Firewall configuration determines which connections a server accepts, but an incorrect rule can also cut off administrative access. For safe implementation, first distinguish the provider’s network security layer from the operating system firewall, preserve your existing SSH or management connection, allow necessary traffic by source address and port, and then repeat the same connection afterward to verify the result using new, time-stamped logs.

Clarify the environment before firewall configuration

This guide is for a Linux VPS or physical server that can be accessed through an administrative shell. On a shared hosting account, you cannot change the operating system firewall; you can use only the IP blocking, application security, or provider rules offered in the hosting panel. On managed servers, however, the network firewall in the provider’s control panel and tools such as ufw, firewalld, or nftables on the server may evaluate the same traffic one after another.

First, record the following information in writing: the management protocol and port, the ports used by the web application, the sources that need database access, the addresses of monitoring or backup systems, and your current client IP address. Instead of allowing unrestricted public access to the management port, limit it to a fixed office, VPN, or management-network address whenever possible. If the source address is not fixed, verify in advance that the provider console or another recovery access method works.

Assess both firewall layers together

If a connection is blocked by the provider’s firewall and never reaches the operating-system rule, the expected entry may not appear in the server logs. Conversely, the local firewall can drop a connection even when the provider allows the port through. Therefore, do not change only one layer and assume that the other layer has not changed the outcome.

Safe operating sequence before applying rules

  1. Prepare backup access: Check that the web console in the provider panel or another management channel actually opens. Store the existing firewall rules using the panel’s export feature or a configuration backup supported by the management tool you use. This allows you to return to the previous state if the connection is lost.
  2. Identify listening services: With administrative privileges on the server, you can use a read-only connection-listing tool such as ss -tulpen. Do not automatically treat every listening port shown in the output as a port that should be exposed to the internet. Compare it with the service settings and architecture to determine whether the service really needs external access or is used only by a local application. If a port does not need to listen, securely stopping the service may be more appropriate than adding a firewall rule.
  3. Define the necessary permissions first: In the provider firewall interface and then in the local firewall manager, allow the HTTP/HTTPS traffic required by the web service; for management, allow access only from the designated source address. Do not expose the database port to the public internet. If access is not required outside the application server’s private network address or a trusted management network, restrict the rule to that source. A permission with an unspecified source address expands the attack surface rather than solving the problem.
  4. Review rule order and default behavior: Check whether the firewall manager evaluates rules from top to bottom or according to priority values. Do not switch to a general reject or drop policy before the required permissions have been verified. A broad blocking rule above an allow rule can still stop the connection; in that case, correct only the priority or scope of the relevant rule instead of changing all rules at once.
  5. Apply one change: For example, suppose the management connection passes through the provider layer but is rejected in the operating system firewall log, and your source address is not in the allowlist. Add management access only for that address. Changing the port, changing the default policy, and allowing all addresses at the same time makes it unclear which change had an effect. Before making the rule permanent, read how the tool you use separates temporary and persistent configuration.
  6. Repeat the same operation and look for new evidence: Note the time of the first connection attempt, save the rule, and repeat the same management login or web request. In the firewall log for the new time window, look for the accepted connection; in the application log, look for evidence that the request reached the service. If the connection succeeds, document the existing rule without changing another port. If it is still rejected, distinguish which of the provider and local layers produced the new entry.

Which rule should you correct based on the symptom?

If only an externally initiated SSH connection fails while the website works, the problem is probably not with the web ports but with the source scope of the management port or the priority at one of the layers. First check that the client IP has not changed. If it has changed, add the new trusted address in a controlled way instead of broadening the old single-address rule without restriction. If the web service also fails, examine the port permission at the provider layer, the local firewall, and whether the service is actually listening, each separately.

Suppose an application server needs to connect only to a database on a private network, while administrators use SSH over a VPN. If external web access is required, the web ports can remain publicly accessible; define the database port to allow only the application server’s private address, and SSH to allow only the VPN network. If the application server’s address changes, the existing rule may interrupt the connection. The safe correction is to verify the new address, update the rule, and remove the old address only after proving that it is no longer in use.

Verification and rollback after the change

A connection that appears successful does not, by itself, prove that the rule has the correct scope. Test the application with a real usage scenario: check the HTTP status of a web request, confirm that an SSH session can be opened, and for application-to-database communication, check for a new application success or error entry. The time in the firewall log must match the test time; do not treat old entries as evidence of the new result.

If the symptom continues, roll back the latest rule before changing another layer, using the previous backup or the recorded value. Especially if management access has been cut off, use the provider console; completely disabling the firewall, turning off security controls, or granting broad permissions is not a safe recovery method. If the connection is restored after the previous setting is returned, reconsider only the immediately preceding change and test it again with a narrower scope.

The purpose of the rules is not to make unused ports invisible, but to define expected traffic explicitly while limiting unnecessary access. After the initial implementation, make a brief record of the port, source address, reason, and time of the last verification. For additional guidance about server management or the network layer, you can review the relevant resources on the İyibirNet home page.


Top