2021-04-09 11:02:54 +02:00
|
|
|
|
# Alexandre Simao
|
|
|
|
|
# GPL v3
|
|
|
|
|
|
2021-04-19 17:06:39 +02:00
|
|
|
|
# SRV-01 ONLY
|
2021-04-20 10:49:35 +02:00
|
|
|
|
# TODO : exclusion/attribution fields
|
|
|
|
|
# Rename interfaces
|
|
|
|
|
#
|
2021-04-20 15:25:09 +02:00
|
|
|
|
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
2021-04-19 17:06:39 +02:00
|
|
|
|
|
2021-04-09 11:02:54 +02:00
|
|
|
|
#Rename this piece of garbage
|
2021-04-20 10:49:35 +02:00
|
|
|
|
Rename-computer "SRV-1"
|
2021-04-21 12:16:54 +02:00
|
|
|
|
|
|
|
|
|
# Set IP for pre-defined MAC addresses
|
|
|
|
|
|
|
|
|
|
$adapter = Get-NetAdapter | ? {$_.MacAddress -eq "00-15-5D-02-70-00"}
|
|
|
|
|
Rename-NetAdapter -Name "Eth*" -NewName "Arc-SRV"
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
2021-04-09 11:02:54 +02:00
|
|
|
|
|
|
|
|
|
# Install the DHCP role (Management tools if you love Metrosexual UI)
|
|
|
|
|
Install-WindowsFeature DHCP -IncludeManagementTools
|
|
|
|
|
|
|
|
|
|
# Show all the interface via iproute2 - LOL no via a shitty lookalike
|
|
|
|
|
netsh inter ipv4 show inter
|
2021-04-20 10:49:35 +02:00
|
|
|
|
Set-NetConnectionProfile -NetworkCategory Private
|
2021-04-09 11:02:54 +02:00
|
|
|
|
|
|
|
|
|
# Behold the LoserShell "cmdlet" to attribute static IP
|
2021-04-21 12:16:54 +02:00
|
|
|
|
#New-NetIPAddress -IPAddress 192.168.8.1 -InterfaceAlias "Arc-SRV" `
#-DefaultGateway 192.168. -AddressFamily IPv4 -PrefixLength 24
|
|
|
|
|
#Set-DnsClientServerAddress -InterfaceAlias "Arc-SRV" -ServerAddresses 9.9.9.9
|
2021-04-09 11:02:54 +02:00
|
|
|
|
|
|
|
|
|
# Create DHCP "security" groups
|
|
|
|
|
netsh dhcp add securitygroups
|
|
|
|
|
|
|
|
|
|
# Restart the DHCP server
|
|
|
|
|
Restart-Service dhcpserver
|
|
|
|
|
|
|
|
|
|
###################Template#######################
|
|
|
|
|
#Add-DhcpServerv4Scope -name "Corpnet" -StartRange 10.0.0.1 -EndRange 10.0.0.254 -SubnetMask 255.255.255.0 -State Active
|
|
|
|
|
#Add-DhcpServerv4ExclusionRange -ScopeID 10.0.0.0 -StartRange 10.0.0.1 -EndRange 10.0.0.15
|
|
|
|
|
#Set-DhcpServerv4OptionValue -OptionID 3 -Value 10.0.0.1 -ScopeID 10.0.0.0 -ComputerName DHCP1.corp.contoso.com
|
|
|
|
|
#Set-DhcpServerv4OptionValue -DnsDomain corp.contoso.com -DnsServer 10.0.0.2
|
|
|
|
|
##################################################
|
|
|
|
|
|
|
|
|
|
# Create DHCP Scopes For Arc-CLI Arc-SRV Bou-Lan
|
2021-04-21 12:16:54 +02:00
|
|
|
|
# Change on options after because this sucker seems to dislike if it's done now
|
2021-04-09 11:02:54 +02:00
|
|
|
|
|
|
|
|
|
Add-DhcpServerv4Scope -name "Arc-SRV" -StartRange 192.168.8.1 -EndRange 192.168.8.254 -SubnetMask 255.255.255.0 -State Active
|
|
|
|
|
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.8.0 -StartRange 192.168.8.1 -EndRange 192.168.8.63
|
|
|
|
|
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.8.0 -StartRange 192.168.8.240 -EndRange 192.168.8.254
|
|
|
|
|
|
|
|
|
|
Add-DhcpServerv4Scope -name "Arc-CLI" -StartRange 192.168.12.1 -EndRange 192.168.12.254 -SubnetMask 255.255.255.0 -State Active
|
|
|
|
|
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.12.0 -StartRange 192.168.12.1 -EndRange 192.168.12.63
|
|
|
|
|
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.12.0 -StartRange 192.168.12.240 -EndRange 192.168.12.254
|
|
|
|
|
|
|
|
|
|
Add-DhcpServerv4Scope -name "Bou-LAN" -StartRange 192.168.128.1 -EndRange 192.168.128.254 -SubnetMask 255.255.255.0 -State Active
|
|
|
|
|
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.128.0 -StartRange 192.168.128.1 -EndRange 192.168.128.63
|
|
|
|
|
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.128.0 -StartRange 192.168.128.240 -EndRange 192.168.128.254
|
2021-04-09 11:34:47 +02:00
|
|
|
|
|
|
|
|
|
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
|
|
|
|
|
|
|
|
|
$Params = @{
|
|
|
|
|
"Name" = 'vm-monitoring-icmpv4'
|
|
|
|
|
"Action" = 'Allow'
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-09 11:48:13 +02:00
|
|
|
|
Set-NetFirewallRule @Params
|
|
|
|
|
|
2021-04-09 15:28:45 +02:00
|
|
|
|
# Add routes for RTR-01
|
|
|
|
|
|
2021-04-09 11:48:13 +02:00
|
|
|
|
route add -p 192.168.12.0/24 192.168.8.254
|
|
|
|
|
route add -p 192.168.255.0/24 192.168.8.254
|
|
|
|
|
route add -p 192.168.128.0/24 192.168.8.254
|
2021-04-19 17:06:39 +02:00
|
|
|
|
route add -p 0.0.0.0/0 192.168.8.254
|
2021-04-21 12:16:54 +02:00
|
|
|
|
|
|
|
|
|
# Change DHCP server options
|
|
|
|
|
|
|
|
|
|
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.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.8.0 -OptionID 3 -Value 192.168.8.254
|
|
|
|
|
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 9.9.9.9
|
|
|
|
|
|
|
|
|
|
Read-Host "Finished"
|