Applicable to:
- Plesk for Linux
- Plesk for Windows
Question
How to allow connections to a port from specific IP addresses only?
Answer
-
Go to Tools & Settings > Firewall.
Note: If Firewall is not available, install it using the instructions from this KB article.
-
Enable Firewall Rules Management and click Modify Plesk Firewall Rules.
-
Click on an existing rule to edit.
-
Select Allow from selected sources, deny from others and add IP addresses from which connections will be allowed.
-
Click OK.
-
Click Apply Changes.
Alternatively, use the OS native tool to achieve that:
-
Connect to the server via RDP.
-
Go to Start > Windows Powershell.
-
Run the following command:
PS New-NetFirewallRule -DisplayName "Allow TCP:15555 from certain IPs" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 15555 -RemoteAddress (203.0.113.2)
Note: Replace 203.0.113.2 and 15555 with the actual IP and network port to be allowed access from/to accordingly.
-
Connect to the server via SSH.
-
Run the following command:
# iptables -I INPUT -p tcp ! -s 203.0.113.2 --dport 15555 -j DROP
Note: Replace 203.0.113.2 and 15555 with the actual IP and network port to be allowed access from/to accordingly.
- (optional) For IP address range:
# iptables -I INPUT -p tcp ! --src-range 203.0.113.2-203.0.113.35 --dport 15555 -j DROP
Note: Replace 203.0.113.2-203.0.113.35 and 15555 with the actual IPs and network port to be allowed access from/to accordingly.
-
Save the changes in iptables:
# iptables-save > /etc/sysconfig/iptables
Comments
0 comments
Please sign in to leave a comment.