Full auto RTR-01, seems functionnal
This commit is contained in:
parent
5438f331e7
commit
2ccc3b1fd3
@ -10,28 +10,55 @@ echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
|||||||
|
|
||||||
Rename-computer RTR-01
|
Rename-computer RTR-01
|
||||||
|
|
||||||
$adapter = Get-NetAdapter | ? {$_.MacAddress -eq "00-15-5D-02-70-00"}
|
$adapts = Get-NetAdapter
|
||||||
Rename-NetAdapter -Name "Eth*" -NewName "Arc-SRV"
|
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
|
$MaskBits = 24 # This means subnet mask = 255.255.255.0
|
||||||
$Gateway = "192.168.8.254"
|
|
||||||
$Dns = "9.9.9.9"
|
|
||||||
$IPType = "IPv4"
|
$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 `
|
$adapter | New-NetIPAddress `
|
||||||
-AddressFamily $IPType `
|
-AddressFamily $IPType `
|
||||||
-IPAddress $IP `
|
-IPAddress $IP `
|
||||||
-PrefixLength $MaskBits `
|
-PrefixLength $MaskBits `
|
||||||
-DefaultGateway $Gateway
|
|
||||||
|
|
||||||
|
#WAN
|
||||||
|
|
||||||
|
$adapter = Get-NetAdapter | ? {$_.Name -eq "WAN"}
|
||||||
|
$IP = "192.168.255.8"
|
||||||
|
$adapter | New-NetIPAddress `
|
||||||
|
-AddressFamily $IPType `
|
||||||
|
-IPAddress $IP `
|
||||||
|
-PrefixLength $MaskBits `
|
||||||
|
-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 Routing and necessary linked roles
|
||||||
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
|
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
|
Set-NetConnectionProfile -NetworkCategory Private
|
||||||
$Params = @{
|
$Params = @{
|
||||||
"Name" = 'vm-monitoring-icmpv4'
|
"Name" = 'vm-monitoring-icmpv4'
|
||||||
@ -39,7 +66,9 @@ $Params = @{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Set-NetFirewallRule @Params
|
Set-NetFirewallRule @Params
|
||||||
|
|
||||||
# Activate NAT and DHCP Relay
|
# Activate NAT and DHCP Relay
|
||||||
|
echo "Activate NAT and DHCP Relay"
|
||||||
netsh routing ip relay install
|
netsh routing ip relay install
|
||||||
|
|
||||||
netsh routing ip add interface name="WAN" state=enable
|
netsh routing ip add interface name="WAN" state=enable
|
||||||
@ -72,7 +101,9 @@ Set-NetFirewallRule @Params
|
|||||||
# Add routes
|
# Add routes
|
||||||
|
|
||||||
route add -p 192.168.8.0/24 192.168.8.254
|
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.255.0/24 192.168.255.8
|
||||||
route add -p 192.168.128.8/24 192.168.255.128
|
route add -p 192.168.128.8/24 192.168.255.128
|
||||||
route add -p 0.0.0.0/0 192.168.255.254
|
route add -p 0.0.0.0/0 192.168.255.254
|
||||||
|
|
||||||
|
Read-Host "Finished???"
|
||||||
|
@ -12,8 +12,7 @@ Rename-computer "SRV-1"
|
|||||||
|
|
||||||
# Set IP for pre-defined MAC addresses
|
# Set IP for pre-defined MAC addresses
|
||||||
|
|
||||||
$adapter = Get-NetAdapter | ? {$_.MacAddress -eq "00-15-5D-02-70-00"}
|
$adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-SRV"}
|
||||||
Rename-NetAdapter -Name "Eth*" -NewName "Arc-SRV"
|
|
||||||
|
|
||||||
#Arc-SRV
|
#Arc-SRV
|
||||||
$IP = "192.168.8.1"
|
$IP = "192.168.8.1"
|
||||||
|
@ -42,16 +42,15 @@ $vms = @{
|
|||||||
Generation = '2'
|
Generation = '2'
|
||||||
MemoryStartupBytes = 1024Mb
|
MemoryStartupBytes = 1024Mb
|
||||||
VHDPath = "d:\VHD\RTR-01.vhdx"
|
VHDPath = "d:\VHD\RTR-01.vhdx"
|
||||||
SwitchName = 'Arc-SRV'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
New-VM @vms
|
New-VM @vms
|
||||||
Set-VMMemory RTR-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
Set-VMMemory RTR-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
||||||
$vmadapter = Get-VMNetworkAdapter -VMName "RTR-01"
|
$vmadapter = Get-VMNetworkAdapter -VMName "RTR-01"
|
||||||
Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -StaticMacAddress 00155D027001
|
#Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Arc-SRV" -DeviceNaming on
|
||||||
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "Arc-CLI"
|
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "Arc-CLI" -Name "Arc-Cli" -DeviceNaming on
|
||||||
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "WAN"
|
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
|
# RTR-02
|
||||||
|
|
||||||
|
14
Memo.ps1
14
Memo.ps1
@ -2,6 +2,20 @@
|
|||||||
Get-VMNetworkAdapter -VMName RTR-01|Format-Table -Property Switchname,Macaddress -HideTableHeaders |Export-Csv D:\scripts\Guests\MACS\test.csv -NoTypeInformation
|
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
|
#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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user