Full auto RTR-01, seems functionnal

This commit is contained in:
Alex 2021-04-21 17:59:14 +02:00
parent 5438f331e7
commit 2ccc3b1fd3
4 changed files with 59 additions and 16 deletions

View File

@ -10,28 +10,55 @@ echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
Rename-computer RTR-01
$adapter = Get-NetAdapter | ? {$_.MacAddress -eq "00-15-5D-02-70-00"}
Rename-NetAdapter -Name "Eth*" -NewName "Arc-SRV"
$adapts = Get-NetAdapter
foreach ($adapt in $adapts) {
$HVName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue
Rename-Netadapter -name $adapt.name -NewName $HVName
}
#Général IP configure
#Arc-SRV
$IP = "192.168.8.1"
$MaskBits = 24 # This means subnet mask = 255.255.255.0
$Gateway = "192.168.8.254"
$Dns = "9.9.9.9"
$IPType = "IPv4"
#Arc-SRV IP conf
$adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-SRV"}
$IP = "192.168.8.254"
$adapter | New-NetIPAddress `
-AddressFamily $IPType `
-IPAddress $IP `
-PrefixLength $MaskBits
#Arc-CLI
$adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-CLI"}
$IP = "192.168.12.254"
$adapter | New-NetIPAddress `
-AddressFamily $IPType `
-IPAddress $IP `
-PrefixLength $MaskBits `
#WAN
$adapter = Get-NetAdapter | ? {$_.Name -eq "WAN"}
$IP = "192.168.255.8"
$adapter | New-NetIPAddress `
-AddressFamily $IPType `
-IPAddress $IP `
-PrefixLength $MaskBits `
-DefaultGateway $Gateway
-DefaultGateway "192.168.255.254"
#DNS Conf for all InterfaceAlias
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
# Install Routing and necessary linked roles
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
#Install-remoteAccess -VpnType Vpn
#Install VPN
echo "Install-remoteAccess -VpnType Vpn"
Install-remoteAccess -VpnType Vpn
Set-NetConnectionProfile -NetworkCategory Private
$Params = @{
"Name" = 'vm-monitoring-icmpv4'
@ -39,7 +66,9 @@ $Params = @{
}
Set-NetFirewallRule @Params
# Activate NAT and DHCP Relay
echo "Activate NAT and DHCP Relay"
netsh routing ip relay install
netsh routing ip add interface name="WAN" state=enable
@ -72,7 +101,9 @@ Set-NetFirewallRule @Params
# Add routes
route add -p 192.168.8.0/24 192.168.8.254
route add -p 192.168.12.0.24 192.168.12.254
route add -p 192.168.12.0/24 192.168.12.254
route add -p 192.168.255.0/24 192.168.255.8
route add -p 192.168.128.8/24 192.168.255.128
route add -p 0.0.0.0/0 192.168.255.254
Read-Host "Finished???"

View File

@ -12,8 +12,7 @@ Rename-computer "SRV-1"
# Set IP for pre-defined MAC addresses
$adapter = Get-NetAdapter | ? {$_.MacAddress -eq "00-15-5D-02-70-00"}
Rename-NetAdapter -Name "Eth*" -NewName "Arc-SRV"
$adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-SRV"}
#Arc-SRV
$IP = "192.168.8.1"

View File

@ -42,16 +42,15 @@ $vms = @{
Generation = '2'
MemoryStartupBytes = 1024Mb
VHDPath = "d:\VHD\RTR-01.vhdx"
SwitchName = 'Arc-SRV'
}
New-VM @vms
Set-VMMemory RTR-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
$vmadapter = Get-VMNetworkAdapter -VMName "RTR-01"
Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -StaticMacAddress 00155D027001
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "Arc-CLI"
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "WAN"
#Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Arc-SRV" -DeviceNaming on
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "Arc-CLI" -Name "Arc-Cli" -DeviceNaming on
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "Arc-SRV" -Name "Arc-SRV" -DeviceNaming on
# RTR-02

View File

@ -2,6 +2,20 @@
Get-VMNetworkAdapter -VMName RTR-01|Format-Table -Property Switchname,Macaddress -HideTableHeaders |Export-Csv D:\scripts\Guests\MACS\test.csv -NoTypeInformation
#echo $VMNETADAP | out-file -FilePath D:\scripts\Guests\MACS\temp.txt
#Arc-SRV
$IP = "192.168.8.1"
$MaskBits = 24 # This means subnet mask = 255.255.255.0
$Gateway = "192.168.8.254"
$Dns = "9.9.9.9"
$IPType = "IPv4"
$adapter | New-NetIPAddress `
-AddressFamily $IPType `
-IPAddress $IP `
-PrefixLength $MaskBits `
-DefaultGateway $Gateway