Showing posts with label RHCSA. Show all posts
Showing posts with label RHCSA. Show all posts

Thursday, December 22, 2011

Basic Network Configuration of Linux System

Main configuration files

  • /etc/hostname : contains name of host machine ; give the hostname in this file to permanently change the hostname. Otherwise, use "hostname" command to change the hostname temporarily

#hostname client1.ciscofriend.comLinux Basic Networking

  • /etc/hosts : Contains Name to IP mapping in the local system
  • /etc/resolv.conf : Contains address of DNS servers
  • /etc/nsswitch.conf : Determines order in which name resolution take place in system. We can change the order in this file  to configure  system to check first DNS then host file etc.

Redhat Network Files

  • /etc/sysconfig/networks-scripts/ifcfg-eth0 : IP address information stored here
  • /etc/sysconfig/network : This file contains the hostname; but this is a non standard way, Ubuntu/Debain is using the correct way

Debian/Ubuntu Network files

  • /etc/network/interfaces

Commands to configure network

  • Ifconfig : dipsplay and configure network interfaces

#ifconfig eth0 192.168.1.22  (set the IP of Ethernet 0 interface to 192.168.1.22)

#ifconfig eth0 netmask 255.255.255.0  (set the subnet mask)

#ifconfig eth0 hw ether 00:00:00:00:00:11 (To change the MAC address of eth0 interface)

#route add default gw 192.168.1.1  (To change the default gateway)

  • Ifup : configure and activate network interface based on config files

#ifup eth0

  • Ifdown- disable configured network interfaces

#ifdown eth0

Wednesday, December 21, 2011

Commonly Using Port Numbers

Port TCP UDP Description
20 x   FTP-Data
21 x   FTP (login access)
22 x x SSH
23 x   Telent
25 x   SMTP (Mail, MTA)
49 x   TACACS+
53 x x DNS
69   x TFTP
80 x x HTTP (Web)
110 x x POP3 (email); generally uses TCP)
119 x   NNTP (Usenet News)
123   x NTP
139 x x NetBIOS (Microsoft)
143 x x IMAP
161 x x SNMP (Network Monitor)
179 x   BGP
443 x x HTTPS
465 x   SMTPS (Secure Mail over SSL)
993 x x IMAP (Secure IMAP over SSL)
995 x x POP3S (Secure POP3 over SSL)
1645,1812   x RADIUS Authentication
1646,1813   x RADIUS Accounting

Tuesday, December 6, 2011

HTTP installation of RHEL6/CentOS/SL-6

On Server

  • Install apache server (HTTP server) using yum apache webserver5

#yum install httpd

Note: if you don’t know how to setup yum you can see this post

  • Mount the DVD (which is also specified in the above post) and copy the content to /var/www/html/cdrom

For example, if DVD is mounted to /cdrom directory, then

#cp –vrf /cdrom /var/www/html/

Note: alternatively, we can mount the DVD directly to the web accessible, /var/www/html/ path

  • Now, start the http service

#service httpd start

  • Check the setting using the web browser with server’s IP. If server IP is 192.168.1.10 then use http://192.168.1.10/cdrom 

Note: if firewall is on, turn off firewall or add exception to port 80

 

On the installation system

  • Download boot.iso from redhat.

Note: boot.iso not ship with DVD now. So we need to download it from redhat site. Alternatively we can use CentOS netinstall.iso, both are same

  • CentOS 6 netinstall.iso is available here:  redhat logo

http://mirrors.hns.net.in/centos/6.0/isos/x86_64/CentOS-6.0-x86_64-netinstall.iso

http://mirrors.hns.net.in/centos/6.0/isos/i386/CentOS-6.0-i386-netinstall.iso

  • Write the the image to a CD and put it in the CD-ROM drive. Alternatively, we can use USB key. It is explained here.
  • Reboot the system and supply the following boot string at the end of current line without quotes by pressing tab

'linux repo=http://192.168.1.10/cdrom ip=192.168.1.20 netmask=255.255.255.0 gateway=192.168.1.1 dns=192.168.1.1'

Note: if more than one DNS server is available specify it using comma. DNS server address is optional. Here IP is the address of the current system

Monday, December 5, 2011

Making CD/DVD as yum repository

1. Mount the CD/DVD to a folder

# mkdir /cdromcdrom

# mount -t iso9660 -o ro /dev/cdrom /cdrom

2. Create a repository file for that folder in /etc/yum.repos.d/

# nano /etc/yum.repos.d/cdrom.repo

Now add the following content to the file and save the file

[cdrom]
name=CD repo
baseurl=file:///cdrom
gpgcheck=0

Now we can install software using the yum command

Saturday, December 3, 2011

Disable login of all users except root

sudo touch /etc/nologin

Note: Now, only root can login to the system. Login as root and delete that file to allow other users to login

rm /etc/nologin

Saturday, November 26, 2011

Network Time Protocol (NTP) configuration

One time updatentp

If you want to synchronize with NTP server just now, then execute the following command:

$ sudo ntpdate 1.in.pool.ntp.org

Here 1.in.pool.ntp.org is the NTP server we are synchronizing with. You can find closer NTP server to your country from www.pool.ntp.org

NTP automatic synchronization through service

$ sudo apt-get install ntp

$ sudo service ntp start

If you want to synchronize with more closer NTP servers, then edit ntp.conf file by replacing the existing NTP servers with closer servers.

$ sudo nano /etc/ntp.conf

now change ntp servers if you want and save the file and restart the service

$ sudo service ntp restart

NOTE: if you are running other distributions than Ubuntu, then login as root and run the command without “sudo” in front of it

Wednesday, November 23, 2011

Linux/Unix file system Hierarchy

/ root directory
/bin command binaries
/boot boot loader
/dev devices
/etc configuration files
/home user home directories (MacOSX uses ‘USERS’ directory to store home directories of users)
/lib library files for executables
/proc virtual file system (information about current running system)
/root root user home directory
/sbin system binaries (binaries that should run by system not users)
/tmp temporary file storage
/usr user binaries , often read only; (install by user like open office)
/var variable files, log, mail
/media mount place for removable media

/mnt

legacy location for removable media

Sunday, November 6, 2011

createrepo rpm installation problem – solution

Error:

[root@server1 Packages]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
warning: createrepo-0.9.8-4.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
    deltarpm is needed by createrepo-0.9.8-4.el6.noarch
    python-deltarpm is needed by createrepo-0.9.8-4.el6.noarch

Solution:

rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm deltarpm* python-deltarpm*

Saturday, October 29, 2011

Preparing a bootable RHEL6 Bootable Pen drive

  1. Go to images sub directory of RHEL DVD
  2. If the location of the pen drive is /dev/sdd, write the image to pen drive using the following command:

#dd if=efidisk.img of=/dev/sdd

Note: This command will overwrite all existing data on the drive

Tuesday, July 20, 2010

Sharing Folder between Linux/UNIX systems using NFS

1. Create the folder which we want to share
mkdir /nfs1
chmod 666 /nfs1
2. Share the folder by entering its details in /etc/exports file. In the /etc/exports file, enter the following:
/nfs1       192.168.1.60(rw) [This means this folder can be accessed by 192.168.1.60 in read-write mode]
/nfs2        172.30.10.0/24
3. Start service
service nfs start
ckconfig nfs on
4. Export the file (publishing):
exportfs –v
note: if we add more folder then we can update the exports using exportfs –a
5. Done!!!

How to access these shared folders from the remote 192.168.1.60 system
1. Create a corresponding directory anywhere say nfs1
mkdir /nfs1
2. Mount the remote shared directory (192.168.1.50) to that this directory
mount –t nfs 192.168.1.50:/nfs1 /nfs1
3. Use the “df –h” or “mount” command to confirm it and we are done!!!

Additional configurations
1. Allow client/remote 'root' user the ability to write to /nfs1 export
/etc/exports: (rw,no_root_squash)
2. Setup mount points so that they're available upon reboot
Edit /etc/fstab
192.168.1.50:/nfs1      /nfs1                   nfs     defaults  0 0
note : Unmount and confirm that NFS mount points will be available when the client system changes runlevels (reboots, starts, etc.) - 'mount –a'

3.  showmount -a 192.168.1.50 - shows mounts on this system (connected NFS clients)

Wednesday, July 7, 2010

DHCP installation and Configuration on RHEL5/CentOS

1. Install dhcp server
yum –y install dhcp
2. Copy the sample configuration file to /etc
cp -v /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
3. Edit the dhcp configuration file /etc/dhcpd.conf as our network details. Also  do the following
#       range dynamic-bootp 192.168.0.128 192.168.0.254; (comment this line and add as below)
        range 192.168.1.150 192.168.1.200;
note: If we dont want specific ip assignments for the hosts (reservation), comment that lines.
4. Start dhcp server
service dhcpd start
chkconfig dhcpd on
5. If we want to configure reservations for a system do as following in the /etc/dhcpd.conf file
host xp1 {
         hardware ethernet 00:0C:29:0C:55:83;
         fixed-address 192.168.1.170;
}
note : Optional 'option-*' are supported between host { } block
6. Restart the service to make the changes to effect
service dhcpd restart
7. Done!!

Notes:
1. On client system /var/lib/dhclient/dhclient-eth0.leases file contains dhcp lease information. On server /var/lib/dhcpd/dhcpd.leases contains the lease information for all clients.
2. NTP details can be given outside the subnet options to make globally available. For more information use ‘man dhcpd.conf’ command.

Thursday, July 1, 2010

Installing and configuring TFTP server in Linux (RHEL5 & Centos)


1. Install tftp server using the following command
yum -y install tftp-server
2. Open  /etc/xinetd.d/tftp file using any text editor and make 
disable                 = no
3. Start xinetd server (because tftpd is sub service of that xinetd)
service xinetd start - to start XINETD
4.  Check whether the tftp port 69 using the following command
netstat -nulp | grep 69
5. If selinux is not disabled by default, use the following command to make it disable for the tftpd service
setsebool -P tftpd_disable_trans=1 - disables SELinux for TFTPD
service xinetd restart
6. Installation of tftp server create a directory called /tftpboot where files are stored (tftp root). we must create a
blank file using touch and change permission to 666 using chmod to make it writable
touch r1-config
chmod 666 r1-config
7. Now from cisco router we can use the copy command
R1#copy run tftp://192.168.1.20/r1-config