mirror of
https://github.com/kuhyx/scripts.git
synced 2026-07-04 16:03:12 +02:00
24 lines
685 B
Bash
Executable File
24 lines
685 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Enable systemd-resolved
|
|
sudo systemctl enable systemd-resolved
|
|
|
|
# Remove all attributes from /etc/hosts to allow modifications
|
|
sudo chattr -i -a /etc/hosts 2>/dev/null || true
|
|
|
|
# Copy the hosts file
|
|
sudo cp hosts /etc/hosts
|
|
|
|
# Set restrictive permissions (read-only for owner, no access for group/others)
|
|
sudo chmod 600 /etc/hosts
|
|
|
|
# Make the file immutable (prevents deletion, renaming, and most modifications)
|
|
sudo chattr +i /etc/hosts
|
|
|
|
# Also set append-only attribute as additional protection
|
|
# Note: This requires removing immutable first, then setting both
|
|
sudo chattr -i /etc/hosts
|
|
sudo chattr +a /etc/hosts
|
|
|
|
# Flush DNS caches
|
|
sudo systemd-resolve --flush-caches |