Jump to content

Linux: How do I block an IP?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Ronin

Ronin

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 309 posts
How can I block an IP in Linux from my entire server? I'm getting several "hack" attempts I believe and the admin has recommended me blocking them. I don't see this feature in WHM but do in cPanel. Blocking them per website does not help, I need the entire server and all ports to block the IP address. Anyone?

#2
Guest_littlefranciscan_*

Guest_littlefranciscan_*
  • Guests
I too would like to know how to stop hackers..there are times that I am sure my who computer is being run by outside sources.. I have the AVG virus protection and paid for some thing Called "Evidence Eraser" that is suppose to hide your tracks..but I don't know if I have all the protection I need either!

#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Well doesn't mean that they cant hack you! even if you have Evidence Eraser.

#4
Guest_littlefranciscan_*

Guest_littlefranciscan_*
  • Guests
So if this is true, how do you get them not to hack you..I was told this helps and paid some pretty penny for it:( so I must search and find if there are any free ways..Are there? To prevent hackers?

#5
Guest_Jordan_*

Guest_Jordan_*
  • Guests
This does help, in fact, it prevents them from hacking you at all unless they spoof their IP or change it which most people can change their IP very easily.

Here is how:

1. Login to your server via SSH and su - to root (do not forget the - after su).

2. After logging in as root, you may want to look at what's already loaded, if anything. To look at the tables that are currently in effect:

(Note: You might need to add "| less" to the end of your iptables -L commands if you have a lot of iptables rules. This will let you view the rules one page at a time. You can use "q" to quit.)

# iptables -L -n

3. To successfully block an IP address, the syntax would be:

# iptables -I INPUT -s IP_ADDRESS_HERE -j DROP

e.g.:

# iptables -I INPUT -s 123.123.123.123 -j DROP

4. To verify that your entry was successful:
(Note: You might need to add "| less" to the end of your iptables -L commands if you have a lot of iptables rules. This will let you view the rules one page at a time. You can use "q" to quit.)

(as root still)

# /sbin/iptables -L -n

5. If you want to flush your IPtables:

# /sbin/iptables -F

You can find other options to choose from with the following command:

# /sbin/iptables --help

Block From: [Linux] Block IP Address using IPtables - Webmaster Forum

#6
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

littlefranciscan said:

So if this is true, how do you get them not to hack you..I was told this helps and paid some pretty penny for it:( so I must search and find if there are any free ways..Are there? To prevent hackers?

Use a Firewall? and read this tutorial http://forum.codecal...ecure-free.html