09-22-2009
Thanks a lot, it worked out..
Now, I would like to automate the process via cron;
Here below the last log from the server:
stybloga ftpd20571 ::ffff:80.99.99. Sun Sep 20 08:52 gone - no logout
stybloga ftpd20569 ::ffff:79.117.15 Sun Sep 20 08:52 gone - no logout
stybloga ftpd20568 ::ffff:95.223.19 Sun Sep 20 08:52 still logged in
stybloga ftpd20553 ::ffff:188.27.12 Sun Sep 20 08:51 gone - no logout
stybloga ftpd20552 ::ffff:85.66.149 Sun Sep 20 08:51 gone - no logout
stybloga ftpd20550 ::ffff:84.227.20 Sun Sep 20 08:51 gone - no logout
stybloga ftpd20534 ::ffff:89.102.22 Sun Sep 20 08:51 gone - no logout
stybloga ftpd20518 ::ffff:89.173.62 Sun Sep 20 08:51 gone - no logout
stybloga ftpd20511 ::ffff:94.19.144 Sun Sep 20 08:51 gone - no logout
stybloga ftpd20509 ::ffff:89.103.12 Sun Sep 20 08:51 gone - no logout
stybloga ftpd20508 ::ffff:86.101.22 Sun Sep 20 08:51 gone - no logout
stybloga ftpd20507 ::ffff:80.2.176. Sun Sep 20 08:51 gone - no logout
Where :
stybloga -> is the username
::ffff:80.2.1 -> ip address connected to the users.
What I am doing right now is
1) last | grep stybloga | awk '{print $3}' > one
2) awk -F. '{$0=((!$NF)?$0:$0FS)"0/8"}1' one > ipblck
3) Using the bash script, I will block the ip's
#!/bin/bash
BLOCKDB=/root/ipblck
IPS=$(grep -Ev "^#" $BLOCKDB)
for i in $IPS
do
iptables -A INPUT -s $i -j DROP
iptables -A OUTPUT -d $i -j DROP
done
So, now what I am trying is, there are different user like the same as above using different ip adderss.
1) Need to check the users in the last log, if a user count exceeds more than of 10 times,
2) Then it should check the third value, which is the ip address . If that do differs with different ip address for the 10 counts then
3) then the ip address should be taken and do as like the process what I have mentioned above.. the 3 steps that I am doing now..
I hope it make sense...
Regards
Siva
Last edited by gsiva; 09-22-2009 at 12:59 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Guys/Gals,
I have a log file that is updated once every few seconds and I am looking for a way to speed up one of my scripts.
Basically what I am trying to do is grep through a text file from start to finish once. Then each subsequent grep starts at the last line of the previous grep to... (4 Replies)
Discussion started by: Jerrad
4 Replies
2. Shell Programming and Scripting
Hi,
Does anyone know if its possible to add something like an end of line like c or java in unix?
dirs=/home/nosnam
var=''
for dir in $dirs
do
listDirs=`ls -d1 $dir/*`
for eachList in $listDirs
do
listRepos=`du -ks $eachList | awk '{ x+=$1 }; END { print x... (4 Replies)
Discussion started by: nosnam
4 Replies
3. Shell Programming and Scripting
Hi All
I have a script which has produced a list, I have used 'sed' to number my list, but i want to list at end of line with the first line starting at zero (0) and brackets round it
ie
My List i want
Hello (0)
this (1)
day (2)
can (3)
be (4)
sed '/./=' filename | sed '/./N; s/\n/) /'... (5 Replies)
Discussion started by: chassis
5 Replies
4. UNIX for Advanced & Expert Users
Hi i would like to add line numbers to end of each line in a file.
I am able to do it in the front of each line using sed, but not able to add at the end of the file.
Can anyone suggest
The following code adds line number to start of each line
sed = filename | sed 'N;s/\n/\t/'
how can i... (5 Replies)
Discussion started by: rudoraj
5 Replies
5. Shell Programming and Scripting
Hello, Would someone guide me on how to write a shell script the would search for a phone no using at the end text file using sed or awk and store it in a varaible or print it.
The text file is in this form
text or numbers in first line
text or numbers in second line
.
.
.
Firsname... (6 Replies)
Discussion started by: amuthiga
6 Replies
6. Shell Programming and Scripting
hi,
i have file which is having large sql query
eg :
i am executing this sql file but now i want to add ; after query on same line
i.e. i should look like
any idea how to achieve it ? (6 Replies)
Discussion started by: crackthehit007
6 Replies
7. Shell Programming and Scripting
I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed).
AU * A01 EXPENSE 6990370000 CWF SUBC TRAVEL & MISC
MY * A02 RESALE 6990788000 Y... (3 Replies)
Discussion started by: udelalv
3 Replies
8. Shell Programming and Scripting
Does anyone know how to use awk to act like grep from a particular line number to the end of file? I am using Solaris 10 and I don't have any GNU products installed.
Say I want to print all occurrences of red starting at line 3 to the end of file.
EXAMPLE FILE:
red
green
red
red... (1 Reply)
Discussion started by: thibodc
1 Replies
9. Shell Programming and Scripting
Given a file like this:
abc
def
ghi
I need to get to
somestandardtext abc1 morestandardtext
somestandardtext def2 morestandardtext
somestandardtext ghi3 morestandardtext
Notice that in addition to the standard text there is the line number added in as well. What I conceived is... (4 Replies)
Discussion started by: edstevens
4 Replies
10. Shell Programming and Scripting
How to add a comma at the end of each line in this file?30 1412
30 3352
30 5254
30 5543
30 7478
3 28
3 30
3 39
3 54
3 108
3 152
3 178
3 182
3 214
3 271
3 286
3 300
3 348
3 349
3 371 (3 Replies)
Discussion started by: gunjan
3 Replies
LEARN ABOUT HPUX
securenets
securenets(4) Kernel Interfaces Manual securenets(4)
NAME
securenets - NIS map security file
DESCRIPTION
The file defines networks and hosts that can access the NIS maps on a server. Each line in the file gives a network mask and a net
address. For example:
The format of the file is as follows:
o Lines beginning with the character are treated as comments.
o Lines that are not comment lines contain two fields separated by white space. The first field is a netmask, and the second field is a
network.
o The netmask field can be one of the following:
o 255.255.255.255 (IPv4)
o ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff (IPv6)
o the string indicating that the second field is a specific host to be allowed access.
The file can have any number of netmask/net pairs.
When is started on the server, it checks for the existence of and reads its contents into memory if it exists. must be stopped and
restarted for any changes in to take effect.
Upon startup, the netmask and the net address are converted to binary format and logical ANDed. The result must equal the net address (the
second address) to be legal.
If the netmask is 255.255.255.255 (all 1's in binary), any address in the net address argument will match it. If any field in the netmask
is 0, the corresponding field in the net address must be 0. When used in this way, the portion of the addresses given as 0 acts as a wild
card.
When a client attempts to bind to the server, checks the client's IP against those given in the file. Again, the address is converted to
binary and logical ANDed with the netmask. The result must equal the net address given in the file. If the client address does not match
any pairs in the file, the binding is refused with the message, "no such map in server's NIS domain".
The file can be used to limit access to specific hosts or to subnets using the wildcard capability.
If there are syntax errors in the file, messages are logged to the logging file (default and is not started.
If a host has multiple interfaces, each interface address must be allowed in the securenets file for that host to have reliable NIS access.
EXAMPLES
The following examples show entries for the file.
Either of the following entries provides access only to the host with address 192.33.33.33:
or
The following entry allows access by any host on the 192.33.33 subnet:
For broader access, such as an entire enterprise, the following entry allows any host whose address begins with "15" to be served:
Either of the following entries allows access for an individual IPv6 address:
or
The following entry allows access for all IPv6 addresses starting with "fec0":
SEE ALSO
ypserv(1M).
securenets(4)