My blog has moved! Redirecting...

You should be automatically redirected. If not, visit http://techienote.com and update your bookmarks.

Tech Resources

Tuesday, June 22, 2010

PXE Boot server on CentOS

This post will be helpful for linux admins who frequently installs diff linux os. PXE boot is one of the best option to start linux installation & for rescue of the other failed systems. we are using CentOS as pxe boot server.

Install tftp-server
#yum install tftp-server -y

Enable tftp server
#vi /etc/xinetd.d/tftp

service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s -vv /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
Start tftp server and mark it for system startup
#service xinetd restart
#chkconfig --level 35 xinetd on

We have to download the latest version of syslinux and build the rpm cause there are some bugs in the existing version that ships with centos.
#cd /root
#wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.86.tar.gz
#tar -zxvf syslinux-3.86.tar.gz
#cp syslinux-3.86/syslinux.spec /usr/src/redhat/SPECS/
#cd ..
#cp syslinux-3.86.tar.gz /usr/src/redhat/SOURCES

Now building the rpm
#cd /usr/src/redhat/SPECS
#rpmbuild -ba syslinux.spec

Installing rpm
#cd /usr/src/redhat/RPMS/i386
#rpm -ivh syslinux-3.86-1.i386.rpm

Copy needed files from syslinux to the tftpboot directory
#cp /usr/share/syslinux/pxelinux.0 /tftpboot
#cp /usr/share/syslinux/menu.c32 /tftpboot
#cp /usr/share/syslinux/memdisk /tftpboot
#cp /usr/share/syslinux/mboot.c32 /tftpboot
#cp /usr/share/syslinux/chain.c32 /tftpboot

Create a base directory for images. Create directories for each CentOS release you are supporting.
#mkdir -p /tftpboot/images/centos/i386/5.4
#cp /tmp/dvd-centos-54/images/pxeboot/vmlinuz /tftpboot/images/centos/i386/5.4/
#cp /tmp/dvd-centos-54/images/pxeboot/initrd.img /tftpboot/images/centos/i386/5.4/

Configure dhcp-server.
Add this to your existing or new /etc/dhcpd.conf.
Note: xxx.xxx.xxx.xxx is the IP address of your PXE server
Configuring dhcp server on centos
allow booting;
allow bootp;
next-server xxx.xxx.xxx.xxx; # IP of my PXE server
filename "/pxelinux.0";
#service dhcpd restart

Create the directory for your PXE menus
#mkdir /tftpboot/pxelinux.cfg

My sample config file
#vi /tftpboot/pxelinux.cfg/default

default menu.c32  

prompt 0  
timeout 50  
ONTIMEOUT localboot  
 
MENU TITLE PXE Menu  
   
LABEL localboot  
MENU LABEL Boot From Hard Disk  
LOCALBOOT  0  

LABEL CentoS 5.4 i386 Installer  
MENU LABEL CentOS 5.4 i386 Installer  
KERNEL images/centos/i386/5.4/vmlinuz  
append vga=normal initrd=images/centos/i386/5.4/initrd.img ramdisk_size=32768
Now start the client machine, boot it from lan, it should get a DHCP lease, and start booting successfully from the network
For troubleshooting check /var/log/messages
Credits

Labels: , , , , , , ,

Wednesday, June 16, 2010

Dynamic DNS on CentOS

Installing required packages:
#yum install -y bind bind-chroot bind-libs bind-utils caching-nameserver dhcp

Configuring DHCP server
#rm -rf /etc/dhcpd.conf
#mv /usr/share/doc/dhcp-*/dhcpd.conf.sample /etc/dhcpd.conf

My dhcp configuration is as follows:
#vi /etc/dhcpd.conf
authoritative;              # No other DHCP servers on this subnet
ddns-update-style interim;  # Supported update method - see man dhcpd.conf
ignore client-updates;      # Overwrite client configured FQHNs
ddns-domainname "home.network.";
ddns-rev-domainname "in-addr.arpa.";
include "/var/named/chroot/etc/rndc.key";
zone home.network. {          # Forward zone to be updated
primary 127.0.0.1;
key rndckey;
}
zone 1.168.192.in-addr.arpa. { # Backward zone to be updated
primary 127.0.0.1;
key rndckey;
}
subnet 192.168.1.0 netmask 255.255.255.0 { # Here Specify your subnet
option routers  192.168.1.1; # Specify your router address              
option subnet-mask      255.255.255.0; # Specify subnet mask
option domain-name      "home.network"; # Specify domain name
option domain-name-servers      192.168.1.1; # Specify domain name ip
option time-offset            19800;        # Indian Standard Time
range dynamic-bootp 192.168.1.50 192.168.1.254; # Specify address pool from which dhcp client can get ips 
default-lease-time 21600; # Default leased time in sec
max-lease-time 43200; # Max leased time in sec
}
Changing permission of rndc.key
#chmod 755 /var/named/chroot/etc/rndc.key

Configuring DNS Server
(Note : You can get the copy of name file in /usr/share/doc/bind-*/sample/etc)

My bind configuration is as follows:
#vi /var/named/chroot/etc/named.conf
//sample named.conf
options {
query-source port 53;
directory "/var/named";
forwarders { 8.8.8.8; 8.8.4.4; };
}; 
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
include "/etc/rndc.key";
zone "." {
type hint;
file "named.ca";
}; 
zone "0.0.127.in-addr.arpa" {
type master;
file "named.local";
}; 
zone "home.network" {
type master;
file "home.network.zone";
allow-update { key "rndckey"; };
notify yes;
}; 
zone "1.168.192.in-addr.arpa" {
type master;
file "1.168.192.zone";
allow-update { key "rndckey"; };
notify yes;
};
Now we have to create sample zone files
Creating home.network.zone file
#vi /var/named/chroot/var/named/home.network.zone
$TTL 86400
@ IN SOA home.network root.home.network (
20100616   ; serial in yyymmddxx
28800      ; refresh (8 hours)
14400      ; retry (4 hours)
3600000    ; expire (5 weeks 6 days 16 hours)
86400      ; minimum (1 day)
)
@    IN  NS  home.network. 
@    IN  A  192.168.1.10
home.network. IN  A  192.168.1.10
Creating reverse lookup zone file
#vi /var/named/chroot/var/named/1.168.192.zone
$TTL 86400
@ IN SOA home.network root.home.network (
20100616   ; serial in yyymmddxx
28800      ; refresh (8 hours)
14400      ; retry (4 hours)
3600000    ; expire (5 weeks 6 days 16 hours)
86400      ; minimum (1 day)
) 
@    IN  NS  home.network. 
10.1.168.192.in-addr.arpa.     IN  PTR  home.network.
Modifying host file
#vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.1.10 home.network
Modifying resolv.conf
#vi /etc/resolv.conf
nameserver 192.168.1.10
Now make shortcuts of these files in the /var/named directory with the same name
#cd /var/named
#ln –s /var/named/chroot/var/named/home.network.zone home.network.zone
#ln –s /var/named/chroot/var/named/1.168.192.zone 1.168.192.zone

Creating soft link of named.conf file
#ln -s /var/named/chroot/etc/named.conf /etc/named.conf

Changing permissions
#chmod 770 /var/named/chroot/var/named
#chmod 770 /var/named

Starting dhcp and bind 
#service dhcpd restart
#service named restart

Starting both the services at system start-up
#chkconfig --level 35 dhcpd on
#chkconfig --level 35 named on 

To troubleshoot, both see /var/log/messages file
#tail -f /var/log/messages | grep dhcp
#tail -f /var/log/messages | grep named 

Labels: , , , , , ,