Professional Documents
Culture Documents
Installing DHCP Server in Ubuntu/Centos
Installing DHCP Server in Ubuntu/Centos
DHCP (short for Dynamic Host Configuration Protocol) is a client/server protocol that enables a
server to automatically assign an IP address and other related configuration parameters (such as the
subnet mask and default gateway) to a client on a network.
DHCP is important because it prevents a system or network administrator from manually
configuring IP addresses for new computers added to the network or computers that are moved from
one subnet to another.
The IP address assigned by a DHCP server to a DHCP client is on a “lease”, the lease time
normally varies depending on how long a client computer is likely to require the connection or the
DHCP configuration.
Once the installation is complete, configure the interface on which you want the DHCP daemon to
serve requests in the configuration file /etc/default/isc-dhcp-server or /etc/sysconfig/dhcpd.
# vim /etc/sysconfig/dhcpd #CentOS
$ sudo vim /etc/default/isc-dhcp-server #Ubuntu
For example, if you want the DHCPD daemon to listen on eth0, set it using the following
directive.
DHCPDARGS=”eth0”
Start by defining the global parameters which are common to all supported networks, at the top of
the file. They will apply to all the declarations:
option domain-name "tecmint.lan";
option domain-name-servers ns1.tecmint.lan, ns2.tecmint.lan;
default-lease-time 3600;
max-lease-time 7200;
authoritative;
Next, you need to define a sub-network for an internal subnet i.e 192.168.1.0/24 as shown.
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-search "tecmint.lan";
option domain-name-servers 192.168.1.1;
range 192.168.10.10 192.168.10.100;
range 192.168.10.110 192.168.10.200;
}
Note that hosts which require special configuration options can be listed in host statements (see the
dhcpd.conf man page).
Now that you have configured your DHCP server daemon, you need to start the service for the
mean time and enable it to start automatically from the next system boot, and check if its up and
running using following commands.
------------ On CentOS ------------
# systemctl start dhcpd
# systemctl enable dhcpd
# systemctl enable dhcpd
Next, permit requests to the DHCP daemon on Firewall, which listens on port 67/UDP, by running.
------------ On CentOS ------------
# firewall-cmd --zone=public --permanent --add-service=dhcp
# firewall-cmd --reload
Save the file and restart network service (or reboot the system).
# systemctl restart network
$ sudo vi /etc/network/interfaces
Save the file and restart network services (or reboot the system).
$ sudo systemctl restart networking
On Ubuntu 18.04, networking is controlled by the Netplan program. You need to edit the
appropriate file under the directory /etc/netplan/, for example.
$ sudo vim /etc/netplan/01-netcfg.yaml
Then enable dhcp4 under a specific interface for example under ethernets, ens0, and comment out
static IP related configs:
network:
version: 2
renderer: networkd
ethernets:
ens0:
dhcp4: yes
Save the changes and run the following command to effect the changes.
$ sudo netplan apply
For more information, see the dhcpd and dhcpd.conf man pages.
$ man dhcpd
$ man dhcpd.conf
What is Telnet ?
Telnet is an old network protocol that is used to connect to remote systems over a TCP/IP network.
It connects to servers and network equipment over port 23. Let’s take a look at Telnet command
usage.
It uses a TELNET protocol. However, this protocol has some security defects, but it is one of the
most used networking protocols due to its simplicity. It is not a secure protocol because it transfers
data in unencrypted form. Often Linux user prefers ssh over telnet because ssh transfers data in
encrypted form. This utility is similar to the Remote Desktop feature in Windows. The syntax for
the telnet is as Follows:
1. telnet hostname/IP address
Telnet has been successfully installed and ready for use. Like in the previous example in CentOS 7,
you need to create a login user and log in using the same syntax.
Sample Output
Sample Output
To check whether telnet service is running, execute the command.
$ systemctl status inetd
Sample Output
Sample Output
In this example, we will create a login user for logging in using the telnet protocol.
# adduser telnetuser
# passwd telnetuser
For example
$ telnet 38.76.11.19
Telnet can also be used to check if a specific port is open on a server. To do so, use the syntax
below.
$ telnet server-IP port
Sample Output
Linux ifconfig
The command ifconfig stands for interface configurator. This command enables us to initialize an
interface, assign IP address, enable or disable an interface. It display route and network interface.
You can view IP address, MAC address and MTU (Maximum Transmission Unit) with ifconfig
command.
Syntax:
1. ifconfig
Look at the above snapshot, it shows the IP address of all three that is eth, lo and wlan.