Dhcp ip address assignment

bennworah

New Member
Joined
Jul 18, 2020
Messages
29
Reaction score
1
Credits
253
Hello Experts,
I have configured a DHCP server on my CentOS 7 endpoint, and also I configured a static IP address on the same CentOS. I can lease ip addresses from my DHCP server (hosted on the CentOS 7) to machines on my network.
However, I observed that the static ip address (on my CentOS 7) changes to one of my dhcp ip pool. I expected my Centos 7 endpoint not to receive ip address from the dhcp server, since it already have a static ip address. Also i observed that my Kali linux changes its static ip address to one of the dhcp ip pool.

Kindly assist.
 


The static host IP should be outside the pool range.

Example:
dhcp server static IP 192.168.1.1/24

dhcp-client-range 192.168.1.2-253
 
I can't remember if CentOS 7 is NetworkManager or not.

If you are using networkd and ifcfg-eth0 type files.

You need to put this line in the ifcfg file on the server.
BOOTPROTO=none

Put this line in the ifcfg file on the clients.
BOOTPROTO=dhcp

If you are using NetworkManager

On the dhcp-server
nmcli con mod (connection name) ipv4.method manual

On the dhcp clients.
nmcli con mod (connection name) ipv4.method auto
 
The static host IP should be outside the pool range.

Example:
dhcp server static IP 192.168.1.1/24

dhcp-client-range 192.168.1.2-253
Hello dos2unix,

Thanks for your response.

The DHCP server was setup on a centos 7 with a static IP of 192.168.0.218, however the dhcp server assigns a new IP to itself within the IP pool. It assigns the dhcp server with 192.168.0.209.

This is my configuration:

subnet 192.168.0.0 netmask 255.255.255.0 {

range 192.168.0.205 192.168.0.209;

option routers 192.168.0.218;

option subnet-mask 255.255.255.0;

default-lease-time 600;

max-lease-time 7200;

}
 
I can't remember if CentOS 7 is NetworkManager or not.

If you are using networkd and ifcfg-eth0 type files.

You need to put this line in the ifcfg file on the server.
BOOTPROTO=none

Put this line in the ifcfg file on the clients.
BOOTPROTO=dhcp

If you are using NetworkManager

On the dhcp-server
nmcli con mod (connection name) ipv4.method manual

On the dhcp clients.
nmcli con mod (connection name) ipv4.method auto
I have the bootproto=none, I changed it to static, same issue. This is also happening to my Kali Linux with a static IP. The Dhcp server changes the static IP to one of its IP pool. This is strange, i used nmtui to set a static IP on both my dhcp server and the Kali Linux, yet it changes..
 
nmtui is a NetworkManager tool.

What is the output of
nmcli con show
 
nmtui is a NetworkManager tool.

What is the output of
nmcli con show
1681723384343.png
 
Now can you give output of ...

nmcli con show 'enp0s3' | egrep 'ipv4.method|ipv4.addresses'
 
This is my configuration:

subnet 192.168.0.0 netmask 255.255.255.0 {

range 192.168.0.205 192.168.0.209;

option routers 192.168.0.218;

option subnet-mask 255.255.255.0;

default-lease-time 600;

max-lease-time 7200;

}

Are you using dhcpd? dnsmasq?

It's usually not a good idea, to put the dhcp server on the same subnet as your static host IP.

If you can do this, I would recommend splitting the subnet.

subnet 192.168.0.0 netmask 255.255.255.128 {
option broadcast-address 192.168.0.128;
option routers 192.168.0.218;
default-lease-time XXXX;
max-lease-time XXXX;

pool {
range 192.168.0.105 192.168.0.109;
}
}

I would make your static IP 192.168.0.218/25
 

Members online


Latest posts

Top