Results 1 to 7 of 7

Thread: How to block the IP in particular folder

  1. #1
    Associate
    Join Date
    Jun 2010
    Location
    Coimbatore
    Posts
    22

    How to block the IP in particular folder

    Hi all,
    I ve task like block the refused connection IP's from /var/log/secure file


    `cat /var/log/secure | grep "refused connect" | awk '{print $9}' |sed 's/::ffff://g' |grep 190.184.35.27 >/root/sample`
    IP="/root/sample/"
    `iptables -A INPUT -s $IP -j DROP`

    When i run this script, i get an error like this
    [root@localhost ~]# sh ipblock.sh
    iptables v1.3.8: invalid mask `' specified
    Try `iptables -h' or 'iptables --help' for more information.
    [root@localhost ~]#

    As soon as give me some idea.........

    Thanks,
    Hariharan V.

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    I have no idear what your file looks like, but you can't make a file input to your iptables command, you need to issue the DROP on each IP, if theres one IP per line in that file, something like this might work:
    Code:
    for IP in `cat /root/sample`; do
       iptables -A INPUT -s $IP -j DROP
    done
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  3. #3
    Associate
    Join Date
    Jun 2010
    Location
    Coimbatore
    Posts
    22
    Hi,
    Thanks a loooot
    The script is ran without an error,can u tell me how to check if that mentioned IP is blocked or not.

  4. #4
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    # iptables -L INPUT -v

    See if it is listed as a rule.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  5. #5
    Associate
    Join Date
    Jun 2010
    Location
    Coimbatore
    Posts
    22
    Thank uuuuuuuuuuuu...........

  6. #6
    Associate
    Join Date
    Jun 2010
    Location
    Coimbatore
    Posts
    22
    Hi,
    Can u help me,i want to learn shell script from basic.
    could u tell me the best site for learn.

  7. #7
    Associate
    Join Date
    Jun 2010
    Location
    Coimbatore
    Posts
    22
    Hi,
    Using shell script i need to create a report with the following content.

    Create a report based on the Blocked IP list. Report should contain the following :
    --- Date, Blocked IP, country of origin, no of attempts, status

Similar Threads

  1. Umask for folder
    By svar in forum Linux - General Topics
    Replies: 0
    Last Post: 06-13-2009, 04:46 PM
  2. Be the first on your block....
    By Fatal Error in forum General Chat
    Replies: 0
    Last Post: 04-02-2005, 02:33 PM
  3. Folder Creation
    By mulberrycrush in forum Windows - General Topics
    Replies: 11
    Last Post: 01-22-2005, 07:28 PM
  4. FTP server.. for only a certain ip block.
    By gmoreno in forum Linux - Hardware, Networking & Security
    Replies: 4
    Last Post: 02-27-2003, 06:01 PM
  5. fd0 not a block device
    By Pantheus in forum Linux - General Topics
    Replies: 25
    Last Post: 10-08-2002, 10:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •