Scripts/Setup-HyperV-Gateway.ps1
### New internal VNET New-VMSwitch -Name AP -SwitchType Private ### New External VNET for NAT New-VMSwitch -Name WAN_NAT -SwitchType Internal ### Get interface Index WAN_NAT $Interface = Get-NetIPInterface -AddressFamily IPv4 | Where-Object InterfaceAlias -Like "*WAN_NAT*" ### New NAT IP Address New-NetIPAddress -IPAddress 10.255.255.254 -PrefixLength 24 -InterfaceIndex $Interface.ifIndex New-NetNat -Name WAN_NAT -InternalIPInterfaceAddressPrefix 10.255.255.0/24 ### Create Gateway VM $VMName = "JT-Gateway2" $IsoFile = "C:\Users\jterlouw\Downloads\OPNsense-21.7.1-OpenSSL-dvd-amd64.iso" New-VM -Name $VMName -MemoryStartupBytes 1GB -Generation 1 -Path C:\Hyper-V\ -NewVHDPath "$($VMName).vhdx" -NewVHDSizeBytes 10GB -BootDevice CD Set-VMMemory $VMName -DynamicMemoryEnabled $false -Verbose Set-VM $VMName -AutomaticStartAction Nothing -AutomaticStopAction ShutDown -AutomaticCheckpointsEnabled $false -Verbose Get-VM | Get-VMDvdDrive | Set-VMDvdDrive -Path $IsoFile $InternalVMSwitches = Get-VMSwitch | Where-Object { ($_.Name -ne "Default Switch") } $VMInterfaces = Get-VMNetworkAdapter -VMName $VMName $InternalVMSwitches | ForEach-Object { if ($VMInterfaces.Name -notcontains $_.Name) { Add-VMNetworkAdapter -VMName $VMName -SwitchName $_.Name -Name $_.Name } } Get-VMNetworkAdapter -VMName $VMName -Name "Network Adapter" | Remove-VMNetworkAdapter Get-VMNetworkAdapter -VMName $VMName Start-VM $VMName # Remove-VMAndDestroyData $VMName ### OPNSense install <# Login: installer Config alleen WAN IP NAT rules aanmaken Floating Firewall rules aanmaken Interfaces toewijzen DHCPv4 enablen SSH aan: System > Settings > Administration #> New-HyperVAutopilotVM -VMName G09-BuildJaap03 -Path C:\Hyper-V\ -vSwitch AP -StartVM -IsoFile C:\temp\WI\Customers\ALL_W10_EN_21H2_X64_General.iso |