msiforthewin

syslog config update

Jan 2nd, 2026
3,164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. # Define IPs
  2. OLD_IP="172.16.1.227"
  3. NEW_IP="172.16.1.229"
  4. CONF_FILE="/etc/rsyslog.d/99-remotelog.conf"
  5.  
  6. if [ -f "$CONF_FILE" ]; then
  7. echo "[+] Updating config from $OLD_IP to $NEW_IP..."
  8.  
  9. # 1. Update the IP address
  10. sudo sed -i "s/$OLD_IP/$NEW_IP/g" "$CONF_FILE"
  11.  
  12. # 2. Restart the service
  13. echo "[+] Restarting rsyslog..."
  14. sudo systemctl restart rsyslog
  15.  
  16. # 3. Validation
  17. if grep -q "$NEW_IP" "$CONF_FILE"; then
  18. echo "[SUCCESS] Config updated."
  19. # Send a test log to the new server
  20. logger "MIGRATION_TEST: Hello 172.16.1.229 from $(hostname)"
  21. echo "[+] Test log sent. Check /var/log/syslog on the new server."
  22. else
  23. echo "[FAIL] Update failed. Check file permissions."
  24. fi
  25. else
  26. echo "[-] Config file $CONF_FILE not found. Run the setup script first!"
  27. fi
Advertisement