DHCP Proxies come in handy when provisioning to multiple networks while not maintaining multiple VLANs on the DHCP-Server itself. The easiest way to accomplish this is by running multiple DHCP-Proxies on the router/firewall (in my case, a MikroTik router).
Some Presets for DHCP:
- Server IP: 172.31.10.8
- Networks: 172.31.20.0/24, 172.31.30.0/24
First, let's set up the subnets on the DHCP-Server:
[archy@dhcp-server ~]$ sudo vim /etc/dhcp/dhcpd.conf
subnet 172.31.20.0 netmask 255.255.255.0 {
range 172.31.20.100 172.31.20.199;
option subnet-mask 255.255.255.0;
option domain-name-servers 172.31.10.5, 172.31.10.6;
option ntp-servers 172.31.10.5, 172.31.0.6;
option routers 172.31.20.254;
option broadcast-address 172.31.20.255;
filename "pxelinux.0";
next-server 172.31.10.10;
}
subnet 172.31.30.0 netmask 255.255.255.0 {
range 172.31.30.100 172.31.30.199;
option subnet-mask 255.255.255.0;
option domain-name-servers 172.31.10.5, 172.31.10.6;
option ntp-servers 172.31.10.5, 172.31.0.6;
option routers 172.31.30.254;
option broadcast-address 172.31.30.255;
filename "pxelinux.0";
next-server 172.31.10.10;
}
There are some extra options set, such as internal DNS- and NTP-Servers, as well as the PXE-Server which is a foreman in my case. To activate the changes, restart the dhcpd.service
[archy@dhcp-server ~]$ sudo systemctl restart dhcpd.service
Now that the dhcpd-side is set-up, let's continue with the router. Since I'm using RouterOS(MikroTik), I'll be using the CLI because I'm most familiar with that on RouterOS.
[archy@MikroTik] > ip dhcp-relay add name=internal dhcp-server 172.31.10.8 interface=vlan20 local-address=172.31.20.254 disabled=no
[archy@MikroTik] > ip dhcp-relay add name=dmz dhcp-server 172.31.10.8 interface=vlan30 local-address=172.31.30.254 disabled=no
[archy@MikroTik] > ip dhcp-relay print
Flags: X - disabled, I - invalid
# NAME INTERFACE DHCP-SERVER LOCAL-ADDRESS
0 internal vlan20 172.31.10.8 172.31.20.254
1 dmz vlan30 172.31.10.8 172.31.30.254
That concludes the DHCP-Proxy setup on the MikroTik Router. You can check if everything works as intended by provisioning a VM in one of the Subnets (assuming they're added to foreman already).
Feel free to comment and / or suggest a topic.
Comments
Post a Comment