I was wondering if a single machine (with several network interfaces) can be, at the same time, a DHCP server and a DHCP client, that is the server would dynamically attribute an IP address to an other interface ?
-
Yes it is possible (at least with a DHCP relay) but what's the point of such a topology?– JFLJan 10, 2019 at 14:33
-
The goal was to use a single virtual machine as part of a course, install the DHCP server and test it in that VM.– Greg82Jan 10, 2019 at 15:22
-
Considering how easy it is to setup a VM, I would rather go for 2 VMs, this will be much more like a real life case.– JFLJan 10, 2019 at 15:56
-
Yes, I agree, and I think I will retain this solution. But my question was only by pure curiosity :)– Greg82Jan 10, 2019 at 16:00
1 Answer
Cetainly it's possible, and indeed moderately common for small routers linking to ISPs.
The external interface to the ISP gets a dynamic address from the ISP (by LCP or DHCP as appropriate), and very often is a DHCP server for the local clients on some internal interface.
This is a portion of a Cisco router configuration with exactly that functionality:
ip dhcp pool 1
network 192.168.241.0 255.255.255.0
default-router 192.168.241.1
dns-server 8.8.8.8
interface Vlan1000
ip address dhcp
ip nat outside
-
As I read the quesiton, it is about the same machine being both the DHCP client and the DHCP server that will respond for its own request.– JFLJan 10, 2019 at 14:26
-
Not exactly "for its own request". I assume the machine has TWO interfaces, one of them being dynamically assigned by the DHCP server that listens on the other one– Greg82Jan 10, 2019 at 15:24