Fix: Del on-link routes

This commit is contained in:
Alex 2021-04-22 10:46:50 +02:00
parent b26848f6af
commit dcf571e06d
4 changed files with 84 additions and 17 deletions

View File

@ -101,9 +101,6 @@ Set-NetFirewallRule @Params
# Add routes # 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.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

64
Guests/RTR-02_OLD.ps1 Normal file
View File

@ -0,0 +1,64 @@
# Alexandre SIMAO
# GPLv3
# Script to install and configure a Fuckdows Server 2016 as a router
# RTR-02 Only
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
# Change the poor machine name
Rename-computer "RTR-02"
Rename-NetAdapter -Name "Ethernet" -NewName "Bou-LAN"
Rename-NetAdapter -Name "Ethernet 2" -NewName "WAN"
netsh interface ip set address "WAN" static 192.168.255.8 255.255.255.0 192.168.255.254
netsh interface ip set address "Bou-LAN" static 192.168.128.254 255.255.255.0
netsh interface ip set dns name="WAN" static 9.9.9.9.
# Install Routing and necessary linked roles
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
set-service RemoteAccess -StartupType Automatic
Start-Service RemoteAccess
# Display interfaces and active forwarding for all of thm via Regedit
netsh inter show inter
Set-NetConnectionProfile -NetworkCategory Private
$Params = @{
"Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow'
}
Set-NetFirewallRule @Params
# Activate NAT and DHCP Relay
netsh routing ip relay install
netsh routing ip add interface name="WAN" state=enable
netsh routing ip relay add interface "WAN"
netsh rout ip rel set int ARC-CLI min=0
netsh routing ip relay add interface "Bou-LAN"
netsh rout ip rel set int ARC-SRV min=0
netsh -f ./Bou-LAN.conf
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
$Params = @{
"Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow'
}
Set-NetFirewallRule @Params
# Add routes
route add -p 192.168.8.0/24 192.168.255.8
route add -p 192.168.12.0.24 192.168.255.8
route add -p 192.168.255.0/24 192.168.255.128
route add -p 192.168.128.0/24 192.168.128.254
route add -p 0.0.0.0/0 192.168.255.254

View File

@ -10,6 +10,14 @@ echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
#Rename this piece of garbage #Rename this piece of garbage
Rename-computer "SRV-1" Rename-computer "SRV-1"
# Rename interfaces
$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
}
# Set IP for pre-defined MAC addresses # Set IP for pre-defined MAC addresses
$adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-SRV"} $adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-SRV"}
@ -18,7 +26,6 @@ $adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-SRV"}
$IP = "192.168.8.1" $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" $Gateway = "192.168.8.254"
$Dns = "9.9.9.9"
$IPType = "IPv4" $IPType = "IPv4"
$adapter | New-NetIPAddress ` $adapter | New-NetIPAddress `
@ -27,6 +34,9 @@ $adapter | New-NetIPAddress `
-PrefixLength $MaskBits ` -PrefixLength $MaskBits `
-DefaultGateway $Gateway -DefaultGateway $Gateway
# Set DNS
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
# Install the DHCP role (Management tools if you love Metrosexual UI) # Install the DHCP role (Management tools if you love Metrosexual UI)
Install-WindowsFeature DHCP -IncludeManagementTools Install-WindowsFeature DHCP -IncludeManagementTools
@ -86,9 +96,9 @@ route add -p 0.0.0.0/0 192.168.8.254
# Change DHCP server options # Change DHCP server options
Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -OptionID 3 -Value 192.168.128.254 Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -OptionID 3 -Value 192.168.128.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 9.9.9.9 Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -DnsServer 9.9.9.9
Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -OptionID 3 -Value 192.168.12.254 Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -OptionID 3 -Value 192.168.12.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 9.9.9.9 Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -DnsServer 9.9.9.9
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -OptionID 3 -Value 192.168.8.254 Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -OptionID 3 -Value 192.168.8.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 9.9.9.9 Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 9.9.9.9

View File

@ -7,7 +7,6 @@ echo "CC BY-NC-SA 4.0"
# Region SRV-01 # Region SRV-01
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\SRV-01.vhdx cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\SRV-01.vhdx
Mount-VHD d:\VHD\SRV-01.vhdx Mount-VHD d:\VHD\SRV-01.vhdx
@ -20,14 +19,12 @@ $vms = @{
Generation = '2' Generation = '2'
MemoryStartupBytes = 1024Mb MemoryStartupBytes = 1024Mb
VHDPath = "d:\VHD\$VMName.vhdx" VHDPath = "d:\VHD\$VMName.vhdx"
SwitchName = 'Arc-SRV'
} }
New-VM @vms New-VM @vms
Set-VMMemory SRV-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB Set-VMMemory SRV-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
$vmadapter = Get-VMNetworkAdapter -VMName "SRV-01" $vmadapter = Get-VMNetworkAdapter -VMName "SRV-01"
Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -StaticMacAddress 00155D027000 Add-VMNetworkAdapter -VMName "SRV-01" -SwitchName "Arc-SRV" -Name "Arc-SRV" -DeviceNaming on
# RTR-01 # RTR-01
@ -67,16 +64,15 @@ $vms = @{
Generation = '2' Generation = '2'
MemoryStartupBytes = 1024Mb MemoryStartupBytes = 1024Mb
VHDPath = "d:\VHD\$VMName.vhdx" VHDPath = "d:\VHD\$VMName.vhdx"
SwitchName = 'Bou-LAN'
} }
New-VM @vms New-VM @vms
Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
$vmadapter = Get-VMNetworkAdapter -VMName "RTR-01" $vmadapter = Get-VMNetworkAdapter -VMName "RTR-02"
Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -StaticMacAddress 00155D027004 Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "Arc-CLI" -Name "Bou-LAN" -DeviceNaming on
Add-VMNetworkAdapter -VMName RTR-02 -SwitchName "WAN" -StaticMacAddress 00155D027005 Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
# RTR-03 # RTR-03
@ -102,9 +98,9 @@ New-VM @vms
Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
$vmadapter = Get-VMNetworkAdapter -VMName "RTR-01" $vmadapter = Get-VMNetworkAdapter -VMName "RTR-03"
Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -StaticMacAddress 00155D027006 Add-VMNetworkAdapter -VMName "RTR-03" -SwitchName "Aston" -Name "Aston" -DeviceNaming on
Add-VMNetworkAdapter -VMName RTR-03 -SwitchName "Aston" -StaticMacAddress 00155D027007 Add-VMNetworkAdapter -VMName "RTR-03" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
Start-VM -Name RTR* Start-VM -Name RTR*