DHCP

SERVER SIDE:

In my lab i will be using ubuntu server as my dhcp server and centos a sthe dhcp client

sudo apt install isc-dhcp-server

  • for recovery purposes

sudo mv dhcpd.conf dhcpd.conf.bak

sudo vim dhcpd.conf

# Default lease time
default-lease-time 28800;
max-lease-time 86400;

# Home lab network
subnet 172.16.1.0 netmask 255.255.255.0 {
        range 172.16.1.100 172.16.1.200;
        option subnet-mask 255.255.255.0;
        option routers 127.16.1.100;
        option domain-name "homelab.lan";
        option domain-name-servers ns1.homelab.lan;
}

Now i have to add a network interface inside my Vmware setting for ubuntu server machine

A network interface with ens37 name has been added to this machine ( same thing to do for centos machine)

Netplan is responsible for network configuration in my machine:

sudo vim /etc/netplan/00-installer-config.yaml

As you can see, i have added a network interface configuration for ens37

Note: I didn’t add a route to the gateway because this will issue a conflict between this interfaces Instead I am planning to use my ubuntu server as a router too and let the forwarding from ens37 to ens33 so any client that takes address from this interface will reach the internet via my home router (not ubuntu server = 192.168.1.1)

And you can see that i have put the default route for these clients to be the same interface that gives dhcp which is ens37=172.16.1.100

Client Side:

i am planning to use ens36 so i have to add it

nmcli connection add con-name ens36 ifname ens36 type ethernet

and VOILAA, ens36 will take ip address automatically since dhcp use broadcast

Configure Routing

Before we start configuring this, let me prove that ens36 can’t reach the internet:

Now let’s start setting up our machine to act like a router, matter of fact turn it into a router

  • Enable IP Forwarding

    Edit the /etc/sysctl.conf file and uncomment the following line

  • Apply it :

Last updated