Our VPSs with DirectAdmin use 'firewalld' as a firewall by default. In firewalld, you can choose to allow only specific IPs to connect to port 2222. Port 2222 is the port you connect to in order to log in to DirectAdmin.
- First close port 2222 with the command below (i.e. in reality remove port 2222 from the list of open ports):
firewall-cmd --permanent --zone=public --remove-port=2222/tcp
- With the commands below, you create an exception for your own IP address so that only your own IP can connect to port 2222.
firewall-cmd --permanent --zone=public --add-rich-rule='
rule family="ipv4"
source address="1.2.3.4"
port protocol="tcp" port="2222" accept'
Replace 1.2.3.4 with your actual IP address. You can repeat these steps to give access to more IPs.
- Reload firewalld to process the changes:
firewall-cmd --reload