Although some settings cannot be changed while a virtual machine is running (including changing static/dynamic MAC, or the static MAC itself), notice that the boxes under the static MAC address radio button are now populated with the first MAC address in the range defined in the registry: 00-15-5D-C8-6A-00.
I have a scenario that involves building out a ton of virtual machines in Hyper-V, I cannot use SCVMM and must use a scripted method to create these VMs. I have a CSV with all required information filled out so my Create-VM code works and creates the VMs with no problem.
My issue is, I would like to assign a static MAC address to the VM NICs during creation. This will help me setup DHCP IP reservations as per my lab requirements. Once I create the VM, I do this command:
At this time I have a NIC already added to this VM and in theory it should set the MAC address to whatever $Config.intMAC holds but it does not, the radio box is still selected for dynamic MAC address and the static value remains unselected and all 0's.
How would I assign the MAC pro-grammatically?
KPSKPS1 Answer
try:
remember that if you use a variable that the mac address is a string.
Jim BJim BNot the answer you're looking for? Browse other questions tagged scriptingpowershellhyper-vwindows-server-2012 or ask your own question.
I have read numerous SO posts with this one being almost identical but I cannot get this to work.
I have a single wireless NIC in my notebook running Windows 10 Pro 1803. This is configured with a static IP address of 192.168.40.111.
I want the VM to have a static IP address of 192.168.40.101 and be accessible to other machines on the 192.168.40/24 network. It will ultimately get Internet access via a host 192.168.40.2.
So based on what I have read I need to use Hyper-V's virtual switch manager to create an 'External' switch which I have done called 'Virtual Switch - Static' as follows:
and then use that for the VM. So far so good. However when I look at what is in the network adapters I see:
However if I change the IP address of the highlighted connection it changes the IP address of the wireless card as well which is what I don't want.
So how do I configure things so that the VM has its static address of 192.168.40.101 and the wireless card maintains its static address of 192.168.40.111?
1 Answer
IP addresses need to be unique on a subnet and each device needs it's own. When you assign the IP to the virtual switch, that gives the host PC running Hyper-V its IP address on your network, the 192.168.40.111 address.
To assign an IP to a VM on the same subnet as the virtual switch, you need to assign the IP, the 192.168.40.101 address, directly in the VM's OS, i.e. Ubuntu.
You will also need to assign the subnet or netmask and gateway manually in the VM. You can choose to manually assign the DNS as well. You can get all this information from your Windows 10 host via the ipconfig command.
- Open a PowerShell or command prompt (cmd) by clicking Start and typing the name of either.
- Click to launch PowerShell or the command prompt
- type ipconfig /all and press enter
- You may need to scroll to see the results from your wifi card, but you can find all the information you need. Highlighted in the example. You will want to use your information, not the information highlighted.
Assuming you're using Ubuntu 18.04, here's how: https://linuxconfig.org/how-to-configure-static-ip-address-on-ubuntu-18-04-bionic-beaver-linux
- Click on top right network icon and select settings corresponding to the network interface you wish to assign with the static IP address.
- Next, click on the gear box icon next to your network connection you wish to configure. This could be wired or wireless connection.
- Select IPv4 from the top menu.
- Select Manual for the IPv4 settings, enter your desired configuration and hit Apply
- Restart your network by ON/OFF switch.