Initial Commit
This commit is contained in:
commit
c29a122d10
58
DHCP.ps1
Normal file
58
DHCP.ps1
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# Alexandre Simao
|
||||||
|
# GPL v3
|
||||||
|
|
||||||
|
#Rename this piece of garbage
|
||||||
|
$name = Read-host "Nom d'hôte?"
|
||||||
|
Rename-computer $name
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Define various variables
|
||||||
|
$DHCPServerIP = Read-Host "Interface IP served by DHCP?"
|
||||||
|
$Interface = Read-host "Interface Name?"
|
||||||
|
$DefGat = Read-Host "Default Gateway?"
|
||||||
|
$DNS = Read-Host "DNS Server?"
|
||||||
|
|
||||||
|
# Behold the LoserShell "cmdlet" to attribute static IP
|
||||||
|
New-NetIPAddress -IPAddress $DHCPServerIP -InterfaceAlias "$Interface" `
-DefaultGateway $DefGat -AddressFamily IPv4 -PrefixLength 24
|
||||||
|
Set-DnsClientServerAddress -InterfaceAlias "$Interface" -ServerAddresses $DNS
|
||||||
|
|
||||||
|
# Create DHCP "security" groups
|
||||||
|
netsh dhcp add securitygroups
|
||||||
|
|
||||||
|
# Restart the DHCP server
|
||||||
|
Restart-Service dhcpserver
|
||||||
|
|
||||||
|
# Remove Server Manager message telling that DHCP need to be fixed
|
||||||
|
Set-ItemProperty –Path registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft`
\ServerManager\Roles\12 –Name ConfigurationState –Value 2
|
||||||
|
|
||||||
|
###################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
|
||||||
|
|
||||||
|
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
|
||||||
|
Set-DhcpServerv4OptionValue -OptionID 3 -Value 192.168.8.254
|
||||||
|
Set-DhcpServerv4OptionValue -DnsServer 9.9.9.9
|
||||||
|
|
||||||
|
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
|
||||||
|
Set-DhcpServerv4OptionValue -OptionID 3 -Value 192.168.12.254
|
||||||
|
Set-DhcpServerv4OptionValue -DnsServer 9.9.9.9
|
||||||
|
|
||||||
|
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
|
||||||
|
Set-DhcpServerv4OptionValue -OptionID 3 -Value 192.168.128.254
|
||||||
|
Set-DhcpServerv4OptionValue -DnsServer 9.9.9.9
|
53
Routeur.ps1
Normal file
53
Routeur.ps1
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
$name = Read-host "Nouveau nom d'hôte?"
|
||||||
|
Rename-computer $name
|
||||||
|
Install-WindowsFeature Routing
|
||||||
|
netsh inter show inter
|
||||||
|
Set-ItemProperty -path 'HKLM:\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet`
|
||||||
|
\Services\Tcpip\Parameters' -Name 'IPEnableRouter' -Value '0x00000001'
|
||||||
|
Set-NetConnectionProfile -NetworkCategory Private
|
||||||
|
|
||||||
|
# IP address or DnsHostName of your Dhcp Server
|
||||||
|
$dhcpServer = '192.168.8.1'
|
||||||
|
|
||||||
|
# Name of the network adapter to enable DHCP on
|
||||||
|
$Inter1 = Read-Host "First interface name"
|
||||||
|
$Inter2 = Read-Host "Second interface name"
|
||||||
|
|
||||||
|
$routerNetAdapterName1 = '$Inter1'
|
||||||
|
$routerNetAdapterName1 = '$Inter2'
|
||||||
|
|
||||||
|
|
||||||
|
$dhcpAddress = [Net.Dns]::GetHostEntry($dhcpServer)
|
||||||
|
if(!$dhcpAddress){
|
||||||
|
Write-Warning "Unable to identify IP address of [$dhcpServer]"
|
||||||
|
break
|
||||||
|
}else{
|
||||||
|
$dhcpServerIP = $dhcpAddress.AddressList[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
$netshDhcpRelay=@"
|
||||||
|
pushd routing ip relay
|
||||||
|
install
|
||||||
|
set global loglevel=ERROR
|
||||||
|
add dhcpserver $($dhcpServerIP.IPAddressToString)
|
||||||
|
add interface name="$routerNetAdapterName1"
|
||||||
|
set interface name="$routerNetAdapterName1" relaymode=enable maxhop=6 minsecs=6
|
||||||
|
add interface name="$routerNetAdapterName2"
|
||||||
|
set interface name="$routerNetAdapterName2" relaymode=enable maxhop=6 minsecs=6
|
||||||
|
popd
|
||||||
|
"@
|
||||||
|
|
||||||
|
$netshDhcpRelayPath="$ENV:TEMP\netshDhcpRelay"
|
||||||
|
|
||||||
|
# Create netsh script file
|
||||||
|
New-Item -Path $netshDhcpRelayPath `
|
||||||
|
-Type File `
|
||||||
|
-ErrorAction SilentlyContinue | Out-Null
|
||||||
|
|
||||||
|
# Populate contents of the script
|
||||||
|
Set-Content -Path $netshDhcpRelayPath `
|
||||||
|
-Value $netshDhcpRelay.Split("`r`n") `
|
||||||
|
-Encoding ASCII
|
||||||
|
|
||||||
|
# run it
|
||||||
|
netsh -f $netshDhcpRelayPath
|
14
Sans titre1.ps1
Normal file
14
Sans titre1.ps1
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# IP address or DnsHostName of your Dhcp Server
|
||||||
|
$dhcpServer = '192.168.8.1'
|
||||||
|
|
||||||
|
# Name of the network adapter to enable DHCP on
|
||||||
|
$routerNetAdapterName = 'Ethernet1'
|
||||||
|
|
||||||
|
|
||||||
|
$dhcpAddress = [Net.Dns]::GetHostEntry($dhcpServer)
|
||||||
|
if(!$dhcpAddress){
|
||||||
|
Write-Warning "Unable to identify IP address of [$dhcpServer]"
|
||||||
|
break
|
||||||
|
}else{
|
||||||
|
$dhcpServerIP = $dhcpAddress.AddressList[0]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user