74 lines
2.3 KiB
PowerShell
74 lines
2.3 KiB
PowerShell
# Alexandre SIMAO
|
|
# GPLv3
|
|
|
|
# Script to install and configure a Fuckdows Server 2016 as a router
|
|
# RTR-01 Only
|
|
|
|
# Change the poor machine name
|
|
|
|
Read-host "Script for RTR-01"
|
|
Read-host "WARNING: Plug-in in this order Arc-SRV, Arc-CLI and WAN"
|
|
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
|
|
|
Rename-computer RTR-01
|
|
|
|
Rename-NetAdapter -Name "Ethernet" -NewName "Arc-SRV"
|
|
Rename-NetAdapter -Name "Ethernet 2" -NewName "Arc-CLI"
|
|
Rename-NetAdapter -Name "Ethernet 3" -NewName "WAN"
|
|
|
|
# Install Routing and necessary linked roles
|
|
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
|
|
#Install-remoteAccess -VpnType Vpn
|
|
|
|
Set-NetConnectionProfile -networkcategory private
|
|
|
|
# Change IP and DNS
|
|
#
|
|
|
|
netsh interface ip set address "WAN" static 192.168.255.8 255.255.255.0 192.168.255.254
|
|
netsh interface ip set address "Arc-CLI" static 192.168.12.254 255.255.255.0
|
|
netsh interface ip set address "Arc-SRV" static 192.168.8.254 255.255.255.0
|
|
netsh interface ip set dns name="WAN" static 9.9.9.9
|
|
|
|
# Display interfaces and active forwarding for all of thm via Regedit
|
|
netsh inter show inter
|
|
Set-ItemProperty -path 'HKLM:\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet`
|
|
\Services\Tcpip\Parameters' -Name 'IPEnableRouter' -Value '0x00000001'
|
|
Set-NetConnectionProfile -NetworkCategory Private
|
|
|
|
# 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 "Arc-CLI"
|
|
netsh rout ip rel set int ARC-SRV min=0
|
|
netsh routing ip relay add interface "Arc-SRV"
|
|
netsh rout ip rel set int WAN min=0
|
|
netsh routing ip relay add dhcpserver 192.168.8.1
|
|
|
|
set-service RemoteAccess -StartupType Automatic
|
|
Start-Service RemoteAccess
|
|
|
|
netsh -f ./Arc-CLI.conf
|
|
netsh -f ./Arc-SRV.conf
|
|
netsh -f ./WAN.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.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 0.0.0.0/0 192.168.255.254
|