Randomize system hostname (and optionally machine-id) on Linux at boot. Useful for pentesting, privacy, or any scenario requiring a fresh identity each boot.
- Randomizes hostname on every boot
- Optionally randomizes
/etc/machine-idfor full identity separation - Configurable prefix and random string length
- Runs early in boot, before network services start
- Configuration via environment variables or CLI flags
git clone https://github.com/ryanmroth/freshid.git
cd freshid
sudo cp freshid /usr/bin/
sudo chmod +x /usr/bin/freshid
sudo cp freshid.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable freshid.serviceConfigure via environment variables in the service file or CLI flags. Flags take precedence over environment variables.
| Environment Variable | Flag | Default | Description |
|---|---|---|---|
FRESHID_PREFIX |
--prefix |
server |
Hostname prefix |
FRESHID_LENGTH |
--length |
6 |
Length of random portion |
FRESHID_MACHINE_ID |
--with-machine-id |
false |
Also randomize machine-id |
To customize, edit /etc/systemd/system/freshid.service:
[Service]
Type=oneshot
ExecStart=/usr/bin/freshid
Environment=FRESHID_PREFIX=kali
Environment=FRESHID_LENGTH=8
#Environment=FRESHID_MACHINE_ID=trueThen reload:
sudo systemctl daemon-reloadThe service runs automatically at boot. To run manually:
# Default (server-a1b2c3)
sudo freshid
# Custom prefix (kali-x9f2k1)
sudo freshid --prefix kali
# No prefix (x9f2k1)
sudo freshid --no-prefix
# Longer random portion (server-a1b2c3d4)
sudo freshid --length 8
# Include machine-id randomization
sudo freshid --with-machine-id
# Show help
freshid --help# Check hostname
hostname
# Check /etc/hosts
grep 127.0.1.1 /etc/hosts
# Check machine-id (if using --with-machine-id)
cat /etc/machine-idThe machine-id flag is useful for:
- Remote deployments (dropboxes) requiring full identity separation
- Scenarios where DHCP servers or services fingerprint on machine-id
For local pentesting laptops, hostname randomization alone is usually sufficient. Randomizing machine-id causes journald to create a new log directory each boot, fragmenting your logs.
sudo systemctl disable freshid.service
sudo rm /etc/systemd/system/freshid.service
sudo rm /usr/bin/freshid
sudo systemctl daemon-reloadSee CHANGELOG.md for version history.
MIT