Tuesday, March 26, 2013

Monitoring Authentication Attempts on Cisco Routers with Syslog

Source: http://aaronwalrath.wordpress.com/2010/06/01/monitoring-authentication-attempts-on-cisco-routers-with-syslog/

One of great things about the syslog logging standard is the capability to collect system notifications from a variety of network hosts and direct them to a central store for analysis.  In this demo I will configure a Cisco router to log system messages using syslog to a central Linux server.  Specifically I am interested in logging authentication attempts to the router.
My preferred syslog daemon that I will be running on my Linux syslog server is rsyslog.  There are also many syslog servers available for Windows if you choose to go that route.  Kiwi is one with a nice interface but the full featured version is payware. Your choice of a syslog server to collect your messages should be immaterial to this discussion as the configuration steps should be the same on a Cisco router.

Configure Syslog Server to Accept Messages
To start, we’ll make sure that the syslog server is configured to accept messages from the IP address of your router.  This should be the IP of the interface on the router that is closest to the syslog server.  For example, suppose the router has an external and an internal interface.  Our syslog server is on the same LAN that the internal interface is connected to.  The syslog server should be configured to accept messages from the IP address of the internal interface.  We also have the option to manually configure the interface the syslog messages are sourced from.
The syslog standard sends log messages identified with a certain facility and severity.  Generally the facility is used to identify the message as coming from a particular program or service.  This has more use when the source of the syslog messages is a full blown computer server.  In the case of Cisco routers by default syslog messages are sent marked as coming from the “local7″ facility, so we need to make sure that the syslog server accepts messages from this facility.  The source facility can be changed if you so desire.
In addition, syslog messages have a severity attached which gives information on the priority or urgency of the message.  If you are familiar with syslog you know that higher numbers represent lower severity levels.  Here is a list of the minimum severity levels that a Cisco router can be configured with which to send messages to the syslog server.

Router(config)#logging trap ?
<0-7>          Logging severity level
alerts         Immediate action needed           (severity=1)
critical       Critical conditions               (severity=2)
debugging      Debugging messages                (severity=7)
emergencies    System is unusable                (severity=0)
errors         Error conditions                  (severity=3)
informational  Informational messages            (severity=6)
notifications  Normal but significant conditions (severity=5)
warnings       Warning conditions                (severity=4)
 
Configure Cisco Router with Secret Passwords
First let’s enter global config mode.

Router#conf t
 
Now we need to make sure that we have a secret password set to enter enable mode.  I’ll use the “enable secret” command to encrypt the password using the type 5 MD5 hash algorithm which is much more secure than the older type 7 encryption.

Router(config)#enable secret EnablePassword
 
Now we’ll set up username authentication.  This needs to be turned on or our authentication attempts will not be logged.  Logging of authentication does not appear to work if you only use passwords set directly on the virtual telnet/ssh terminal lines.

Router(config)#username aaron secret MyPassword
 
We need to configure our telnet/ssh terminal lines to use local username authentication.

Router(config)#line vty 0 4
Router(config-line)#login local
Router(config-line)#exit
 
Configure Logging Options
Now we’ll set the router to direct messages to be logged to the IP address or hostname of our syslog server host.

Router(config)#logging 192.168.10.51
 
We can set the minimum severity level that log messages need to be if they are logged to the syslog server. The minimum level for logging failed authentication attempts is warning (4) and for successful authentications is notifications (5).  To capture both I will configure the minimum level to be notifications. Dial this back to warnings and above if there are too many messages being forwarded to your server, but remember that the successful logins will no longer be logged.

Router(config)#logging trap notifications
 
I’ll choose to activate login checking for both successful and failed login attempts.  Specifying “log” will generate the syslog messages.  Optionally we can have the router generate a log after a certain number of attempts, but in this case I’ll log them all.

Router(config)#login on-success log
Router(config)#login on-failure log
 
We also need to set up a quiet mode time period. Logging of failed logins will not work without this. The “login block-for” command will create an ACL for a certain period of time that will as the name suggests block logins after a certain number of failed attempts. In this case logins will be disabled for 120 seconds if there are 3 failed attempts within a 60 second time span. This will also work well for deterring a brute force attack on the router.

Router(config)#login block-for 120 attempts 3 within 60
 
Optional Logging Parameters
As I mentioned at the beginning by default the syslog messages sent by the router will appear as coming from the interface closest to the syslog server. If you want to change this behavior you can manually specify the interface the messages appear to come from.
 
Router(config)#logging source-interface FastEthernet0/0
 
We can also activate a delay which will slow login attempts. In this case there will be a 5 second delay between when a bad username/password combo is entered and when the next login prompt is presented.

Router(config)#login delay 5
 
That should do it. You can now test a successful or failed login attempt and the messages should show up on the syslog server!

How to configure syslog server in Linux

Source: http://computernetworkingnotes.com/linux-network-administrations/syslog-server.html

Sample Exam question:- You are a System administrator. Using Log files very easy to monitor the system. Now there are 40 servers running as Mail, Web, Proxy, DNS services etc. Your task is to centralize the logs from all servers into on LOG Server. How will you configure the LOG Server to accept logs from remote host ?

Answer with Explanation

An important part of maintaining a secure system is keeping track of the activities that take place on the system. If you know what usually happens, such as understanding when users log into your system, you can use log files to spot unusual activity. You can configure what syslogd records through the /etc/syslog.conf configuration file.
The syslogd daemon manages all the logs on your system and coordinates with any of the logging operations of other systems on your network. Configuration information for syslogd is held in the /etc/syslog.conf file, which contains the names and locations for your system log files.
By Default system accept the logs only generated from local host. In this example we will configure a log server and will accept logs from client side.
For this example we are using two systems one linux server one linux clients . To complete these per quest of log server Follow this link
Network configuration in Linux
  • A linux server with ip address 192.168.0.254 and hostname Server
  • A linux client with ip address 192.168.0.1 and hostname Client1
  • Updated /etc/hosts file on both linux system
  • Running portmap and xinetd services
  • Firewall should be off on server
We suggest you to review that article before start configuration of log server. Once you have completed the necessary steps follow this guide.
Check syslog, portmap, xinetd service in system service it should be on

 #setup Select  System service from list [*]portmap [*]xinetd [*]syslog 
 
Now restart xinetd and portmap service
service restart

To keep on these services after reboot on then via chkconfig command
chkconfig

After reboot verify their status. It must be in running condition

service status

Now open the /etc/sysconfig/syslog file
vi syslog

and locate SYSLOGD_OPTIONS tag
syslog

add -r option in this tag to accepts logs from clients
syslog editing
-m 0 disables 'MARK' messages.
-r enables logging from remote machines
-x disables DNS lookups on messages recieved with -r

After saving file restart service with service syslog restart command



service syslog restat

 

On Linux client

ping from log server and open /etc/syslog.conf file
syslog.conf

Now go to the end of file and do entry for serve as user.* @ [ server IP] as shown in image
syslog.conf editing

After saving file restart service with service syslog restart command
service syslog restart

Now restart the client so it can send log entry to server. ( Note that these logs will generate when client boot, so do it restart not shutdown)




reboot

Check clients log on Log server

To check the message of client on server open
less messages

In the end of this file you can check the log from clients
messages file

Sunday, March 10, 2013

Reading queue

http://docstore.mik.ua/orelly/networking_2ndEd/ssh

http://www.ibm.com/developerworks/library/l-radius/

http://en.tldp.org/HOWTO/LDAP-HOWTO/index.html

http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch05_:_Troubleshooting_Linux_with_syslog#.UVUP5VtNulA

https://sites.google.com/site/openldaptutorial/Home/openldap---beginners/what-s-needed-to-start

# FreeRadius + WLAN
http://www.linuxjournal.com/article/8151?page=0,0

Linux
http://ceata.org/~tct/resurse/utlk.pdf
http://www.tldp.org/guides.html
http://www.tldp.org/HOWTO/HOWTO-INDEX/categories.html
http://www.tldp.org/sorted_howtos_full.html
http://linuxreviews.org/beginner/index.html.en
http://www.kroah.com/lkn/
http://lwn.net/
http://www.ibm.com/developerworks/linux/
http://www.linuxfromscratch.org/
http://kernelnewbies.org/KernelProjects
http://www.amazon.com/dp/0201612437/?tag=stackoverfl08-20
http://www.ibm.com/developerworks/library/l-linux-kernel/

http://www.tldp.org/LDP/tlk/tlk.html

Certificate and Crypto
http://en.wikipedia.org/wiki/Initialization_vector
http://en.wikipedia.org/wiki/X.509
http://en.wikipedia.org/wiki/Root_certificate
http://en.wikipedia.org/wiki/Chosen-ciphertext_attack
http://en.wikipedia.org/wiki/Public_key_certificate
http://en.wikipedia.org/wiki/Certificate_authorities
http://en.wikipedia.org/wiki/Cipher_suite

RSA
http://en.wikipedia.org/wiki/Primality_test
http://www.inf.pucrs.br/~calazans/graduate/TPVLSI_I/RSA-oaep_spec.pdf

Blogs
http://www.thoughtcrime.org/blog/
http://www.techrepublic.com/blog/
http://theoatmeal.com/blog/
http://www.theguardian.com/
https://www.schneier.com