In: Computer Science
Instructions:
Using Unix programming language and regular expressions,
1. how many unique ip addresses were seen note: we only want to
look at ipv4 addresses
2. which was most commnly seen ip address
on the piece of access.log file below
66.249.75.132 - - [18/Jun/2018:06:41:00 -0500] "GET
/~rcoleman/Common/History/Images/?C=N;O=D HTTP/1.1" 200 1976 "-"
"Mozilla/5.0 (compatible; Googlebot/2.1;
+http://www.google.com/bot.html)"
5.255.250.23 - - [18/Jun/2018:06:41:23 -0500] "GET
/~rcoleman/Common/CodeVault/Code/DesignPatterns/Images/DP16-Builder.jpg
HTTP/1.1" 304 182 "-" "Mozilla/5.0 (compatible; YandexImages/3.0;
+http://yandex.com/bots)"
5.255.250.23 - - [18/Jun/2018:06:41:28 -0500] "GET
/~rcoleman/CS121/CourseInfo/Images/WinExp.jpg HTTP/1.1" 304 180 "-"
"Mozilla/5.0 (compatible; YandexImages/3.0;
+http://yandex.com/bots)"
148.108.96.32 - - [18/Jun/2018:06:41:43 -0500] "GET
/~rcoleman/Common/Basics/Images/ASCII_Table.jpg HTTP/1.1" 200
144715 "https://www.bing.com/" "Mozilla/5.0 (Windows NT 6.1; WOW64;
rv:52.0) Gecko/20100101 Firefox/52.0"
5.255.250.23 - - [18/Jun/2018:06:42:41 -0500] "GET
/~delugach/Courses/H399-01/License%20Agreement%20for%20Acrobat
HTTP/1.1" 200 12667 "-" "Mozilla/5.0 (compatible; YandexBot/3.0;
+http://yandex.com/bots)"
5.255.250.23 - - [18/Jun/2018:06:42:59 -0500] "GET
/~rcoleman/Common/CodeVault/Code/DesignPatterns/Images/DP03-Decorator.jpg
HTTP/1.1" 304 182 "-" "Mozilla/5.0 (compatible; YandexImages/3.0;
+http://yandex.com/bots)"
49.36.1.71 - - [18/Jun/2018:06:43:22 -0500] "GET /favicon.ico
HTTP/1.1" 301 4121
"https://www.cs.uah.edu/~rcoleman/Common/C_Reference/C++%20For%20DUMMIES.pdf"
"Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/69.0.3452.0 Safari/537.36"
148.253.182.198 - - [18/Jun/2018:06:44:00 -0500] "GET
/~rcoleman/CS121/ClassTopics/Images/Operators02.jpg HTTP/1.1" 200
54617 "https://www.bing.com/" "Mozilla/5.0 (Windows NT 6.3; WOW64;
Trident/7.0; rv:11.0) like Gecko"
49.36.1.71 - - [18/Jun/2018:06:43:21 -0500] "GET
/~rcoleman/Common/C_Reference/C++%20For%20DUMMIES.pdf HTTP/1.1" 200
8103354 "https://www.google.co.in/" "Mozilla/5.0 (Windows NT 6.3;
Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/69.0.3452.0 Safari/537.36"
66.249.75.130 - - [18/Jun/2018:06:44:42 -0500] "GET
/~rcoleman/Common/History/Images/Pic20_ABC.jpg HTTP/1.1" 304 181
"-" "Googlebot-Image/1.0"
179.7.54.141 - - [18/Jun/2018:06:44:53 -0500] "GET
/~rcoleman/Common/C_Reference/C++%20For%20DUMMIES.pdf HTTP/1.1" 200
8085570 "-" "Dalvik/2.1.0 (Linux; U; Android 7.0; SM-J730GM
Build/NRD90M)"
175.158.232.110 - - [18/Jun/2018:06:45:58 -0500] "GET
/~rcoleman/CS121/ClassTopics/Images/CompSys10.jpg HTTP/1.1" 200
217846 "https://www.google.com.ph/" "Mozilla/5.0 (Windows NT 6.1;
WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116
Safari/537.36"
5.255.250.23 - - [18/Jun/2018:06:46:03 -0500] "GET
/~rcoleman/Common/SoftwareEng/Images/UML_01.jpg HTTP/1.1" 304 181
"-" "Mozilla/5.0 (compatible; YandexImages/3.0;
+http://yandex.com/bots)"
5.255.250.23 - - [18/Jun/2018:06:46:23 -0500] "GET
/~dhardin/cs_100/Animations/frmMoveBall_GUI.frm HTTP/1.1" 200 2066
"-" "Mozilla/5.0 (compatible; YandexBot/3.0;
+http://yandex.com/bots)"
216.244.66.197 - - [18/Jun/2018:06:47:14 -0500] "GET /robots.txt
HTTP/1.1" 301 577 "-" "Mozilla/5.0 (compatible; DotBot/1.1;
http://www.opensiteexplorer.org/dotbot, [email protected])"
157.55.39.241 - - [18/Jun/2018:06:47:37 -0500] "GET
/~rcoleman/Common/Basics/Images/Pointers03.jpg HTTP/1.1" 200 76104
"-" "Mozilla/5.0 (compatible; bingbot/2.0;
+http://www.bing.com/bingbot.htm)"
41.190.3.133 - - [18/Jun/2018:06:47:51 -0500] "GET
/~rcoleman/Common/History/History.html HTTP/1.1" 200 9592
"http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=14&ved=0ahUKEwjNw_ODkt3bAhWkB8AKHfbUCMwQFghnMA0&url=http%3A%2F%2Fwww.cs.uah.edu%2F~rcoleman%2FCommon%2FHistory%2FHistory.html&usg=AOvVaw1na6HxGz_OCQSHXgI3jn1L"
"Mozilla/5.0 (Windows NT 6.1; rv:36.0) Gecko/20100101
Firefox/36.0"
41.190.3.133 - - [18/Jun/2018:06:47:52 -0500] "GET
/~rcoleman/Common/History/Images/Pic02_RomanAbacus.jpg HTTP/1.1"
200 43539
"http://www.cs.uah.edu/~rcoleman/Common/History/History.html"
"Mozilla/5.0 (Windows NT 6.1; rv:36.0) Gecko/20100101
Firefox/36.0"
41.190.3.133 - - [18/Jun/2018:06:47:52 -0500] "GET
/~rcoleman/Common/History/Images/Pic01_AncientTimes.jpg HTTP/1.1"
200 40097
"http://www.cs.uah.edu/~rcoleman/Common/History/History.html"
"Mozilla/5.0 (Windows NT 6.1; rv:36.0) Gecko/20100101
Firefox/36.0"
41.190.3.133 - - [18/Jun/2018:06:47:52 -0500] "GET
/~rcoleman/Common/History/Images/Pic03_JohnNapier.jpg HTTP/1.1" 200
39131 "http://www.cs.uah.edu/~rcoleman/Common/History/History.html"
"Mozilla/5.0 (Windows NT 6.1; rv:36.0) Gecko/20100101
Firefox/36.0"
41.190.3.133 - - [18/Jun/2018:06:47:52 -0500] "GET
/~rcoleman/Common/History/Images/Pic06_WilliamOughtred.jpg
HTTP/1.1" 200 49153
"http://www.cs.uah.edu/~rcoleman/Common/History/History.html"
"Mozilla/5.0 (Windows NT 6.1; rv:36.0) Gecko/20100101
Firefox/36.0"
41.190.3.133 - - [18/Jun/2018:06:47:52 -0500] "GET
/~rcoleman/Common/History/Images/Pic05_SlideRule.jpg HTTP/1.1" 200
71314 "http://www.cs.uah.edu/~rcoleman/Common/History/History.html"
"Mozilla/5.0 (Windows NT 6.1; rv:36.0) Gecko/20100101
Firefox/36.0"
41.190.3.133 - - [18/Jun/2018:06:47:53 -0500] "GET
/~rcoleman/Common/History/Images/Pic04_NapiersBones.jpg HTTP/1.1"
200 53637
"http://www.cs.uah.edu/~rcoleman/Common/History/History.html"
"Mozilla/5.0 (Windows NT 6.1; rv:36.0) Gecko/20100101
Firefox/36.0"
Answer 1
***********
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' access.log | uniq
Answer 2
************
grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" access.log | sort | uniq -c | sort -n
if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)