How to block an IP address in IPTables in Linux Ako zablokovať IP adresu v iptables v Linuxe

by Sukrit Dhandhania on April 6, 2009 používateľa Sukrit Dhandhania dňa 6.dubna 2009

LinuxBezpečnosť

If you are responsible for a Linux server, security becomes a big concern. Ak ste zodpovedný za server Linux, bezpečnosť sa stáva veľkým problémom. Some of the biggest threats to a server's security are DDOS attacks and repeated attempts to enter the server using automates bots. Niektoré z najväčších hrozieb pre bezpečnosť servera sú DDOS útoky a po opakovaných pokusoch vstúpiť na server pomocou automatizuje roboty. There are a number of ways by which you can detect the IP address of a potential intruder. Existuje mnoho spôsobov, ktorými možno zistiť IP adresu potenciálneho votrelca. But what do you do after you have located his/her IP address? Ale čo robiť potom, čo ste sa nachádza jeho IP adresu? Well, you block it. No, zablokujte ho. Here's how you do it using IPTables which is the firewall that ships with most flavors of Linux. Tu je návod, ako to urobiť pomocou iptables, ktorý je firewall, ktorý je dodávaný s najväčšou chuť na Linux.

If you have just one IP address that you want to block you can use the following method: Ak máte len jednu IP adresu, ktorú chcete blokovať, môžete použiť nasledujúci postup:

# iptables -I INPUT -s 122.174.12.228 -j DROP # Iptables-I INPUT-s 122.174.12.228-j DROP

This command will add an entry into your iptables configuration file, instructing it to drop any packets that come from the IP 122.172.9.222 . Tento príkaz pridá vstup do iptables konfiguračný súbor, ktorý nariaďuje, aby nepokračoval pakety, ktoré pochádzajú z IP 122.172.9.222. If you face numerous attacks you are better of using a slightly more automated method to add the IPs from your ban list. Máte-li čeliť sérii útokov ste lepšie použiť o niečo viac automatizovaná metóda pridať IP zo svojho zoznamu zakázaných. To do that create the following script: K tomu, že vytvorte nasledujúci skript:

#!/bin/sh #! / Bin / sh
for i in $(< banned_IPs.cfg) ; do for i in $ (<banned_IPs.cfg); do
iptables -I INPUT -i eth1 -s "$i" -j DROP iptables-I INPUT-i eth1-s "$ i"-j DROP
done hotovo

Save the script into a file named something like banned_IPs.sh and grant it executable privileges: Uložiť skript do súboru s názvom niečo ako banned_IPs.sh a poskytnúť je spustiteľný výsady:

# chmod +x banned_IPs.sh # Chmod + x banned_IPs.sh

Now create a file called banned_IPs.cfg and enter the list of IP addressed you want to block, each in a new line: Teraz vytvorte súbor s názvom banned_IPs.cfg a zadajte zoznam IP adresované, ktorú chcete blokovať, každý z novej série:


122.174.12.228 122.174.12.228
129.122.10.23 129.122.10.23
111.154.84.130 111.154.84.130

Now run the script banned_IPs.sh to have the IP addresses you want blocked added to the list of banned IPs in iptables: Teraz spustite skript banned_IPs.sh mať IP adries, ktoré chcete blokovaný pridané na zoznam zakázaných IP v iptables:

# ./banned_IPs.sh #. / Banned_IPs.sh

Related Posts: Súvisiace zmeny:
  • How to block DDOS attacks in Linux Ako blokovať DDOS útoky v Linuxe
  • Getting started with iptables in Linux Začíname s iptables v Linuxe
  • How to redirect traffic to another machine in Linux Ako presmerovať prevádzku na iný stroj v Linuxe
  • How to delete an individual site from the address bar's list of previously viewed sites in Firefox Ako odstrániť jednotlivé stránky z adresného riadku v zozname skôr zobrazených stránok vo Firefoxe
  • How to determine your IP or MAC address in Windows Ako zistiť IP alebo MAC adresy v systéme Windows
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Get Help jednoduchá cvičenie, rovnako ako to vo vašej e-mailovej schránky každý deň - zadarmo! Just enter your email address below: Stačí zadať e-mailovú adresu:

    You can always opt out of this email subscription at any time. Vždy sa môžete odhlásiť z tohto e-mailu predplatného kedykoľvek.

    { 1 comment… read it below or (1 komentár ... prečítať nižšie alebo add one pridať jedno } )

    1 1 Teixeira 05.10.09 at 4:41 am Teixeira 05.10.09 v 441: am

    Simple, clear and efficient. Jednoduchý, jasný a účinný.
    Btw, is there any nice black list website where we can sync the “banned_IPs.cfg” file dailly for example? Btw, existuje nejaká pekná čierna listina webovej stránky, kde možno synchronizovať "banned_IPs.cfg" súbor DAILLE napríklad? Should be nice…. Mal by byť príjemný ....

    br, br,
    TT TT

    Leave a Comment Zanechať komentár

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> Môžete použiť tieto HTML tagy a atribúty: href = "" <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> del datetime <em> <i> <q Cite=""> <strike> <strong>