Tag: IP

Networking: HSRP V VRRP

Networking: HSRP V VRRP

This is a common question I get asked when implementing HA for routeing interfaces and here is my very simple explanation to why I use VRRP over HSRP

“VRRP is an open standard meaning that is not proprietary┬áto Cisco Systems. Ultimately VRRP and HSRP achieve the same goal. If you were only ever going to have Cisco hardware from now and in the future I wouldn’t have a problem using HSRP but considering we are unable to predict the future VRRP is a safer bet as we can run it with multiple hardware and software vendors”

Please see below for a quick cheat sheet to show you the comparison between the protocols

cheatsheet

http://www.cisco.com/c/en/us/support/docs/ip/hot-standby-router-protocol-hsrp/9234-hsrpguidetoc.html

https://www.ietf.org/rfc/rfc3768.txt+

 

Advertisements
PS: Changing NIC IP Configuration

PS: Changing NIC IP Configuration

Okay, so it’s taken me a fair while of time to get this script to work needed for one of my latest projects so due to it taking me a while to piece this together I feel that it’s probably worthwhile putting it out on here for you guys to use if you wish. The following code will change the IP of a NIC and reconfigure the DNS settings using NETSH

 <# Get Network Adapter #>
Get-NetAdapter | Format-Table -AutoSize
<# User Input Network Interface #>
write-host 'Please Enter Network Interface Name: ' -ForegroundColor Yellow -NoNewline
$nicname = Read-Host
Write-host 'Please Enter New Host IP: ' -ForegroundColor Yellow -NoNewline
$NewIP = Read-Host
Write-host 'Please Enter New Subnet Mask: ' -ForegroundColor Yellow -NoNewline
$NewMask = Read-Host
Write-Host 'Please Enter New Gateway: ' -ForegroundColor Yellow -NoNewline
$NewGate = Read-Host
Write-Host 'Please Enter DNS Server 1: ' -ForegroundColor Yellow -NoNewline
$NewDNS1 = Read-Host
Write-Host 'Please Enter DNS Server 2:' -ForegroundColor Yellow -NoNewline
$NewDNS2 = Read-Host
write-host 'Setting New IPv4 Configuration'
& "$env:windir\system32\netsh.exe" interface ipv4 set address $nicname static $NewIP $NewMask $NewGate
write-host 'Removing Exsisting DNS Config'
& "$env:windir\system32\netsh.exe" interface ip delete dns $nicname all
write-host 'Adding New DNS Config'
& "$env:windir\system32\netsh.exe" interface ipv4 set dns name=$nicname source=static address=$NewDNS1 primary validate=no
& "$env:windir\system32\netsh.exe" interface ipv4 add dnsserver name=$nicname address=$NewDNS2 index=2 validate=no
PS: Validating User Input for an IP Address or Subnet Mask

PS: Validating User Input for an IP Address or Subnet Mask

Okay in one of my scripts I needed to incorporate user input of an IP address and to validate the input as valid IPv4 address. Take a look at the snippet below

 <#IP Validation Pattern#>
$IPPattern = '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'

<#User Input of IP #>
Write-Host "Please Enter IP: " -ForegroundColor Yellow -NoNewline
<#Input Loop Until Validation meets pattern#>
do {
<# Set IP address var #>
$IPADR = Read-Host
$ok = $IPADR -match $IPPattern
if ($ok -eq $false) {
<# Error Message and Prompt to enter an IP #>
Write-Warning ("'{0}' is not an IP address." -f $IPADR)
write-host -fore Yellow "Please Enter IP: " -NoNewline
}
<#Condition#>
} until ( $ok )