|
| 1 | +# Created by Fletcher Salesky |
| 2 | +# FFS Connect (This verson from 2021-10-06) |
| 3 | + |
| 4 | +#Display current firewall settings |
| 5 | +Get-NetFirewallProfile | Format-List -Property Profile, Enabled |
| 6 | + |
| 7 | +#DISABLE ALL WINDOWS FIREWALLS |
| 8 | +Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False |
| 9 | +echo "Disabled Windows Firewall" |
| 10 | + |
| 11 | +#Create Firewall allow rules for FRC FMS Ports (Ports from FMS White Paper, WPIlib and The FTAA/CSA Troubleshooting) |
| 12 | +#Create Firwall allow rule for NI mDNS Responser |
| 13 | +function Install-Firewall-Rules |
| 14 | +{ |
| 15 | + $rule = Get-NetFirewallRule -Group "Allow FRC Driver Station FMS Comms" 2> $null; |
| 16 | + if ($rule) { |
| 17 | + #enable-update rules if they exist |
| 18 | + Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_TCP_in -Direction Inbound -Protocol TCP -RemoteAddress 10.0.0.0/8 -LocalPort 80,443,554,1110,1115,1120,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled True -Profile Any |
| 19 | + Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_UDP_in -Direction Inbound -Protocol UDP -RemoteAddress 10.0.0.0/8 -LocalPort 80,443,554,1110,1115,1120,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled True -Profile Any |
| 20 | + Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_mDNS_in -Direction Inbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files\National Instruments\Shared\mDNS Responder\nimdnsResponder.exe" -Action Allow -Enabled True -Profile Any |
| 21 | + |
| 22 | + Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_TCP_out -Direction Outbound -Protocol TCP -RemoteAddress 10.0.0.0/8 -RemotePort 80,443,554,1110,1115,1120,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled True -Profile Any |
| 23 | + Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_UDP_out -Direction Outbound -Protocol UDP -RemoteAddress 10.0.0.0/8 -RemotePort 80,443,554,1110,1115,1120,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled True -Profile Any |
| 24 | + Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_mDNS_out -Direction Outbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files\National Instruments\Shared\mDNS Responder\nimdnsResponder.exe" -Action Allow -Enabled True -Profile Any |
| 25 | + } |
| 26 | + |
| 27 | + else { |
| 28 | + #create rules if they do not exist |
| 29 | + New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_TCP_in -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms TCP" -Direction Inbound -Protocol TCP -RemoteAddress 10.0.0.0/8 -LocalPort 80,443,554,1110,1115,1120,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow |
| 30 | + New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_UDP_in -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms UDP" -Direction Inbound -Protocol UDP -RemoteAddress 10.0.0.0/8 -LocalPort 80,443,554,1110,1115,1120,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow |
| 31 | + New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_mDNS_in -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms NI mDNS Responder" -Direction Inbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files\National Instruments\Shared\mDNS Responder\nimdnsResponder.exe" -Action Allow |
| 32 | + |
| 33 | + New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_TCP_out -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms TCP" -Direction Outbound -Protocol TCP -RemoteAddress 10.0.0.0/8 -RemotePort 80,443,554,1110,1115,1120,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow |
| 34 | + New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_UDP_out -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms UDP" -Direction Outbound -Protocol UDP -RemoteAddress 10.0.0.0/8 -RemotePort 80,443,554,1110,1115,1120,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow |
| 35 | + New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_mDNS_out -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms NI mDNS Responder" -Direction Outbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files\National Instruments\Shared\mDNS Responder\nimdnsResponder.exe" -Action Allow |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +#Enable the Firewall rules to allow comms to the field network |
| 40 | +Install-Firewall-Rules |
| 41 | +echo "Firewall Opened to FRC Protocols" |
| 42 | + |
| 43 | +#Display current firewall settings |
| 44 | +Get-NetFirewallProfile | Format-List -Property Profile, Enabled |
| 45 | + |
| 46 | +#Stop Windows updates |
| 47 | +net stop wuauserv |
| 48 | +echo "Windows Update Service Stopped" |
| 49 | +echo "" |
| 50 | +echo "Reset Ethernet adapters and disable other adapters?" |
| 51 | +pause |
| 52 | + |
| 53 | +#Get All Adapters |
| 54 | +$adapters = Get-NetAdapter |
| 55 | + |
| 56 | +#Disable all adapters |
| 57 | +foreach ($adapter in $adapters) |
| 58 | +{ |
| 59 | + Disable-NetAdapter -name $adapter.Name -Confirm:$false |
| 60 | +} |
| 61 | + |
| 62 | +#Get Physical Adapters |
| 63 | +$physicalAdapters = Get-NetAdapter -Physical |
| 64 | + |
| 65 | +#Enable Physical 802.3 Adapters and Disable IPv6 on Physical 802.3 Adapters |
| 66 | +foreach ($adapter in $physicalAdapters) |
| 67 | +{ |
| 68 | + if ($adapter.PhysicalMediaType -like "*802.3") |
| 69 | + { |
| 70 | + Enable-NetAdapter -name $adapter.Name -Confirm:$false |
| 71 | + Disable-NetAdapterBinding -name $adapter.Name -ComponentID ms_tcpip6 |
| 72 | + } |
| 73 | + |
| 74 | +} |
| 75 | +echo "Wireless Adapters Disabled, Ethernet Adapters Reset" |
| 76 | +#Show Status of Adapters |
| 77 | +Get-NetAdapter | Format-List -Property Name,Status,AdminStatus,HardwareInterface |
| 78 | + |
| 79 | +echo "Set Ethernet adapters to use DHCP?" |
| 80 | +pause |
| 81 | + |
| 82 | +#Set Physical 802.3 Adapters to use DHCP |
| 83 | +foreach ($adapter in $physicalAdapters) |
| 84 | +{ |
| 85 | + if ($adapter.PhysicalMediaType -like "*802.3") |
| 86 | + { |
| 87 | + netsh interface ip set address $adapter.Name dhcp |
| 88 | + netsh interface ip set dns $adapter.Name dhcp |
| 89 | + } |
| 90 | + |
| 91 | +} |
| 92 | + |
| 93 | +#flush DNS |
| 94 | +Clear-DnsClientCache |
| 95 | +echo "DNS Flushed" |
| 96 | +#Release everything |
| 97 | +ipconfig /release |
| 98 | +ipconfig /release6 |
| 99 | +echo "IP Addresses Released" |
| 100 | + |
| 101 | +#open Network Adapters Conntrol Panel to allow Static IP setting |
| 102 | +control ncpa.cpl |
| 103 | + |
| 104 | +echo "Get IP Address with DHCP?" |
| 105 | +pause |
| 106 | + |
| 107 | +#Renew DHCP for Physical 802.3 Adapters |
| 108 | +foreach ($adapter in $physicalAdapters) |
| 109 | +{ |
| 110 | + if ($adapter.PhysicalMediaType -like "*802.3") |
| 111 | + { |
| 112 | + ipconfig /renew $adapter.Name |
| 113 | + } |
| 114 | + |
| 115 | +} |
| 116 | +Echo "Ethernet Adapter IP Addresses Renewed" |
| 117 | + |
0 commit comments