Using firewall rules
allow traffic from a specific IP address
To deny traffic from a specific IP address
Using TCP wrappers
allow Access to your ssh server from ip address
allow ip address to Access your ssh server
TCP wrappers with subnet mask
Using buil in firewall
allow or block traffic to or from specific IP address
Using host.allow or host.deny
Limiting access to your Linux server by IP address is an effective way to enhance its security. By doing so, you can restrict access to your server only to trusted users or networks. Here are some examples of how you can limit IP addresses on your Linux server:
1.Using firewall rules
One of the most common ways to limit access to your Linux server by IP address is to use firewall rules. You can use the iptables or ufw firewall to allow or deny traffic from specific IP addresses.
For example, if you want to allow traffic from a specific IP address (e.g. 192.168.0.10) to your SSH server, you can run the following command using iptables
sudo iptables -A INPUT -p tcp --dport ssh -s 192.168.0.10 -j ACCEPT
This will allow incoming SSH traffic from the IP address 192.168.0.10. To deny traffic from a specific IP address, you can replace ACCEPT with DROP.
If you're using ufw, you can use the following commands to allow or deny traffic from a specific IP address:
sudo ufw allow from 192.168.0.10 to any port ssh
sudo ufw deny from 192.168.0.10 to any port ssh
2.Using TCP wrappers
Top comments (0)