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 timedefault-lease-time28800;max-lease-time86400;# Home lab networksubnet172.16.1.0netmask255.255.255.0{range172.16.1.100172.16.1.200;optionsubnet-mask255.255.255.0;optionrouters127.16.1.100;optiondomain-name"homelab.lan";optiondomain-name-serversns1.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
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
addresses:
- 192.168.1.5/24
nameservers:
addresses:
- 8.8.8.8
search: []
routes:
- to: default
via: 192.168.1.1
ens37:
addresses:
- 172.16.1.100/24
nameservers:
addresses:
- 192.168.1.9
search: []
version: 2
[k8s@k8s-manager ~]$ nmcli device status
DEVICE TYPE STATE CONNECTION
ens33 ethernet connected ens33
lo loopback connected (externally) lo
ens36 ethernet disconnected --