Managing Linux VPS Firewall Rules

From Hostek.com Wiki
Jump to: navigation, search

Adding an allow rule to a Linux VPS Firewall

Situation

You want to open up a custom TCP or UDP port on your VPS, but want to restrict it such that only a specific IP address can connect on that port.

Solution

You will need to create an allow rule for your server's firewall. For example, you want to open TCP port 6201, but you only want the address 192.0.43.7 to have access. The rule would look like this:

tcp|in|d=6201|s=192.0.43.7 #Some useful description

Let's discuss each part of this sample rule. The first part is the protocol: tcp. The next part is the direction, which is inbound traffic. The next part is the port, 6201. The next part is the source IP address that you want the rule to apply to, 192.0.43.7. And finally, you can put some short worthwhile comment on the end to remind yourself later what the rule is for.

Now, let's say for example that you want to allow inbound UDP port 6203, but you only want IP address 192.0.45.8 to have access. The appropriate command would look like this:

udp|in|d=6203|s=192.0.45.8 #Another useful description.

Steps for adding firewall allow rules

Steps:

  1. Log into WHM on your server at https://your_server_IP:2087
  2. Once logged in, scroll down and click on ConfigServer Security&Firewall
  3. Click on the Fireawll Allow IPs button
  4. Add the rule you created