Saturday, June 22, 2013

How to Install and Configure Proxy Server with Squid3 on Ubuntu Server 12.04 LTS

 https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQx27uETEmIq5j5OdE-nFucfkoJeiSn-pqyvTywxaeQwPRq71hG1tlpS4K_B6d8v3GnFumWQL8uA2wwCt-r-WWcqdq-6X1MzHVTlUZlyE02v7P-6BmVVULwsRchjeXFwbdmzzeY08OtdI/s1600/squid-ubuntu.jpg

Squid is a popular appliaction that used as web proxy cache server which provides proxy and cache services for HTTP, HTTPS, FTP, gopher and other popular network protocols. Squid can implement caching of Domain Name Server (DNS) lookups and caching and proxying Secure Sockets Layer (SSL) requests, and perform transparent caching.in addition, Squid also supports a wide variety of caching protocols, such as Internet Cache Protocol (ICP), the Hyper Text Caching Protocol (HTCP), the Cache Array Routing Protocol (CARP), and the Web Cache Coordination Protocol (WCCP).


The Squid proxy cache server is an excellent solution to a variety of proxy and caching server needs, and scales from the branch office to enterprise level networks while providing extensive, granular access control mechanisms and monitoring of critical parameters via the Simple Network Management Protocol (SNMP). When selecting a computer system for use as a dedicated Squid proxy, or caching servers, ensure your system is configured with a large amount of physical memory, as Squid maintains an in-memory cache for increased performance.

On This tutorial I will demonstrate how to installing and configure Proxy server with Squid3 on Ubuntu server 12.04. Here’s basic features squid3 :
  • Connection Pinning (for NTLM Auth Passthrough)
  • Native IPv6
  • Quality of Service (QoS) Flow support
  • Native Memory Cache
  • SSL Bump (for HTTPS Filtering and Adaptation)
  • TProxy v4.1+ support
  • eCAP Adaptation Module support
  • Error Page Localization
  • Follow X-Forwarded-For support
  • X-Forwarded-For options extended (truncate, delete, transparent)
  • Peer-Name ACL
  • Reply headers to external ACL.
  • ICAP and eCAP Logging
  • ICAP Service Sets and Chains
  • ICY (SHOUTcast) streaming protocol support
  • HTTP/1.1 support on connections to web servers and peers.
  • More feature here

Installing Squid3

Log in on Ubuntu Server, then type command below to Install squid2 in ubuntu server 12.04:

sudo apt-get install squid3 ccze

Configure Squid3

Create directory for Cache, on this case cache directory placed on directory /home/precise/cache/. Then change the permissions cache directory to 777 and owner proxy:proxy

sudo mkdir -p /home/precise/cache/
 
sudo chmod 777 /home/precise/cache/
 
sudo chown proxy:proxy /home/precise/cache/
 
Before editing squid configuration, Make a backup of your /etc/squid3/squid.conf file for future reference. Squid.conf has nearly all the options listed and it is recommended to go through that file to know more about squid options.

sudo cp /etc/squid3/squid.conf /etc/squid3/squid.conf.origin
 
sudo chmod a-w /etc/squid3/squid.conf.origin
 
Now edit /etc/squid3/squid.conf file, delete all options in /etc/squid3/squid.conf then replace with squid3 configuration below.

sudo nano /etc/squid3/squid.conf
 
Squid3 configuration

# ACCESS CONTROLS OPTIONS
# ====================
#
acl QUERY urlpath_regex -i cgi-bin \? \.php$ \.asp$ \.shtml$ \.cfm$ \.cfml$ 
\.phtml$ \.php3$ localhost 
acl all src
acl localnet src 10.0.0.0/8
acl localnet src 192.168.1.0/24 # Your network here
acl localhost src 127.0.0.1/32
acl safeports port 21 70 80 210 280 443 488 563 591 631 777 901 81 3128 1025-65535
acl sslports port 443 563 81 2087 10000
acl manager proto cache_object
acl purge method PURGE
acl connect method CONNECT
acl ym dstdomain .messenger.yahoo.com .psq.yahoo.com
acl ym dstdomain .us.il.yimg.com .msg.yahoo.com .pager.yahoo.com
acl ym dstdomain .rareedge.com .ytunnelpro.com .chat.yahoo.com
acl ym dstdomain .voice.yahoo.com
acl ymregex url_regex yupdater.yim ymsgr myspaceim
#
http_access deny ym
http_access deny ymregex
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !safeports
http_access deny CONNECT !sslports
http_access allow localhost
http_access allow localnet
http_access deny all
#
# NETWORK OPTIONS
# —————
#
http_port 3128
#
# OPTIONS WHICH AFFECT THE CACHE SIZE
# ==============================
#
cache_mem 8 MB
maximum_object_size_in_memory 32 KB
memory_replacement_policy heap GDSF
cache_replacement_policy heap LFUDA
cache_dir aufs /home/precise/cache 10000 14 256
maximum_object_size 128000 KB
cache_swap_low 95
cache_swap_high 99
#
# LOGFILE PATHNAMES AND CACHE DIRECTORIES
# ==================================
#
access_log /var/log/squid3/access.log
cache_log /cache/cache.log
#cache_log /dev/null
cache_store_log none
logfile_rotate 5
log_icp_queries off
#
# OPTIONS FOR TUNING THE CACHE
# ========================
#
cache deny QUERY
refresh_pattern ^ftp: 1440 20% 10080 reload-into-ims
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i \.(gif|png|jp?g|ico|bmp|tiff?)$ 10080 95% 43200 override-expire 
override-lastmod reload-into-ims ignore-no-cache ignore-private
refresh_pattern -i \.(rpm|cab|deb|exe|msi|msu|zip|tar|xz|bz|bz2|lzma|gz|tgz|rar|
bin|7z|doc?|xls?|ppt?|pdf|nth|psd|sis)$ 10080 90% 43200 override-expire 
override-lastmod reload-into-ims ignore-no-cache ignore-private
refresh_pattern -i \.(avi|iso|wav|mid|mp?|mpeg|mov|3gp|wm?|swf|flv|x-flv|axd)$ 
43200 95% 432000 override-expire override-lastmod reload-into-ims ignore-no-cache 
ignore-private
refresh_pattern -i \.(html|htm|css|js)$ 1440 75% 40320
refresh_pattern -i \.index.(html|htm)$ 0 75% 10080
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 1440 90% 10080
#
quick_abort_min 0 KB
quick_abort_max 0 KB
quick_abort_pct 100
store_avg_object_size 13 KB
#
# HTTP OPTIONS
# ===========
vary_ignore_expire on
#
# ANONIMITY OPTIONS
# ===============
#
request_header_access From deny all
request_header_access Server deny all
request_header_access Link deny all
request_header_access Via deny all
request_header_access X-Forwarded-For deny all
#
# TIMEOUTS
# =======
#
forward_timeout 240 second
connect_timeout 30 second
peer_connect_timeout 5 second
read_timeout 600 second
request_timeout 60 second
shutdown_lifetime 10 second
#
# ADMINISTRATIVE PARAMETERS
# =====================
#
cache_mgr ninja
cache_effective_user proxy
cache_effective_group proxy
httpd_suppress_version_string on
visible_hostname ninja
#
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on
#
# DNS OPTIONS
# ==========
#
dns_timeout 10 seconds
dns_nameservers 192.168.1.1 8.8.8.8 8.8.4.4 # DNS Server
#
# MISCELLANEOUS
# ===========
#
memory_pools off
client_db off
reload_into_ims on
coredump_dir /cache
pipeline_prefetch on
offline_mode off
#
#Marking ZPH
#==========
zph_mode tos
zph_local 0x04
zph_parent 0
zph_option 136
### END CONFIGURATION ###
 
Create swap director

squid3 -z
 
Restart squid3

sudo /etc/init.d/squid3 restart
 
 
Reference:

Friday, June 21, 2013

How to Enable or Disable the Control Panel and PC Settings in Windows 8

image

Disabling the Control Panel is a pretty common thing for admins to do. Here is how to do it in Windows 8 using both Group Policy as well as a manual registry hack.

It’s worth noting that this is something you probably won’t want to do on your home computer. But it’s useful to understand how it works in case yours is disabled and you want to enable it again.

Using a Local Group Policy Setting

Press the Win + R keyboard combination to bring up a run box, then type gpedit.msc and press enter.



When the Local Group Policy Editor opens navigate to:
User Configuration\Administrative Templates\Control Panel


On the right hand side you should see a setting called “Prohibit access to Control Panel and PC settings”. Double click on it.



Then change the radio button over to Enabled.



Once you have applied the setting you will want to refresh your group policy settings, this can be done by running:
gpupdate /force

Sunday, June 9, 2013

How Software Installation & Package Managers Work On Linux

image

Installing software on Linux involves package managers and software repositories, not downloading and running .exe files from websites like on Windows. If you’re new to Linux, this can seem like a dramatic culture shift.
While you can compile and install everything yourself on Linux, package managers are designed to do all the work for you. Using a package manager makes installing and updating software easier than on Windows.

Linux vs. Windows

There are a wide variety of Linux distributions and a wide variety of package managers. Linux is built from open-source software, which means that each Linux distribution compiles its own software with its desired library versions and compilation options. Compiles Linux applications generally don’t run on every distribution – even if they could, installation would be hindered by competing package formats.If you locate a Linux application’s website, you’ll likely see a variety of download links for different package formats and Linux distributions – assuming the application’s website provides pre-compiled versions at all. The application may tell you to download the source code and compile it yourself.


Software Repositories

Linux users don’t normally download and install applications from the applications’ websites, like Windows users do. Instead, each Linux distribution hosts their own software repositories. These repositories contain software packages specially compiled for each Linux distribution and version. For example, if you’re using Ubuntu 12.04, the repositories you use contain packages specially compiled for Ubuntu 12.04. A Fedora user uses a repository full of packages specially compiled for their version of Fedora.


Package Managers

Think of a package manager like a mobile app store – except they were around long before app stores. Tell the package manager to install software and it will automatically download the appropriate package from its configured software repositories, install it, and set it up – all without you having to click through wizards or hunt down .exe files on websites. When an update is released, your package manager notices and downloads the appropriate update. Unlike on Windows, where each application must have its own updater to receive automatic updates, the package manager handles updates for all installed software — assuming they were installed from the software repositories.


What’s a Package?

Unlike on Windows, where applications come in .exe installer files that can do anything they like to the system, Linux uses special package formats. There are a variety of package types – most notably DEB on Debian and Ubuntu and RPM on Fedora, Red Hat, and others. These packages are essentially archives containing a list of files. The package manager opens the archive and installs the files to the location the package specifies. The package manager remains aware of which files belong to which packages – when you uninstall a package, the package manager knows exactly which files on the system belong to it. Windows has no idea what files belong to an installed application – it lets application installers manage installation and uninstallation themselves.

Packages can also contain scripts that run when the package is installed and removed, although these are generally used for system setup and not moving files to arbitrary locations.


Installing Software on Linux

To install software on Linux, open your package manager, search for the software, and tell the package manager to install it. Your package manager will do the rest. Linux distributions often offer a variety of frontends to the package manager. For example, on Ubuntu, the Ubuntu Software Center, Update Manager, Synaptic application, and apt-get command all use apt-get and dpkg to download and install DEB packages. You can use any utility you like – they just provide different interfaces. You’ll generally find a simple, graphical package manager in your Linux distribution’s menus.


Update Delays

One thing new Linux users often notice with package managers and repositories is a delay before new software versions reach their systems. For example, when a new version of Mozilla Firefox is released, Windows and Mac users will acquire it from Mozilla. On Linux, your Linux distribution must package the new version and push it out as an update. If you open Firefox’s preferences window on Linux, you’ll note that Firefox has no ability to automatically update itself (assuming you’re using the version of Firefox from your Linux distribution’s repositories).



You can also download and install the application yourself – for example, downloading Firefox directly from Mozilla — but this may require compiling and installing the software from source and removes the benefits of package managers, such as automatic, centralized security updates.

While new versions of Firefox are a priority because they contain security updates, other applications may not be delivered as quickly. For example, a major new version of the LibreOffice office suite may not ever be released as an update for the current version of your Linux distribution. To avoid potential instability and allow time for testing, this version may not be available until the next major release of your Linux distribution – for example, Ubuntu 12.10 – when it becomes the default version in the distribution’s software repositories.
To fix this problem, some Linux distributions, such as Arch Linux, offer “rolling release cycles,” where new versions of software are pushed into the main software repositories. This may cause problems – while you may want new versions of desktop applications, you probably don’t care about new versions of low-level system utilities, which could potentially introduce instability.

Ubuntu offers the backports repository to bring newer versions of significant packages to older distributions, although not all new versions make it into the backports repository.

Other Repositories

While Linux distributions ship with their own repositories pre-configured, you can also add other repositories to your system. Once you have, you can install software repositories from that repository and receive updates from it using your package manager. The repository you add must be designed for your Linux distribution and package manager.

For example, Ubuntu offers a wide variety of personal package archives (PPAs), which contain software compiled by individuals and teams. Ubuntu doesn’t vouch for the stability or security of the packages in these repositories, but you can add PPAs from trusted individuals to download packages not yet in Ubuntu’s repository – or download newer versions of existing packages.
Some third-party applications also use their own software repositories. For example, when you install Google Chrome on Ubuntu, it adds its own apt repository to your system. This ensures you receive updates to Google Chrome through Ubuntu’s Update Manager and standard software installation tools.

How to Change your Username on Ubuntu 12.04


Introduction

User management is a critical part of maintaining a secure system. Ineffective user and privilege management often lead many systems into being compromised. Therefore, it is important that you understand how you can protect your server through simple and effective user account management techniques. 

Users are encouraged to make use of a tool by the name of sudo to carry out system administrative duties. Sudo allows an authorized user to temporarily elevate their privileges using their own password instead of having to know the password belonging to the root account. This simple yet effective methodology provides accountability for all user actions, and gives the administrator granular control over which actions a user can perform with said privileges.

In this tutorial, we explain how you can change your Username on your Ubuntu system. So follow the steps to change your username on your Ubuntu system.

Step Wise Changing Username on Ubuntu 12.04

Step 1 : Before beginning the procedure, Open the terminal by pressing CTRL + ALT + T from your keyboard. When the terminal opens, run the following command in the terminal to create new password for the root account on your Ubuntu system.
$ sudo passwd root
Step 2 : Next, run the following command in the terminal to unlock the root account on your Ubuntu system.
$ sudo passwd -u root
Step 3 : Next, Now log out and again login as the root user from the logon screen on your Ubuntu system.

Step 4 : Next, When you login again, Open the terminal and run the following command in the terminal to change your username on your Ubuntu system.
$ usermod -c "Real Name" -l new_name old_name
Step 5 : Finally, Lock the root account again and restart it by running the following command in the terminal on your Ubuntu system.
$ passwd -l root
That’s All and now enjoy the new username on your Ubuntu system.

Linux Users Have a Choice: 8 Linux Desktop Environments

ubuntu-derivatives

There’s no one true desktop environment for Linux. Unlike competing operating systems like Windows, Linux users have a choice of many different desktop environments, all with their own styles and strengths.
You can install one of these desktop environments after installing your Linux distribution and switch between desktop environments from the login screen. You can also choose to install a Linux distribution that comes with the desktop environment. For example, you can get Ubuntu in many different flavors.

Unity

Unity is Ubuntu’s own default desktop environment. If you’ve installed Ubuntu using the standard installer, you’re probably using the Unity desktop right now.
Unity is Ubuntu’s vision of what a Linux desktop should be. In fact, for most users, Unity is probably synonymous with Ubuntu. From its searchable Dash (which also searches online sources) to its application dock that functions similarly to Windows 7′s taskbar, Unity has its own identity as a desktop. However, Unity also includes a variety of programs from the GNOME desktop. Prior to Unity, Ubuntu used GNOME — many of these GNOME programs, like the Nautilus file manager, are still used on Unity today.


GNOME

GNOME was once the most popular Linux desktop environment. The GNOME 2.x series was used by default on Ubuntu, Fedora, Debian, and most other big Linux distributions. It was a simple, fairly lightweight desktop environment. After the transition to the new GNOME 3 with its GNOME Shell interface, Ubuntu and other distributions began moving away from GNOME. GNOME 3 was arguably too simple and stripped-down in terms of options and features — for example, it doesn’t even include a taskbar by default.
However, GNOME 3 now supports extensions that can add many missing desktop features, including a taskbar. GNOME 3 is a slick desktop that takes advantage of the graphical effects available on multiple computers, and some people do prefer its vision of the Linux desktop. It works similarly to Unity in some ways, with a full-screen application launcher.


KDE

At one point, KDE and GNOME were the two most popular Linux desktop environments. KDE has always been more complex than GNOME, packing in many more configuration options and features. It’s a bit more Windows-like than the other desktop environments here, coming with a single taskbar on the bottom of the screen that includes a menu, quick launch-type icons, a taskbar, a notification area, and a clock — the typical layout of a Windows taskbar before Windows 7.

KDE is a solid desktop environment that’s well-suited to someone who wants a lot of configuration options. KDE 4′s desktop comes with a variety of widgets, so the desktop itself can be extensively customized, too. KDE is based on the QT toolkit, whereas GNOME and Unity are based on the GTK toolkit. This means that KDE uses different programs than these other desktops — file manager, image viewer, and so on — they’re all different programs than you’d use on a GNOME or Unity desktop.


Xfce

Xfce is a more lightweight desktop environment. It was once very similar to GNOME, but with GNOME 3 striking out in a different direction, Xfce now has its own identity as a more traditional Linux desktop environment that’s quite similar to GNOME 2.

This option is ideal if you want a more traditional desktop environment without full-screen application launchers, overdone graphical effects, and desktop widgets. It’s also more lightweight than the other options here, making it ideal for older computers or ones without stable 3D graphics drivers that can’t handle the effects in Unity and GNOME.

While Xfce also uses the GTK toolkit, it includes many of its own programs, such as a lightweight file manager, text editor, and image viewer. You won’t find all the typical programs you would find in Unity and GNOME, although some common ones are present.


Cinnamon

Cinnamon was developed for Linux Mint. Cinnamon is based on GNOME 3, so it uses up-to-date libraries and other software — but it takes that software and tries to create a more traditional-looking desktop with it.
This modern desktop environment offers nice graphical effects and a rethought application menu. However, it doesn’t throw away the past and includes a taskbar, application menu that doesn’t take up the full screen, and so on. Linux Mint pushes Cinnamon as one of its preferred desktop environments, but you can also install and use it on Ubuntu.

As it’s based on GNOME, Cinnamon uses many GNOME utilities but also includes some of its own configuration tools.


MATE

MATE is a fork of the original GNOME 2 that aims to preserve GNOME 2, continually updating it so it will continue to work on modern Linux distributions. MATE has also seen some new features, but the main purpose of MATE is to give people who desperately miss GNOME 2 the opportunity to install it on new Linux distributions. It’s officially supported along with Cinnamon in Linux Mint, where it’s given a prominent place as a default choice.

This desktop environment is ideal for people who really miss GNOME 2. In some ways, a desktop environment like Cinnamon is probably better positioned for the future as it’s based on newer software like GTK 3, while MINT is stuck with the older GTK 2.


LXDE

If you didn’t think Xfce was lightweight enough, try LXDE. LXDE is focused on being as lightweight as possible and is especially designed for older computers, netbooks, and other systems with low hardware resources. While it’s a lightweight desktop, it includes all the standard desktop features — some lightweight desktops omit the taskbar entirely, but LXDE doesn’t.

Like Xfce, LXDE bundles its own lightweight file manager, text editor, image viewer, terminal program, and other utilities.


Xmonad and More

This isn’t a complete list — not by a long shot. There are many more niche desktop environments and window managers you could use, including Xmonad, a tiling window manager. Tiling window managers attempt to make your life easier by automatically arranging windows in tiles on your screen, saving you the trouble of dragging them around and allowing you to quickly rearrange them with keyboard shortcuts. It’s a good example of just how different from each other Linux desktop environments can be.


Monday, June 3, 2013

What is DHCP and How DHCP Works?

Computer networks can be of any form like a LAN, WAN etc. If you are connected to a local LAN or an internet connection, the IP addresses form the basis of communication over computer networks. An IP address is the identity of a host or a computer device while connected to any network.
In most of the cases when you connect your computer to a LAN or internet, you’ll notice that the IP address and other information like subnet mask etc are assigned to your computer automatically. Have you ever thought about how this happens? Well, in this article we will understand the concept of DHCP that forms the basis of this functionality.

What is DHCP?

DHCP stands for Dynamic Host Configuration Protocol.
As the name suggests, DHCP is used to control the network configuration of a host through a remote server. DHCP functionality comes installed as a default feature in most of the contemporary operating systems. DHCP is an excellent alternative to the time-consuming manual configuration of network settings on a host or a network device.
DHCP works on a client-server model. Being a protocol, it has it’s own set of messages that are exchanged between client and server. Here is the header information of DHCP :

FIELD OCTETS DESCRIPTION
op 1 Type of message
htype 1 type of hardware address
hlen 1 length of hardware address
hops 1 used in case of relay agents. Clients sets them to 0.
xid 4 Transaction ID used by the client and server for a session.
secs 2 Time elapsed (in seconds) since the client requested the process
flags 2 Flags
ciaddr 4 Client IP address.
yiaddr 4 The IP address assigned by server to the client
siaddr 4 Server IP address.
giaddr 4 IP address of the relay agent.
chaddr 16 Hardware address of the client.
sname 64 Host name of the server.
file 128 Boot file name.
options var Additional options

Understanding DHCP helps in debugging many network related problems. Read our articles on wireshark and Journey of a packet on network to enhance your understanding on network and network debugging tools.
In the next section, we will cover the working of this protocol.

How DHCP Works?

Before learning the process through which DHCP achieves it’s goal, we first have to understand the different messages that are used in the process.

1. DHCPDISCOVER

It is a DHCP message that marks the beginning of a DHCP interaction between client and server. This message is sent by a client (host or device connected to a network) that is connected to a local subnet. It’s a broadcast message that uses 255.255.255.255 as destination IP address while the source IP address is 0.0.0.0

2. DHCPOFFER

It is DHCP message that is sent in response to DHCPDISCOVER by a DHCP server to DHCP client. This message contains the network configuration settings for the client that sent the DHCPDISCOVER message.

3. DHCPREQUEST

This DHCP message is sent in response to DHCPOFFER indicating that the client has accepted the network configuration sent in DHCPOFFER message from the server.

4. DHCPACK

This message is sent by the DHCP server in response to DHCPREQUEST recieved from the client. This message marks the end of the process that started with DHCPDISCOVER. The DHCPACK message is nothing but an acknowledgement by the DHCP server that authorizes the DHCP client to start using the network configuration it received from the DHCP server earlier.

5. DHCPNAK

This message is the exact opposite to DHCPACK described above. This message is sent by the DHCP server when it is not able to satisfy the DHCPREQUEST message from the client.

6. DHCPDECLINE

This message is sent from the DHCP client to the server in case the client finds that the IP address assigned by DHCP server is already in use.

7. DHCPINFORM

This message is sent from the DHCP client in case the IP address is statically configured on the client and only other network settings or configurations are desired to be dynamically acquired from DHCP server.

8. DHCPRELEASE

This message is sent by the DHCP client in case it wants to terminate the lease of network address it has be provided by DHCP server.


Now as we know about the various DHCP messages, it’s time to go through the the complete DHCP process to give a better Idea of how DHCP works. Note that the steps mentioned below assume that DHCP functionality is enabled by default on the client side.
Here are the steps :
  • Step 1: When the client computer (or device) boots up or is connected to a network, a DHCPDISCOVER message is sent from the client to the server. As there is no network configuration information on the client so the message is sent with 0.0.0.0 as source address and 255.255.255.255 as destination address. If the DHCP server is on local subnet then it directly receives the message or in case it is on different subnet then a relay agent connected on client’s  subnet is used to pass on the request to DHCP server. The transport protocol used for this message is UDP and the port number used is 67. The client enters the initializing stage during this step.
  • Step 2: When the DHCP server receives the DHCPDISCOVER request message then it replies with a DHCPOFFER message. As already explained, this message contains all the network configuration settings required by the client. For example, the yaddr field of the message will contain the IP address to be assigned to client. Similarly the the subnet mask and gateway information is filled in the options field. Also, the server fills in the client MAC address in the chaddr field. This message is sent as a broadcast (255.255.255.255) message for the client to receive it directly or if DHCP server is in different subnet then this message is sent to the relay agent that takes care of whether the message is to be passed as unicast or broadcast. In this case also, UDP protocol is used at the transport layer with destination port as 68. The client enters selecting stage during this step
  • Step 3: The client forms a DHCPREQUEST message in reply to DHCPOFFER message and sends it to the server indicating it wants to accept the network configuration sent in the DHCPOFFER message. If there were multiple DHCP servers that received DHCPDISCOVER then client could receive multiple DHCPOFFER messages. But, the client replies to only one of the messages by populating the server identification field with the IP address of a particular DHCP server. All the messages from other DHCP servers are implicitly declined. The DHCPREQUEST message will still contain the source address as 0.0.0.0 as the client is still not allowed to use the IP address passed to it through DHCPOFFER message. The client enters requesting stage during this step.
  • Step 4: Once the server receives DHCPREQUEST from the client, it sends the DHCPACK message indicating that now the client is allowed to use the IP address assigned to it. The client enters the bound state during this step.

The Concept of Lease

With all the necessary information on how DHCP works, one should also know that the IP  address assigned by DHCP server to DHCP client is on a lease. After the lease expires the DHCP server is free to assign the same IP address to any other host or device requesting for the same. For example, keeping lease time 8-10 hours is helpful in case of PC’s that are shut down at the end of the day.  So, lease has to be renewed from time to time. The DHCP client tries to renew the lease after half of the lease time has expired. This is done by the exchange of DHCPREQUEST and DHCPACK messages. While doing all this, the client enters the renewing stage.