Facebook
From ec, 8 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 263
  1. # SNMP servisini yükleme
  2. Install-WindowsFeature SNMP-Service, SNMP-WMI-Provider, RSAT-SNMP
  3.  
  4. # SNMP servisine genel ayarlar yapma
  5. $community = "public"
  6. $location = "Server Location"
  7. $contact = "Admin Contact"
  8.  
  9. # SNMP servisini yapılandırma
  10. reg add "HKLM\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities" /v $community /t REG_DWORD /d 4 /f
  11. reg add "HKLM\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent" /v sysLocation /t REG_SZ /d $location /f
  12. reg add "HKLM\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent" /v sysContact /t REG_SZ /d $contact /f
  13.  
  14. # SNMP servisini başlatma
  15. Start-Service SNMP
  16.  
  17. # SNMP servisine sadece belirli IP adreslerinden erişim izni vermek için Güvenlik Duvarı kuralları ekleniyor
  18. $allowedIPs = @("10.80.43.5", "185.254.237.248")
  19. foreach ($ip in $allowedIPs) {
  20.     New-NetFirewallRule -DisplayName "Allow SNMP from $ip" -Direction Inbound -Action Allow -Protocol UDP -LocalPort 161 -RemoteAddress $ip
  21. }
  22.  
  23. # SNMP servis durumunu kontrol etme
  24. Get-Service SNMP
  25.  
  26.  
  27.  
  28.  
  29. # SNMP Hizmeti için Topluluk Adı Ayarları
  30. $communityName = "public"
  31. $communityPermission = 8 # 4: READ ONLY, 8: READ WRITE
  32.  
  33. # Kayıt defterinde SNMP ayarlarını yap
  34. $snmpRegPath = "HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters"
  35.  
  36. # Topluluk adı ve izinlerini ayarla
  37. New-Item -Path "$snmpRegPath\ValidCommunities" -Force
  38. Set-ItemProperty -Path "$snmpRegPath\ValidCommunities" -Name $communityName -Value $communityPermission
  39.  
  40. # SNMP Paketlerini Kabul Edecek IP Adreslerini Ayarla
  41. New-Item -Path "$snmpRegPath\PermittedManagers" -Force
  42. New-ItemProperty -Path "$snmpRegPath\PermittedManagers" -Name "1" -Value "185.254.237.248"
  43.  
  44. Restart-Service -Name snmp
  45.  
  46.  
  47.