The way to Block IP Addresses From Accessing a Desktop or Server in Linux


On this The way to Make Tech Work tutorial, Jack Wallen exhibits methods to add one other layer of safety to your Linux machines with simply two recordsdata.

Do you know there’s a very simple solution to block or enable IP addresses in Linux utilizing two easy recordsdata? These recordsdata are hosts.enable and hosts.deny, and so they make it such which you can block or enable IP addresses on the fly with out having to take care of extra sophisticated firewall guidelines.

With this means, you might shortly block a suspicious IP handle to keep away from attainable malicious exercise; or, you might restrict, say, SSH connections to solely particular addresses so that you don’t have to fret about third events getting access to your servers or desktops. Let me present you the way it’s finished by demonstrating SSH entry to a machine. The one stuff you’ll want for this are a operating occasion of Linux and a consumer with sudo privileges.

Log in to your Linux machine and open a terminal window. The very first thing we’re going to do is deny all entry to the SSH daemon. Open hosts.deny with the command sudo nano /and many others/hosts.deny. On the backside of that file, add sshd: ALL. Save and shut the file.

Subsequent, open hosts.enable with the command sudo nano /and many others/hosts.enable. Let’s say you wish to allow SSH entry to solely two machines in your community, that are at IP addresses 192.168.1.62 and 192.168.1.152; for that, on the backside of the file, add the road sshd: 192.168.1.62, 192.168.1.152. Save and shut the file.

At this level, the one two machines which might be in a position to entry your desktop or server by way of SSH are these two. Remember the fact that hosts.deny is learn earlier than hosts.enable so having sshd: ALL set to hosts.deny is simply overridden if there’s an entry in hosts.enable. When you configure hosts.deny with ssdh: ALL and don’t add a corresponding entry in hosts.enable, nobody will probably be allowed entry, by way of SSH, to the machine.

And that’s all there may be to utilizing hosts.deny and hosts.enable so as to add one other layer of safety to your Linux machines.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the newest tech recommendation for enterprise execs from Jack Wallen.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles