LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-17-2019, 11:46 PM   #1
satlx
LQ Newbie
 
Registered: Mar 2019
Posts: 3

Rep: Reputation: Disabled
generate an audit log when a non-whitelist IP is trying to access


I have removed the SSH service from firewalld

Code:
firewall-cmd --zone=public --remove-service=ssh
Using rich rule I'm allowing particular IP to access SSH service

Code:
firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="192.163.14.10" service name="ssh" accept'
Now I want to generate an audit log when a non-whitelist IP is trying to access my host. The host should generate an audit log for access denied. Something like Error: Network access denied. Unauthorized IP 111.111.111.111 is trying to access my host.

I tried to find logs in /var/log but no luck.
 
Old 03-18-2019, 05:14 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,765

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Where does firewalld put it's logs?
On my server, those rejections are written to /var/log/messages.
 
Old 03-18-2019, 11:12 PM   #3
satlx
LQ Newbie
 
Registered: Mar 2019
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for the reply.


In /var/log/messages, I found, when ssh service was present in firewalld

Quote:
Mar 19 00:03:09 sshd[6628]: Accepted password for cliadmin from <ip> port 62886 ssh2
Mar 19 00:03:11 sshd[6631]: Accepted password for cliadmin from <ip> port 62888 ssh2

for the wrong it gives log

Quote:
Mar 19 00:06:15 sshd[6697]: Failed password for cliadmin from <ip> port 63004 ssh2

Now, I removed the SSH service from firewalld
Quote:
firewall-cmd --zone=public --remove-service=ssh
And try to ssh uesr@<ip-host> from machine X, will get
Quote:
error : ssh: connect to host <ip-host> port 22: No route to host
Here I'm supposed to get log message in /var/log/messages saying that
Quote:
Network access denied. Unauthorized IP machine X trying to access <ip-host>.
 
Old 03-18-2019, 11:20 PM   #4
satlx
LQ Newbie
 
Registered: Mar 2019
Posts: 3

Original Poster
Rep: Reputation: Disabled
I am able to get log messages in /var/log/messages for successful authorization and failure authorization.

I am expecting log messages when the service ssh has been removed from firewalld services.

Run following command on host X
Code:
firewall-cmd --zone=public --remove-service=ssh
Now, try to host ssh host X from host Y
Code:
ssh user@<host-x>
ssh: connect to host <host-x> port 22: No route to host

For this behavior, I'm expecting log like
Quote:
Error: Network access denied. Unauthorized IP <host-Y> is trying to access my host.
 
Old 03-19-2019, 08:45 AM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,765

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by satlx View Post
Code:
ssh user@<host-x>
ssh: connect to host <host-x> port 22: No route to host
That error says that host y can't find host x, so it can't even attempt to connect to it...there's no way that host x can log a connection attempt when no connection was made.
Check the name resolution and routing on host y.

Last edited by scasey; 03-19-2019 at 08:47 AM.
 
Old 03-27-2019, 07:20 AM   #6
Honest Abe
Member
 
Registered: May 2018
Distribution: CentOS 7, OpenSUSE 15
Posts: 420
Blog Entries: 1

Rep: Reputation: 202Reputation: 202Reputation: 202
When you are removing ssh service from firewalld, you are basically blocking off the ssh port. Hence the "no route" message.

Are you familiar with hosts.allow and hosts.deny files?

Try putting a known ip in the blacklist (hosts.deny ) and see what happens.
(I forgot the preference order for these two files, I am leaving that part on u to figure out.)

Make sure you have access to console so that you can undo changes easily.
 
1 members found this post helpful.
Old 03-27-2019, 07:32 AM   #7
dc.901
Senior Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 1,005

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
You can also use fail2ban, and it writes to its own log file so it can be easier than messages log file.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get local timestamp msg=audit(Mon Jan 21 23:47:38 2019.689:1866319) in audit.log instead of msg=audit(1548145864.461:1866430) naveen.kumar2512 Linux - Newbie 1 01-22-2019 07:24 AM
[SOLVED] Logrotate - what is rotating /var/log/audit/audit.log? veeruk101 Linux - Newbie 3 11-03-2011 07:53 PM
Generate audit log every 6 months it_guy Red Hat 2 03-11-2011 07:18 AM
[Linux Audit]: Which groups should be allowed to read audit log files? quanba Linux - Security 1 11-15-2010 10:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration