Geekyogi

A lazy geek blog

Using linux syslog for cisco logs

without comments

scenario : You have multiple routers in your network infrastructure. You need a single system to log and analyze them.  Syslog comes handy..

Enabling syslog listen port :

To enable your linux box listen to the incoming log request, you need to turn on syslogd.

Edit the file /etc/sysconfig/syslog

vi /etc/sysconfig/syslog

SYSLOGD_OPTIONS=”-m 0 -r“  #make sure -r option is turned ON

service syslog restart # To restart syslog demon

netstat -nul # To check if linux box is listening to port no.514 (syslogd)

Now We need to configure /etc/syslog.conf :

#At the bottom of the file add the following line:

local0.*                                                /var/log/router1.log

#This will log all the cisco router messages to /var/log/router1.log with

facility as: local0 and of any level/importance


Configuring cisco router for logging on linux box:

login into cisco router as privileged config mode:

Router(config)#logging 192.168.2.6 #Logging to the Linux box IP
Router(config)#logging facility local0    #Logging facility name – local0
Router(config)#logging trap 7 #logging level 7(debugging)

Note: The level represented in cisco router is opposite to linux in priority level.  For eg. level 7 of cisco represent debugging level where as level 7 in linux represent emergency level.  So its always better not to specify the level while editing sysconfig.conf.

Now you can view your cisco router logs at /var/log/router1.log. You can also setup NTP service for all the routers and linux box to syn time across the entire network.  This will help you to analyze the log messages.

Do log your comments here.. :)

Written by yogesh

January 15th, 2010 at 3:09 pm

Posted in cisco, linux

Tagged with , , , ,

Playing with file systems on Linux

with 4 comments

In this article we will play with linux file systems and learn how to create partitions.

Lets consider a scenario.. You are running an FTP server with low space on your single SCSI the disk.. You attach another SCSI disk to the board and restart your system. Here are the steps to properly partition and mount the disk.

At first you need to identify the disks Attached to the system.

fdisk -l #will display the list of Disk attached to the system.  eg. sda, sdb, etc.  It will also display the file format of the disk in use. Note: You must be logged in as root.

Once you’ve recognized the newly attached / unused disk (In this article i use /dev/sde) , We need to create partitions and file system.

[root@localhost ~]# fdisk /dev/sde #/dev/sde is the new disk to be partitioned
#<Unwanted output removed>

#At any point you could press m for help

#press n to create a new partition

Command (m for help): n

Command action

e   extended
p   primary partition (1-4)                    #press p to create a primary partition.
p

#Partition number set to 1.  There can be max of 4 primary partition.

Partition number (1-4): 1

#First cylinder for a /dev/sde1 partition.  Use default.First cylinder (1-2610, default 1): 1

# Mention the size.

Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +10G

#Modify File system to be used

Command (m for help): t

#Since there is only 1 partition on this disk.. It auto selects sde1

Selected partition 1
Hex code (type L to list codes): 83 # 83 is the hex for linux

Changed system type of partition 1 to 83

# p to print and verify the disk partitioning. Similarly many more..

#partitions can be created by following the above steps.

Command (m for help): p
Disk /dev/sde: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1        1217     9775521   83  Linux

# w to write the changes to the disk

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.

After creating the partitions, we need to overlay or format the raw partition with the file system and mount the partition.

mke2fs -j /dev/sde1 #will make inodes to partition and -j option to enable journal option.

mount /dev/sde1 /newdisk #will mount the partition sde1 to the /newdisk folder

df -h # use this command to verify the mount information

df -h /newdisk # use this command to verify the available and free space.

Now you need to make sure that the partition will auto-mount to /newdisk on reboot.

vi /etc/fstab #This file stores the mount information

#Add the following line to the end of the file fstab
/dev/sde1               /newdisk              ext3    defaults        0 0

Hope you enjoyed learning it.. :)

Written by yogesh

January 14th, 2010 at 4:40 pm

Posted in linux

Tagged with , , , , ,