scripts/hosts/install.sh

24 lines
685 B
Bash
Raw Normal View History

2024-12-27 21:51:35 +01:00
#!/bin/bash
2025-06-03 22:41:00 +02:00
# Enable systemd-resolved
2024-12-28 14:02:23 +01:00
sudo systemctl enable systemd-resolved
2025-06-03 22:41:00 +02:00
# Remove all attributes from /etc/hosts to allow modifications
sudo chattr -i -a /etc/hosts 2>/dev/null || true
# Copy the hosts file
2024-12-27 21:49:30 +01:00
sudo cp hosts /etc/hosts
2025-06-03 22:41:00 +02:00
# 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