2021-04-22 11:05:32 +02:00
# Made by Alexandre SIMAO
2021-04-09 15:51:30 +02:00
# GPLv3
# Script to install and configure a Fuckdows Server 2016 as a router
2021-04-23 12:54:01 +02:00
# RTR-02 Only
2021-04-09 15:51:30 +02:00
2021-04-20 10:49:35 +02:00
echo " Shamefully made by Alexandre Simao. Pardon-me M. Stallman "
2021-04-23 12:54:01 +02:00
### Change VM name
2021-05-11 10:39:12 +02:00
echo " Changing computer Name as RTR-02 "
2021-04-22 11:05:32 +02:00
Rename-computer RTR - 02
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-23 12:54:01 +02:00
#End
2021-04-09 15:51:30 +02:00
2021-04-23 12:54:01 +02:00
### Rename Adapters by parsing the VM device name
2021-05-11 10:39:12 +02:00
echo " Rename adapters "
2021-04-22 11:05:32 +02:00
$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
}
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-23 12:54:01 +02:00
# End
### Pausing to let things settle
2021-04-19 16:04:47 +02:00
2021-05-10 11:49:17 +02:00
echo " Sleeping 10s "
2021-04-22 17:26:29 +02:00
Sleep 10
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-22 15:58:53 +02:00
2021-05-11 10:39:12 +02:00
#End
2021-04-09 15:51:30 +02:00
2021-04-22 11:05:32 +02:00
#Bou-LAN IP conf
2021-04-09 15:51:30 +02:00
2021-05-11 10:39:12 +02:00
echo " IP conf via netsh fort Bou-LAN "
2021-04-23 17:37:49 +02:00
netsh interface ip set address name = " Bou-LAN " static 192.168 . 128 . 254 255.255 . 255 . 0
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-22 11:05:32 +02:00
2021-05-10 17:16:04 +02:00
#WAN
2021-04-22 11:05:32 +02:00
2021-05-11 10:39:12 +02:00
echo " IP conf via netsh for WAN "
2021-06-01 10:18:07 +02:00
netsh interface ip set address name = " WAN " static 192.168 . 255 . 128 255.255 . 255 . 0
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-22 11:05:32 +02:00
2021-04-23 12:54:01 +02:00
# END
### DNS Conf for all InterfaceAlias
2021-05-11 10:39:12 +02:00
2021-05-11 16:46:18 +02:00
echo " Configuring Dns for 192.168.8.1 on all interfaces "
foreach ( $c in Get-NetAdapter ) { write-host 'Setting DNS for' $c . interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c . interfaceindex -ServerAddresses ( '192.168.8.1' ) }
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-23 12:54:01 +02:00
#End
2021-04-20 16:08:08 +02:00
2021-05-10 12:18:00 +02:00
### Install VPN (?)
2021-04-09 15:51:30 +02:00
2021-05-11 10:39:12 +02:00
echo " installing and activating routing role "
2021-05-10 12:48:32 +02:00
Install-windowsFeature -Name Routing -IncludemanagementTools
2021-05-10 12:18:00 +02:00
Install-remoteAccess -VpnType Routingonly
2021-04-23 12:54:01 +02:00
set-service RemoteAccess -StartupType Automatic
Start-Service RemoteAccess
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-22 11:05:32 +02:00
2021-04-23 12:54:01 +02:00
#END
### Set connection as Private
2021-05-11 10:39:12 +02:00
echo " Set connection as private on all Interface "
2021-05-10 12:31:36 +02:00
Get-NetAdapter | Set-NetConnectionProfile -NetworkCategory Private
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-23 12:54:01 +02:00
#END
2021-05-10 12:31:36 +02:00
### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes ###
2021-04-23 12:54:01 +02:00
2021-05-11 10:39:12 +02:00
echo " change firewall rules to accept ICMP probes "
2021-05-10 12:31:36 +02:00
Get-NetFirewallRule -name " *ICMP4-ERQ-In* " | Enable-NetFirewallRule
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-20 16:08:08 +02:00
2021-04-23 12:54:01 +02:00
#END
2021-05-11 10:39:12 +02:00
### Activate routing and DHCP Relay
2021-05-10 12:31:36 +02:00
2021-05-11 10:39:12 +02:00
echo " Activate DHCP Relay via netsh "
2021-04-20 16:08:08 +02:00
2021-04-09 15:51:30 +02:00
netsh routing ip relay install
2021-04-22 11:05:32 +02:00
netsh routing ip add interface name = " Bou-LAN " state = enable
2021-04-09 15:51:30 +02:00
netsh routing ip add interface name = " WAN " state = enable
netsh routing ip relay add interface " Bou-LAN "
2021-05-10 11:43:54 +02:00
netsh rout ip rel set int BOU-LAN min = 0
2021-04-22 11:05:32 +02:00
netsh routing ip relay add interface " WAN "
netsh rout ip rel set int WAN min = 0
netsh routing ip relay add dhcpserver 192.168 . 8 . 1
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-09 15:51:30 +02:00
2021-04-23 12:54:01 +02:00
### Add routes
2021-04-09 15:51:30 +02:00
2021-04-23 12:54:01 +02:00
echo " Adding routes "
2021-04-09 15:51:30 +02:00
route add -p 192.168 . 8 . 0 / 24 192.168 . 255 . 8
2021-04-22 11:05:32 +02:00
route add -p 192.168 . 12 . 0 / 24 192.168 . 255 . 8
2021-04-19 16:04:47 +02:00
route add -p 0.0 . 0 . 0 / 0 192.168 . 255 . 254
2021-05-11 10:39:12 +02:00
echo " Done! "
2021-04-22 11:05:32 +02:00
2021-05-12 18:01:39 +02:00
# Add BGINFO autostart
Copy-Item " c:\Program Files\BGINFO\bginfo.bat " " C:\Users\Administrateur\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup "
2021-05-11 10:39:12 +02:00
Read-Host " Press enter to reboot "
2021-05-10 11:43:22 +02:00
Restart-Computer