Aston-HyperV-Code/RTR-03.ps1

44 lines
1.2 KiB
PowerShell
Raw Normal View History

2021-04-09 15:51:30 +02:00
# Alexandre SIMAO
# GPLv3
2021-04-19 17:06:39 +02:00
### TODO ?
2021-04-09 15:51:30 +02:00
# Script to install and configure a Fuckdows Server 2016 as a router
# RTR-03 Only
# Change the poor machine name
2021-04-20 10:49:35 +02:00
Rename-computer "RTR-03"
2021-04-19 17:06:39 +02:00
2021-04-20 10:49:35 +02:00
Rename-NetAdapter -Name "Ethernet" -NewName "WAN"
Rename-NetAdapter -Name "Ethernet 2" -NewName "Aston"
2021-04-19 17:06:39 +02:00
2021-04-09 15:51:30 +02:00
# Install Routing and necessary linked roles
2021-04-19 17:06:39 +02:00
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
2021-04-09 15:51:30 +02:00
set-service RemoteAccess -StartupType Automatic
Start-Service RemoteAccess
2021-04-19 16:04:47 +02:00
netsh interface ip set address "WAN" static 192.168.255.254 255.255.255.0
2021-04-19 17:06:39 +02:00
netsh interface ip set dns name="WAN" static 9.9.9.9
2021-04-19 16:04:47 +02:00
2021-04-09 15:51:30 +02:00
# Activate NAT
netsh routing ip nat install
netsh routing ip nat add interface name="WAN" mode=PRIVATE
netsh routing ip nat add interface name="Aston" mode=FULL
2021-04-19 17:06:39 +02:00
Set-NetConnectionProfile -networkcategory private
2021-04-09 15:51:30 +02:00
# 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.128.0/24 192.168.255.128
2021-04-19 16:04:47 +02:00
route add -p 192.168.255.0/24 192.168.255.254