Linux Network Administration
Linux Network Administration
Linux Network Administration
Network Basics:
Here we are providing some idea about network and network
commands
To check IP address and IP information
#ifconfig
To set IP address
#setup
network configuration
select ethernet
give IP address, subnet mask, gateway
close
quit
quit
#service network restart
To provide DNS information:
#vi /etc/resolv.conf
(type as follows)
nameserver (DNS IP)
ex: nameserver 202.138.103.100
save&quit
To check network connectivity:
Ping: packet internet gropher
#ping server IP
To check LAN card status:
#ping 127.0.0.1
To check host name:
#hostname
To change host name:
#hostname (fqdn)
ex: #hostname station1.redhat.com
To assign new hostname permanently
#vi /etc/hosts
50***
$HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month -- output mailed to
paul
15 14 1 * *
$HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "Its 10pm" joe%Joe,%%Where are your
kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ...,
everyday"
5 4 * * sun
echo "run at 5 after 4 every sunday"
To set a crontab for an user
#crontab -e -u <user name>
ex:crontab -e -u alex
To remove a crontab for an user
#crontab -r -u <user name>
ex:crontab -r -u alex
FTP Server Configuration on Linux (Redhat or CentOS 5&6)
FTP (FILE TRANSFER PROTOCOL)
Service profile:
Type:System V-managed service
Package:vsftpd
Daemon:/usr/sbin/vsftpd
Script:/etc/init.d/vsftpd
Ports:21(ftp),20(ftp-data)
Configuration
files:/etc/vsftpd/vsftpd.conf,/etc/vsftpd/ftpusers,/etc/pam.d/vsftpd
Log:/var/log/xferlog
Related:tcp_wrappers,ip_conntrack_ftp,ip_nat_ftp
default selinux daemon= /var/ftp
vsftpd--the default redhat enterprise linux ftp server
(very secure ftp daemon)
this is designed to be a secure,stabled,fast & scalable ftp daemon.
it provides two types of access
1)ANONYMOUS ACCESS:User can login as anonymous user (without
having any account in server) to get access to ftp site. By default
CLIENT SIDE:
#ftp <server IP>
(it will prompt you for user name and password if you are login as
an anonymous user type ftp at username and nopassword is
required. If you are login as a local user name and password)
commands used at ftp
#vi /etc/samba/smb.conf
copy last 8 lines and paste under change as follows
[linux]
comment=<any data>
path=/exam(directory to be shared)
valid users=sam john
writable= yes
printable= no
hosts allow= 192.168.0.(allowable network)
here we are sharing /exam directory to sam and john they can read
write /exam from any of 192.168.0. network system by using a share
name linux
Note: we have to provide samba password for both users
#smbpasswd -a <username>
samba passwords will store under /etc/samba/smbpasswd
To check syntax of configuration file:
#testparm
#service smb restart
#mkdir /exam
#chmod 777 /exam
(here we have to set selinux context )
#chcon -t samba_share_t /exam
#setsebool -P allow_smbd_anon_write=1
select finish
type username and password
try to create some files and folders
to disconnect
rightclick on mynetwork places disconnect network drive
select drive click ok
IInd Method
start---run ---\\<serverip>\<sharedirectory>
provide username and password
to access user homedirectory
#setsebool -P samba_enable_home_dirs 1
from linux client
#smbclient //<serverip>/<myhomes> -U <username>
from windows client
start--run--\\<serverip>\<myhomes>
provide username & password
to give directory for a specific group
vi /etc/samba/smb.conf
[<sharename>]
path=<exported directory>
write list=@<group name>
ex:
[linux]
path=/exam
write list=@sales
DNS Configuration in Linux (Redhat or CentOS 6)
DNS (Domain Naming Service)
MASTER DNS :
There are two types of zonerecords
1) Forwad lookup zone
2) Reverse lookup zone
By defaults, computer connects to another computer with the
help of IP address
Forward lookup zone
-------------------It converts names into IP addresses
Reverse lookup zone
change as follows
$TTL 86400
@
IN SOA redhat.com.
42
3H
15M
1W
1D )
root.redhat.com. (
; serial (d. adams)
; refresh
; retry
; expiry
; minimum
IN NS
server1.redhat.com.
server1.redhat.com.
IN A
192.168.0.254
www254.redhat.com.
IN CNAME
server1.redhat.com.
station1.redhat.com.
IN A
192.168.0.1
www1.redhat.com.
IN CNAME
station1.redhat.com.
station2.redhat.com.
IN A
192.168.0.2
www2.redhat.com.
IN CNAME
station2.redhat.com.
xxx2.redhat.com.
IN CNAME
station2.redhat.com.
yyy2.redhat.com.
IN CNAME
station2.redhat.com.
station3.redhat.com.
IN A
192.168.0.3
www3.redhat.com.
IN CNAME
station3.redhat.com.
station4.redhat.com.
IN A
192.168.0.4
www4.redhat.com.
IN CNAME
station4.redhat.com.
station5.redhat.com.
IN A
192.168.0.5
www5.redhat.com.
IN CNAME
station5.redhat.com.
station6.redhat.com.
IN A
192.168.0.6
www6.redhat.com.
IN CNAME
station6.redhat.com.
SLAVE DNS
Master DNS Server
It is the Master Copy of all the Zone Information.
It is Read/Write copy.
Slave DNS Server
It is Slave Backup of Master zone. It is Read Only
if any error may occur to your dns server at the time the entir
network will stop.sometimes it may cause huge damage.for that one
we are createing slave dns for faulttolerance and load balancing.
we need another system which contains server o/s
steps
#yum install bind-* caching-nameserver -y
#service named start
#chkconfig named on
#cd /var/named/chroot/etc/named-rfc1912.zone
(change as follows)
copy 10 lines from 21 to 31 paste under 31
zone "redhat.com"
type slave;
file "redhat.for"
masters {192.168.0.254:};
zone "0.168.192. IN-ADDR-arpa" IN {
type slave ;
file " redhat.rev"
masters {192.168.0.254;};
save& quit
#service named restart
go to client
#i /etc/resolv.conf
nameserver 192.168.0.254
nameserver 192.168.0.1 (slave dns ip)
FORWARDERS
if you have trusted relationship with another company those
comapny users can enter into our network & our company users can
enter into their network by using this forwarders
steps
in master dns server
# vi /var/named/chroot/etc/named.conf
add aline
forwarders {192.168.10.254:};
forward only ;
};
(here 192.168.10.254 is trusted companies dns)
save & quit
#service named restart
what is apache?
Apache is a freeware & is the Most Popular& widely used Web
Server which consumes 60% of web market that can be configured
in both windows and LINUX.
ServerAdmin [email protected]
DocumentRoot /cyber
serverName xxx17.redhat.com
</VirtualHost>
save&quit
#mkdir /cyber
#cd /cyber
#vi index.html
<html>
<body bgcolor=blue>
<h1> "welcome to cyber'+'technologies" <h1>
</body>
</html>
save & quit
#chcon -R --reference=/var/www/html /cyber
#service httpd restart
to check :
open mozilla
type in url box as follows
http://xxx17.redhat.com(u will get website)
(Click On below image to large......)
##############################################
################################
TRY
THINGS
AFTER
to run scripts
#vi test.sh
#!/bin/bash
echo Content-Type:text/html
echo
-date
ls -l
echo welcome to cyber services
save&quit
#mkdir -p /var/www/hml/cgi-bin
#cp -rf test.sh /var/www/html/cgi-bin/
#cd /var/www/html/cgi-bin/
#cd ..
#chown -R apache.apache cgi-bin
#cd cgi-bin
#chmod 755 test.sh
#vi /etc/httpd/conf/httpd.conf
add a line in website data
ScriptAlias /cgi-bin "/var/www/html/cgi-bin"
save&quit
#service httpd restart
#setsebool -P httpd_tty_comm on
#setsebool -P httpd_enable_cgi 1
#setsebool -P httpd_sys_script_exec_t rw
to check:
open mozilla
type http://station17.redhat.com/cgi-bin
option nis-domain
"domain.org";
option domain-name
"redhat.com"; (domain name)
option domain-name-servers
192.168.0.254; (dns ip)
option time-offset
-18000; # Eastern Standard Time
#
option ntp-servers
192.168.1.1;
#
option netbios-name-servers
192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change
this unless
# -- you understand Netbios very well
#
option netbios-node-type 2;
range dynamic-bootp 192.168.0.1 192.168.0.20; (ip range)
default-lease-time 21600;
max-lease-time 43200;
save & quit
#service dhcpd restart
if you want to give a specific ip for a system
at the end of the file specify as follows
host station1
{ hardware ethernet 00:a0:cc:3d:45:3e
fixed address 192.168.0.10;
}
}
(here in this example we are providing 192.168.0.10 for a
specific system we have to type mac address of that system at
hardware ethernet)
save&quit
#/usr/lib/yp/ypinit -m (to make as master nis server)
ctrl+d
y (to create database)
#useradd user1
#useradd user2
#cd /var/yp
#make (to update database)
to set nisdomain name:
#nisdomainname RHCE
#vi /etc/sysconfig/network
add a new line
NISDOMAINNAME=RHCE
save&quit
#service network restart
#service ypxfrd restart
#service ypbind restart
#service yppasswdd restart
#service ypserv restart
(sharing home directories via nfs)
#yum install nfs-* -y
#service portmap start
#service portmap restart
#service nfs start
#chkconfig portmap on
#chkconfig nfs on
#vi /etc/exports
/home/u1 *.redhat.com(rw,sync)
save&quit
#service nfs restart
#exportfs -v
#exportfs -r
select Authentication
select nis
provide nis domainname&nis server ip
#setsebool -P allow_ypbind 1
#vi /etc/auto.master
add a new line
/home /etc/auto.misc
save7quit
u1 -rw,soft,intr
server1.redhat.com:/home/u1
save&quit
#service autofs restart
#getent passwd u1
# su - u1
KICKSTART Server Installation In Linux (REdhat or CentOS 6)
KICKSTART SERVER
this server is used for remote installation & Automatic installation
of o/s
steps :
keep rhel or centOS 5 or 6 dvd in cdrom
#mount /dev/cdrom /mnt
#cd /mnt
#cd Server
#rpm -ivh pykickstart-0.43-1.el5.noarch.rpm --force --aid
#system-config-kickstart-2.6.19.1-1.el5.noarch.rpm --force --aid
enter below command
#system-config-kickstart
open screen like below screen shots..
we have provided screen shots for this
save this file under /var/ftp/pub(with a name with .ks extension)
client side:
place linux bootable cd
type
linux ks:nfs://<server ip>/var/ftp/pub/<ks filename>
installation is starttttttt..........................
Send mail:
It listens mails sent by MUA's through port no.25.
in this mail server mails will be strictly check for exploids and
regenerate the packet and send to MDA.
we have two types in MDA:
1)pop3
2)IMAP
1)pop3:(postoffice protocol 3 port no.110)
mails are in /var/spool/mail
The pop3 connect to server with port no.110 and downloads
/var/spool/mail/U1 and the clients every mail and move it to the
client p.c(don't have backup)
The entire mails of user(U1) are downloaded into client system. It
any damage had done to the client system. I want to get back.
2)IMAP:
From the client it connects to port no.143 and get the mails of the
user(one copy) and it doesn't remove original file when ever the
damage occurs in client p.c. We can download another copy from
server.
pop3--> moves original mails to the client
IMAP--> It send only one copy of the mails to the client
to check:
add 2users login as one user & send mail to another user
then login as second user type mail
2nd method
as root: mutt -f {[email protected]}
yes
provide mahesh password
O
tocheck :
to check:
add an user send mail to that user from remote system
#############################################
SSL Certification (Secure Socket Layer)
by using ssl certification we can encrypt the data transfer between
one user to another user or one mailserver to another mailserver
#vi /etc/dovecot.conf
(line no 87 & 88)
#ssl_cert_file = /etc/pki/dovecot/certs/dovecot.pem
#ssl_key_file = /etc/pki/dovecot/private/dovecot.pem (remove # for
two lines)
save&quit
#make -C /etc/pki/tls/certs dovecot.pem
provide country,state,city,organization,server,user info (user must
not root)
#cp /etc/pki/tls/certs/dovecot.pem /etc/pki/tls/private
Pre-Configuration Requirements
Assign hostname node01 to primary node with IP
address 192.168.0.20 to eth0.
Assign hostname node02 to slave node with IP
address 192.168.0.21.
Note: on node01
#uname -n
must return node01.
On node02
#uname -n
must return node02.
192.168.0.22 is the virtual IP address that will be used for our
Apache webserver (i.e., Apache will listen on that address).
Configuration:
1. Download and install the heartbeat package. In our case we are
using CentOS/RHEL so we will install heartbeat with yum command:
auth 2
2 sha1 test-ha
Change the permission of the authkeys file:
#chmod 600 /etc/ha.d/authkeys
5. Moving to our second file (ha.cf) which is the most important. So
edit the ha.cf file with vi:
#vi /etc/ha.d/ha.cf
#vi /etc/httpd/conf/httpd.conf