How Can We Help?
< All Topics
Print

Enhancing Security: A Guide to Utilizing the VPS Firewall

A firewall is a network security device that monitors incoming and outgoing traffic, deciding whether to allow or block specific traffic based on specific security rules.

a) Linux

Types of methods to configure Linux firewall
1. Listing current rules

The “sudo iptables -L -v -n” command use to display all the current rules in the iptables firewall.

2. Set the default policy

The “sudo iptables -P INPUT DROP” command use to drop all incoming traffic, and the “sudo iptables -P OUTPUT ACCEPT” command allows all outgoing traffic.

3. Allow specific traffic

The sudo iptables -A INPUT -p tcp –dport 22 -j ACCEPT  command allow incoming SSH traffic on port 22.

4. Block specific traffic

The sudo iptables -A INPUT -s 192.168.1.10 -j DROP command use to block incoming traffic from a specific IP address.

5. NAT configuration (port forwarding)

The sudo iptables -t nat -A PREROUTING -i eth0 -p tcp –dport 8080 -j DNAT –to-destination 192.168.1.10:80 command use to forward incoming traffic on port 8080 to the internal machine on port 80.

6. Use the systemd method to save the rules

a) First, use the sudo systemctl enable iptables command to ensure that the iptables service is enabled and starts at boot time.

b) Then, use the sudo sh -c ‘iptables-save > /etc/iptables/iptables.rules’ command to configure iptables rules and save them.

c) Finally, systemd will utilize the iptables-restore service, which by default reads from the /etc/iptables/iptables.rules file.

7. Use the netfilter-persistent plugin to save the rules

a) First, use the sudo apt-get install iptables-persistent command to install the netfilter-persistent plugin.

b) Then, use the sudo netfilter-persistent save command to save the current IPtables rules.

8. Use the UFW (Uncomplicated Firewall) command to configure the IPtables firewall

a) The sudo ufw enable command allows you to enable UFW.

b) The sudo ufw allow ssh command allows SSH traffic.

c) The sudo ufw deny from [IPaddress] command use to reject traffic from a specific IP.

d) The sudo ufw status verbose command allows you to check UFW status and rules.

9. firewalld (systemd firewall component) configuration command

a) The sudo systemctl start firewalld and sudo systemctl enable firewalld commands allow you to start and enable firewalld.

b) The sudo firewall-cmd –add-service=http –permanent and sudo firewall-cmd –add-service=https –permanent commands allow HTTP and HTTPS services.

c) The sudo firewall-cmd –permanent –add-rich-rule=’rule family=”ipv4″ source address=”192.168.1.10″reject’ command allows you to block the IP address.

d) The sudo firewall-cmd –reload command allows you to reload the configuration.

10. CSF (Configure Server Firewall) command

a) The cd /usr/src, wget https://download.configserver.com/csf.tgz, tar -xzf csf.tgz, cd csf, or sh install.cpanel.sh command allows you to install CSF on the cPanel server.

b) The sudo csf -a [IPaddress] command allows the IP address.

c) The sudo csf -d [IPaddress] command allows you to block the IP address.

d) The sudo csf -r command allows you to reload CSF rules.

e) The sudo nano /etc/csf/csf.conf command allows you to view the configuration.

b) Windows

Types of methods to access the Windows Firewall with Advanced Security

1. To execute Windows Firewall with Advanced Security, press Win + R, type wf.msc, and press Enter, or use Command Prompt or Windows PowerShell.

VPS Firewall

2. To turn on Windows Firewall with Advanced Security, enter “firewall with” in the Start menu and select the Windows Firewall with Advanced Security icon.

3. To activate Windows Firewall with Advanced Security in Windows Server Manager, navigate to Tools in the upper right corner and select the Windows Firewall with Advanced Security option.

Windows command to enable or disable a Windows firewall

1. To turn on the firewall, use the netsh advfirewall set allprofiles state on command in the netsh.

2. To turn off the firewall, use the netsh advfirewall set allprofiles state off command in the netsh.

3. To turn on the firewall, use the Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True command in the Windows PowerShell.

4. To turn off the firewall, use the Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False command in the Windows PowerShell.

Table of Contents