IP address of DHCP Server

I know this is a stupid question, but I'll ask anyway.

Must a DHCP server have a static IP address or is it possible for it to ask itself for an IP address?
 
A DHCP server broadcasts to the entire network. It usually has the ip of the gateway like a modem or router but it can be something else. The ip isn't relevant to make a DHCP request work. The server only has to be visible over wire,
 
I was wondering if there was some way to start the DHCP sever before running ifconfig_em0="dhcp".....

probably not.... just asking...
 
I was wondering if there was some way to start the DHCP sever before running ifconfig_em0="dhcp".....

probably not.... just asking...
I think you need to have at least 1 network interface up, and the (local) DHCP client must assume this is the network to expect a DHCP server on.
Not sure, though. I kind of never tried this situation. Even a softrouter has its ip and gateway configured before starting a DHCP server to act upon this link.
 
I know this is a stupid question, but I'll ask anyway.

Must a DHCP server have a static IP address or is it possible for it to ask itself for an IP address?

DHCP is a Layer 2 service thus below IP, runs on a raw network interface, and actually doesn't need any IP address assigned to that interface at all to operate.

Yes it is possible. Understand that it is the MAC address that is king in the broadcast domain of LAN, not IP. Two or more machines can be DHCP servers at the same time, provided they're meticously configured to not interfere with eachother.
 
with enough effort, i guess you could, but why? configure your DHCP server with a static IP. If you want to use hardware blocks to pin the rest of your network, that's cool, we do that for a few things, but we wouldn't go out of our way to make the DHCP server come up before IP because it's easier to just configure it statically.
 
DHCP is a Layer 2 service thus below IP, runs on a raw network interface, and actually doesn't need any IP address assigned to that interface at all to operate.

Yes it is possible. Understand that it is the MAC address that is king in the broadcast domain of LAN, not IP. Two or more machines can be DHCP servers at the same time, provided they're meticously configured to not interfere with eachother.
Just curious. What kind of signal does dhclient send to what if there's no TCP/IP network at all? Does 1 device with a MAC-address somehow get priority to send hardware-layer signals with?
If you create a bridge or tap device and give it an ip, shouldn't a DHCP request be sent to a black hole because it assumes this is where to get a lease since it's the only networking device seen?
 
DHCP conversation is started by a client. Inital packet is broadcast, basically raw IP (UDP) sent to 255.255.255.255 usually port 67. A DHCP server is listening on that port and sends back a reply.
So in theory if you have a listener on port 67 attached to an interface, then it should work.

But you would need to figure out how to write the server side to listen on a raw interface and send back a response on that same interface.

Wikipedia actually has a pretty good article on DHCP, includes packet formats
 
mer the dhcpd's interface binding is from rc.conf, as the daemon opens the raw socket. I don't think it is necessary to have IP on this interface, and dhcpd will not perform any sort of checks to see whether its subnet definition matches the IP/network on the interface.

Of course it is easier. but is it possible to do what I want. I have my reasons.

I found with FreeBSD and networking, anything is possible.
If you give me the exact details of your setup, I can give you the recommendation.
 
  • Like
Reactions: mer
Just curious. What kind of signal does dhclient send to what if there's no TCP/IP network at all? Does 1 device with a MAC-address somehow get priority to send hardware-layer signals with?
If you create a bridge or tap device and give it an ip, shouldn't a DHCP request be sent to a black hole because it assumes this is where to get a lease since it's the only networking device seen?

Just to add to mer's description, the UDP does not require a TCP/IP state machine, so the port can be actually unconfigured as it is prior to DHCP client's task.

The dhclient will fail if it cannot open a raw packet connection.

I have trouble understanding the rest of your questions. I can only answer generally - there are no hardware layer signals, everything is done in software. If you refer to Layer 2, the drivers actually read the MAC from the card and set up the interface, but the "stack" is the one generating the packets, and therefore you can use any MAC entry. It is the network stacks ARP table that holds bindings between IPs and MACs.
 
Just to add to mer's description, the UDP does not require a TCP/IP state machine, so the port can be actually unconfigured as it is prior to DHCP client's task.

The dhclient will fail if it cannot open a raw packet connection.

I have trouble understanding the rest of your questions. I can only answer generally - there are no hardware layer signals, everything is done in software. If you refer to Layer 2, the drivers actually read the MAC from the card and set up the interface, but the "stack" is the one generating the packets, and therefore you can use any MAC entry. It is the network stacks ARP table that holds bindings between IPs and MACs.
Dhclient sends a request on UDP to everything that's connected on ARP/MAC level? So, the system networking stack spreads a DHCP request to everything that's known as networking device, as I understand, (I'm only slightly aware of the 90's TCP layers doctrine)
 
I found with FreeBSD and networking, anything is possible.
If you give me the exact details of your setup, I can give you the recommendation.

The setup is quite straightforward, nothing fancy.

I have a dhcp server which works and it has a static IP address. I'm trying figure out if it can have a dynamic IP address provided by the server it is running on.

A static IP address can be provided by the server via its MAC address. Is it possible to run dhclient em0 after the dhcp server has started?
 
It would do you well to study how dhclient works.

#1 the main PID.
This runs the main daemon

#2 The interface PID's
These are per interface PID's
 
In case of a failed to connect DHCP server it does this.

On Starts main daemon, starts interface daemon which starts ack and shake. If no ack it keeps searching. So if connection comes up late it will still handshake.

But problem when you want to stop and redo dhclient. You must run pkill dhclient twice to kill both daemons.
Then you can restart dhclinet on an interface.
To manually kill a single dhclient interface without bringing down all of dhclient you need to kill the dhclient inteface PID.
 
Dhclient sends a request on UDP to everything that's connected on ARP/MAC level? So, the system networking stack spreads a DHCP request to everything that's known as networking device, as I understand, (I'm only slightly aware of the 90's TCP layers doctrine)

ARP/MAC level to simplify, call it wire. Everything that is wired on the local Ethernet will get the broadcast packet from the switch, generated by that dhclient.

No, the system networking stack doesn't spread this request. The dhclient, like the dhcpd, is ran over a specific interface.

If there is need to have multiple interfaces DHCP configured, then there are multiple dhclient instances running.
 
If you wanted to run a script two minutes later after bootup you could do a /etc/rc.local script to assist.

sleep 120
ifconfig em0 up
sleep 10
dhclient em0
 
except that happens all the way at the end of startup, so you'll start network services without having network and they'll be very sad about that. what possible reason do you have for not configuring your DHCP server statically?
 
except that happens all the way at the end of startup, so you'll start network services without having network and they'll be very sad about that. what possible reason do you have for not configuring your DHCP server statically?
In my homelab I have /etc/exports with

Code:
/ -mapall="root

and all my workstations mount this to /net. I'm sure it's bad practice but it's my playground.

The problem is that I have just discovered that if I boot a computer diskelessly it uses the same rc.conf and uses the same IP address because it's set staticaly and this causes all sorts of problems and makes my LAN unusable. If the IP address was set dynamically a different IP address would be used.

Unfortunately I can't figure a way of doing what I wanted, so it's back to the drawing board.
 
Back
Top