Wednesday, July 24, 2019

pxe boot - How to configure PXE/Tftp in dhcp.conf on vmware Fusion 7 Pro with static reservations



I'm senior devops engineer with a deployment system to ship a couple thousand linux machines a week. I'm using vmware fusion 7 pro to do this, and I'm having a little trouble with pxe booting.



I ran into this little issue, so I thought i'd do a quick writeup to maybe save someone 15 mins. If someone knows a better way, I'd love to hear it.



I'm playing with PXE booting some containers. I want VMware Fusion to handle DHCP, and I want the VM's to be Nat'ed with my Mac for outside access, thus I need to use vmnet8 by default. I also have several virtual machines that should have static reservations to mimic the production network this system will reside on. So, I edit /Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf



I need to add two simple lines to the subnet declaration for tftp:




  next-server 192.168.87.20;  
filename "pxelinux.0";


The problem is the subnet declaration (line 26 of the stock file) is in the forbidden zone:



###### VMNET DHCP Configuration. Start of "DO NOT MODIFY SECTION" #####



If you change stuff in the forbidden zone then restart vmware fusion, or restart its networking, it rudely replaces the whole dhcpd.conf file with an auto-generated one. It does rotate the existing one to a backup, but only one rotation (3 would be less rude, so would a prompt and a log entry).


Answer



This is How To Add the PXE Boot Configuration in the relevant VMware Fusion dhcp.conf file.



The "proper" solution is to simply redeclare the whole subnet block below the "DO NOT MODIFY" section. So, to add the next-server and filename options for PXE booting, I had to add the following:



####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######  
subnet 192.168.87.0 netmask 255.255.255.0 {
range 192.168.87.128 192.168.87.254;
option broadcast-address 192.168.87.255;

option domain-name-servers 192.168.87.2;
option domain-name localdomain;
default-lease-time 1800; # default is 30 minutes
max-lease-time 7200; # default is 2 hours
option netbios-name-servers 192.168.87.2;
option routers 192.168.87.2;
next-server 192.168.87.20;
filename "pxelinux.0";
}
#

host cmhpxe {
hardware ethernet 00:0C:29:DF:06:7F;
fixed-address 192.168.87.20;
}
#


The fun way to reconfigure and restart DHCP without restarting fusion:



alias vm_restartdhcpd='sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --configure ;   

sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --stop;
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start'

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...