Sunday, November 25, 2012

How to setup VLAN on CISCO routers

It is assumed that:
- you are into router as user with full rights – level 15 – ssh, telnet or console
- You just want to route a specific range of IPs through one interface
- You will not use STP / Trunks on that VLAN
- Physical interface is FastEthernet 4
a1) Setup VLAN
cisco1#configure terminal
cisco1(config)#interface vlan4
cisco1(config-if)# ip address 192.168.1.1 255.255.255.0
cisco1(config-if)#exit
cisco1(config)#exit
cisco1#write
a2) Link VLAN and physical interface
cisco1#configure terminal
cisco1(config)#interface FastEthernet4
cisco1(config-if)#speed 100
cisco1(config-if)#no cdp enable
cisco1(config-if)#spanning-tree portfast
cisco1(config-if)#switchport access vlan 4
(Will you receive error the see b), solve the issue and come back )
cisco1(config-if)#exit
cisco1(config)#exit
cisco1#write
a3) Create route
cisco1#configure terminal
cisco1(config)ip route 192.168.1.0 255.255.255.0 vlan4
cisco1(config)#exit
cisco1#write
a4) Create access list
Use by your own access-list command
b) Error when try to add vlan4
It is possible to get this error :
“..Access VLAN 4 does not exist. Please add it to vlan database”
It may help to fix this problem:
It is assumed that:
-you are into router as user with full rights – level 15 – ssh, telnet or console
-do not go to configure menu
cisco1#vlan database
cisco1(vlan)#vlan 4
VLAN 4 added
….
….
cisco1(vlan)#write

How to Create and Delete VLAN on Cisco Catalyst Switch

One of the typical configuration activities you’ll perform on a Cisco Switch is to manipulate VLANs.
VLAN stands for Virtual Local Area Network.
In one physical cisco switch, you can create multiple VLANs that connects to different network.
For example, a VLAN for 10.10.191.0 network, a VLAN for 10.10.192.0 network, and a VLAN for 10.10.193.0 network. All three of these can be configured in the same physical switch.

While these commands were tested on a cisco catalyst switch 3750 series, similar commands (may be with slight variation to the port number format) should work on all cisco switches.

Create VLAN on Cisco Switch

If you are planning to have only one network in your whole switch (for example, 10.10.192.0). i.e All the ports in the switch will be connected to the 10.10.192.0 network, then you don’t need to create a VLAN, just use the default VLAN 1.
Every switch comes with the default VLAN 1 as shown below. In this example, all the ports in this switch ( from 1 through 8 ) are part of the default VLAN 1.

#show vlan VLAN Name Status Ports ---- -------------------------------- --------- ------------ 1 default active Gi1/0/1, Gi1/0/2, Gi1/0/3, Gi1/0/4 Gi1/0/5, Gi1/0/6, Gi1/0/7, Gi1/0/8
In the following example, we are creating 192 VLAN network (for 10.10.192.0 network). While creating a VLAN you also need to specify the range of ports from the switch that needs to be part of this VLAN network.
In this example, ports 3 through 6 are configured as part of 192 VLAN network.
config t
vlan 192
interface range gigabitEthernet 1/0/3-6
switchport access vlan 192
exit
In the above commands:
  • config t – Goes into the configuration mode
  • vlan 192 – Creates VLAN 192
  • interface range gigabitEthernet 1/0/3-6 – Indicates that the port numbers 3 through 6 are assigned to this VLAN
  • swithport access vlan 192 – Indicates that the access to the vlan 192 is enabled
Apart from providing the access to the vlan 192 for the port numbers 3 through 6, you can also specify the following additional switchport configuration parameters (for example, nonegotiate and mode access)
config t
interface range gigabitEthernet 1/0/3-6
switchport mode access
switchport nonegotiate
exit
Once you’ve created a VLAN verify it as shown below,
#show vlan

VLAN Name       Status    Ports
---- -------------------------------- --------- ------------
1    default    active    Gi1/0/1, Gi1/0/2, Gi1/0/7, Gi1/0/8
192  VLAN0192   active    Gi1/0/3, Gi1/0/4, Gi1/0/5, Gi1/0/6
On a side note, it is always recommended that you upgrade ISO image on your cisco switch to the latest version.

Delete VLAN on Cisco Switch

You might want to delete a VLAN, if you are planning to switch the ports assigned to VLAN 192 to a different VLAN. Or, you might want to delete a VLAN, just because you’ve created it by mistake.
Let us assume that you want to delete the VLAN 192 (ports 3 though 6) that you just created.
Deleting a VLAN is as simple as assigning the default VLAN 1 to the ports that are part of the VLAN you want to delete, and delete the VLAN.
i.e If you want to delete VLAN 192, assign VLAN 1 to the ports 3 through 6, and just delete the VLAN 192.
First, assign the default VLAN 1 to ports 3 though 6 as shown below.
interface range gigabitEThernet 1/0/3-6
switchport access vlan 1
exit
Next, delete the vlan itself as shown below.
no vlan 192
Finally, verify that the VLAN 192 got deleted as shown below.
#show vlan

VLAN Name       Status    Ports
---- -------------------------------- --------- ------------
1    default    active    Gi1/0/1, Gi1/0/2, Gi1/0/3, Gi1/0/4
                          Gi1/0/5, Gi1/0/6, Gi1/0/7, Gi1/0/8
As a final note, if you don’t know what you are doing, do not execute any of the above commands on production switch, as you might bring down your network. Do this only on a test system, where you can play around and learn how to manipulate VLANs on cisco switch.

Linux Install Google Chrome Browser [ Ubuntu, Suse, Debian, Fedora ]

How do I install Google Chrome browser under Linux operating systems? How do I install google-chrome-beta_current_amd64.deb or google-chrome-beta_current_x86_64.rpm file under Linux?

Google Chrome is another web browser which runs web pages and applications with lightning speed due to its superior JavaScript rendering engine.

Step #1: Download Chrome Browser

Visit this url and download the package for Linux desktop.
Fig.01: Please select your download package format
Fig.01: Please select your download package format
Save .deb or .rpm package at /tmp directory.

Step #2: Install Google Chrome Browser

Open the terminal and type the following command to install the same under Debian or Ubuntu Linux:
cd /tmp
sudo dpkg -i google-chrome-beta_current_amd64.deb
If you are using Suse or Fedora Linux, enter:
 
rpm -ivh google-chrome-beta_current_x86_64.rpm

How Do I Run Google Chrome Browser?

You can launch Google Chrome browser by visiting the Application > Internet > Google Chrome. Or type the following command at a bash prompt:
google-chrome &
Fig.02: Linux Google Chrome In Action
Fig.02: Linux Google Chrome In Action

Removing a Directory In Linux

How do I remove a directory in Linux using the shell prompt?

You can use the following commands:
[a] rmdir command : remove empty directories.
[b] rm command : remove files or directories.

Linux Delete a Directory Command Examples

The syntax is as follows:
 
rmdir dirName
 
Login using the ssh client or open a command-line terminal (select Applications > Accessories > Terminal under Gnome desktop), than type the following command to delete empty directory called foo:
 
rmdir foo
 
By default, the rm command does not remove directories. Use the --recursive (-r or -R) option to remove each listed directory, too, along with all of its contents including all files and subdirectories:
 
rm -r documents
 
You can also specifiy the full path:
 
rm -r /data/dir1
rm -r /home/vivek/dir2
rmdir $HOME/mp3
 

Find: Ram Size in Linux

How do I find out my RAM size under Linux operating systems?

You can use the following commands to find out actual RAM size under Linux operating systems.

/proc/meminfo file

Type the following command to view total installed ram and used ram, enter:
$ less /proc/meminfo
OR
$ cat /proc/meminfo
Sample outputs:
MemTotal:      8177444 kB
MemFree:       1528304 kB
Buffers:        353152 kB
Cached:        2301132 kB
SwapCached:          0 kB
Active:        5250532 kB
Inactive:       983832 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:      8177444 kB
LowFree:       1528304 kB
SwapTotal:     1052248 kB
SwapFree:      1052248 kB
Dirty:            1796 kB
Writeback:           0 kB
AnonPages:     3579784 kB
Mapped:         106548 kB
Slab:           295500 kB
PageTables:      82956 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   5140968 kB
Committed_AS:  4959796 kB
VmallocTotal: 34359738367 kB
VmallocUsed:    263900 kB
VmallocChunk: 34359473347 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB

free Command

The free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel:
$ free -m
OR
$ free -g
Sample outputs:
             total       used       free     shared    buffers     cached
Mem:          7985       6466       1519          0        344       2249
-/+ buffers/cache:       3871       4114
Swap:         1027          0       1027

Options

From the man page:
       The -b switch displays the amount of memory in bytes; the -k switch (set by default) displays it in kilobytes; the -m switch displays it in megabytes.
       The -t switch displays a line containing the totals.
       The -o switch disables the display of a "buffer adjusted" line.  If the -o option is not specified, free subtracts buffer memory from the used memory and adds it to the free memory reported.
       The -s switch activates continuous polling delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolution delay times.

vmstat command

The vmstat command can display memory statistics including additional information about processes, paging, block IO, traps, and cpu activity. Type the following command:
$ vmstat -s
Sample outputs:
      8177444  total memory
      6655064  used memory
      5251360  active memory
       989748  inactive memory
      1522380  free memory
       353316  buffer memory
      2308588  swap cache
      1052248  total swap
            0  used swap
      1052248  free swap
     38412570 non-nice user cpu ticks
       100117 nice user cpu ticks
      5153239 system cpu ticks
    271927635 idle cpu ticks
        45717 IO-wait cpu ticks
        63003 IRQ cpu ticks
       564561 softirq cpu ticks
            0 stolen cpu ticks
      1846153 pages paged in
    158053429 pages paged out
            0 pages swapped in
            0 pages swapped out
   1226003322 interrupts
    740976858 CPU context switches
   1295805340 boot time
       659452 forks

top Command

The top command provides a dynamic real-time view of a running system including a quick summary information about RAM, CPU as well as a list of tasks currently being managed by the Linux kernel. Type the following command:
$ top
Sample outputs:
Fig.01: Display Linux RAM Size with the top commad
Fig.01: Display Linux RAM Size with the top commad

GUI System Information Tool

The System Monitor Gnome application enables you to display basic system information and monitor system processes, usage of system resources, and file systems. You can start System Monitor in the following ways:
Click on System menu > Choose Administration > System Monitor
Or type the following command:
$ gnome-system-monitor
Sample outputs:
Fig.02: Linux view installed memory with the System Monitor application
Fig.02: Linux view installed memory with the System Monitor application

dmidecode Command

The dmidecode command is used for dumping a computer's DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system's hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware. To see complete information about memory, enter:
$ sudo dmidecode --type memory
Sample outputs:
# dmidecode 2.9
SMBIOS 2.6 present.
Handle 0x1000, DMI type 16, 15 bytes
Physical Memory Array
 Location: System Board Or Motherboard
 Use: System Memory
 Error Correction Type: None
 Maximum Capacity: 16 GB
 Error Information Handle: Not Provided
 Number Of Devices: 4
Handle 0x1100, DMI type 17, 28 bytes
Memory Device
 Array Handle: 0x1000
 Error Information Handle: Not Provided
 Total Width: 64 bits
 Data Width: 64 bits
 Size: 4096 MB
 Form Factor: DIMM
 Set: None
 Locator: DIMM_A
 Bank Locator: Not Specified
 Type: 
 Type Detail: Synchronous
 Speed: 1333 MHz (0.8 ns)
 Manufacturer: 80CE000080CE
 Serial Number: 45AAFB60
 Asset Tag: 01101800
 Part Number: M471B5273CH0-CH9
Handle 0x1101, DMI type 17, 28 bytes
Memory Device
 Array Handle: 0x1000
 Error Information Handle: Not Provided
 Total Width: 64 bits
 Data Width: 64 bits
 Size: 4096 MB
 Form Factor: DIMM
 Set: None
 Locator: DIMM_B
 Bank Locator: Not Specified
 Type: 
 Type Detail: Synchronous
 Speed: 1333 MHz (0.8 ns)
 Manufacturer: 80CE000080CE
 Serial Number: 45AAFDAD
 Asset Tag: 01101800
 Part Number: M471B5273CH0-CH9
Handle 0x1102, DMI type 17, 28 bytes
Memory Device
 Array Handle: 0x1000
 Error Information Handle: Not Provided
 Total Width: 64 bits
 Data Width: 64 bits
 Size: No Module Installed
 Form Factor: DIMM
 Set: None
 Locator: DIMM_C
 Bank Locator: Not Specified
 Type: 
 Type Detail: Synchronous
 Speed: Unknown
 Manufacturer:
 Serial Number:
 Asset Tag:
 Part Number:
Handle 0x1103, DMI type 17, 28 bytes
Memory Device
 Array Handle: 0x1000
 Error Information Handle: Not Provided
 Total Width: 64 bits
 Data Width: 64 bits
 Size: No Module Installed
 Form Factor: DIMM
 Set: None
 Locator: DIMM_D
 Bank Locator: Not Specified
 Type: 
 Type Detail: Synchronous
 Speed: Unknown
 Manufacturer:
 Serial Number:
 Asset Tag:
 Part Number:

Shutdown Linux Server

How do I shutdown my Linux server or computer using command line options?

The shutdown command bring the Linux based system or server down. Only the superuser (root user) can shut the system down. Open a command-line terminal (select Applications > Accessories > Terminal), or login to remote server using the ssh command, and then type the following command to shutdown the Linux server immediately:
# shutdown -h now
The shutdown command arranges for the system to be brought down in a safe way i.e. it will remove power from a servers's main components in a controlled way. All logged-in users are notified that the system is going down and, within the last five minutes of TIME, new logins are prevented. TIME may have different formats, the most common is simply the word now which will bring the system down immediately. Other valid formats are +m, where m is the number of minutes to wait until shutting down and hh:mm which specifies the time on the 24hr clock format. In this example, shutdown the system in 5 minutes:
# shutdown -h +5
Sample outputs:
Broadcast message from vivek@vivek-laptop
 (/dev/pts/0) at 16:57 ...
The system is going down for halt in 5 minutes!

-h (halt) option

The -h option requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system:
# shutdown -h 6:30
OR
# shutdown -h 20:00
The above will turn the server off at 8:00 PM.

-H option

The -H option requests that the system be halted after it has been brought down:
# shutdown -H +10

-P (power off) option

The -P option requests that the system be powered off after it has been brought down:
# shutdown -P +10
Sample outputs:
Broadcast message from vivek@vivek-laptop
 (/dev/pts/1) at 17:00 ...
The system is going down for power off in 10 minutes!
You can type the poweroff command:
# poweroff

How do I Cancel The System Shutdown?

You can press [CTRL+C] or type the following command to cancel a running shutdown:
# shutdown -c
Sample output (the command was issued on tty01):
shutdown -h +10
Broadcast message from vivek@vivek-laptop
 (/dev/pts/1) at 17:04 ...
The system is going down for halt in 10 minutes!
shutdown: Shutdown cancelled

How Do I Display Custom Shutdown Message?

Use the following syntax:
# shudown -h TIME "YOUR-MESSAGE-HERE"
In this example, shutdown the server for hard disk replacement:
# shutdown -h +5 "The server is going down for 'harddisk replacement'"
Sample outputs:
Broadcast message from vivek@vivek-laptop
 (/dev/pts/0) at 17:11 ...
The system is going down for halt in 5 minutes!
The server is going down for 'harddisk replacement' 

Linux Server Shutdown and Log Files

The following two files are updates when the system goes down for the poweroff / halt or reboot operations:
  1. /var/run/utmp - Where the current runlevel will be read from; this file will also be updated with the runlevel record being replaced by a shutdown time record.
  2. /var/log/wtmp - A new runlevel record for the shutdown time will be appended to this file.

How Do I Display the System Shutdown Time?

Use the last command as follows:
# last -x shutdown
Sample outputs:
shutdown system down  2.6.18-238.el5   Sat Jan 22 06:40 - 05:51 (10+23:10)
shutdown system down  2.6.18-194.32.1. Sun Jan 16 13:26 - 06:40 (5+17:14)
shutdown system down  2.6.18-194.26.1. Sat Jan  8 04:17 - 13:25 (8+09:08)
shutdown system down  2.6.18-194.26.1. Mon Nov 15 16:46 - 04:16 (53+11:30)
shutdown system down  2.6.18-194.17.1. Wed Oct 27 01:00 - 02:00 (18+02:00)
shutdown system down  2.6.18-194.8.1.e Thu Aug 12 00:18 - 09:02 (20+08:43)
shutdown system down  2.6.18-194.8.1.e Wed Jul 14 14:07 - 16:19 (5+02:12)
shutdown system down  2.6.18-194.8.1.e Tue Jul 13 20:21 - 14:06  (17:45)
shutdown system down  2.6.18-194.8.1.e Tue Jul 13 12:13 - 20:20  (08:07)
shutdown system down  2.6.18-194.8.1.e Tue Jul 13 11:48 - 12:13  (00:24)
shutdown system down  2.6.18-194.8.1.e Tue Jul 13 10:38 - 11:48  (01:09)
shutdown system down  2.6.18-194.el5   Tue Jul 13 10:32 - 10:38  (00:05)
wtmp begins Tue Jul 13 10:26:19 2010

Show Linux Partitions Command

How do I display or show a list of all hard disk drive partitions under Linux operating systems?

Your PC or x86 Linux server hard disk drive can be divided into one or more logical disks called partitions. This division is described in the partition table found in sector 0 of the disk. The fdisk command can be used to view the list of the partition tables for the specified devices. Open a command-line terminal (select Applications > Accessories > Terminal), and then type:
$ sudo fdisk -l
OR
# fdisk -l
Sample outputs:
Disk /dev/sda: 73.2 GB, 73284976640 bytes
255 heads, 63 sectors/track, 8909 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1580    12586927+  83  Linux
/dev/sda3            1581        8778    57817935   fd  Linux raid autodetect
/dev/sda4            8779        8909     1052257+   5  Extended
/dev/sda5            8779        8909     1052226   82  Linux swap / Solaris
Disk /dev/sdb: 73.2 GB, 73284976640 bytes
255 heads, 63 sectors/track, 8909 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        7052    56645158+  fd  Linux raid autodetect
Disk /dev/md0: 58.0 GB, 58004537344 bytes
2 heads, 4 sectors/track, 14161264 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
No devices are given, those mentioned in /proc/partitions (if that exists) are used. But you can specify device as follows:
$ sudo fdisk -l /dev/sda
You can also see the list of paritions by typing the following command:
$ cat /proc/partitions
Sample outputs:
major minor  #blocks  name
   8     0   71567360 sda
   8     1     104391 sda1
   8     2   12586927 sda2
   8     3   57817935 sda3
   8     4          1 sda4
   8     5    1052226 sda5
   8    16   71567360 sdb
   8    17   56645158 sdb1
   9     0   56645056 md0