A system daemon for managing network interfaces via REST APIs, supporting both Linux and macOS systems.
- REST APIs for network interface management:
- TUN interface creation and management
- Subnet configuration and management
- Automatic subnet allocation in 10.0.0.0/8 range
- Secure daemon operation with proper privilege handling
- Comprehensive logging system
- Platform-specific service management (systemd/launchd)
- Rust toolchain (1.70.0 or later)
- Root/Administrative privileges
- Platform-specific requirements:
- Linux: systemd
- macOS: launchd
# Build and install TUN daemon
make install_tunThe installation process:
- Builds the release binary
- Installs it to
/usr/local/bin/tun-daemon - Sets up log files in
/var/log/ - Configures and starts the system service:
- Linux: systemd service
- macOS: launchd daemon
# Build and install Subnet daemon
make installThe installation process:
- Builds the release binary
- Installs it to
/usr/local/bin/subnet-daemon - Sets up log files in
/var/log/ - Configures and starts the system service:
- Linux: systemd service
- macOS: launchd daemon
make uninstall_tunmake uninstallThese commands will:
- Stop the respective daemon service
- Remove all installed files
- Clean up system service configurations
The TUN daemon runs a REST API server on localhost:3030 with the following endpoints:
curl -X POST http://localhost:3030/tun -H "Content-Type: application/json" -d '{"name": "optional_name"}'Response:
{
"name": "utun3",
"ip_addr": "10.0.0.1",
"netmask": "255.255.255.0",
"broadcast": "10.0.0.255"
}curl http://localhost:3030/tunResponse:
[
{
"name": "utun3",
"ip_addr": "10.0.0.1",
"netmask": "255.255.255.0",
"broadcast": "10.0.0.255"
}
]The subnet daemon runs a REST API server on localhost:3031 with the following endpoints:
curl -X POST http://localhost:3031/subnet -H "Content-Type: application/json" -d '{"cidr": "10.1.0.0/24"}'Response:
{
"network": "10.1.0.0/24",
"interface": "lo0:0" # on macOS, or a dummy interface name on Linux
}curl http://localhost:3031/subnetResponse:
[
{
"network": "10.1.0.0/24",
"interface": "lo0:0"
}
]curl -X DELETE http://localhost:3031/subnet/10.1.0.0%2F24Logs are split between:
/var/log/tun_daemon.log: INFO, DEBUG, and TRACE level logs/var/log/tun_daemon.err: ERROR and WARN level logs
/var/log/subnet_daemon.log: INFO, DEBUG, and TRACE level logs/var/log/subnet_daemon.err: ERROR and WARN level logs
The daemons implement several security measures:
- Run as root with restricted capabilities
- Use systemd security features:
- Capability bounding (CAP_NET_ADMIN)
- No new privileges
- Protected system and home
- Restricted address families
- Namespace restrictions
- Run as root with wheel group
- Use launchd's security features
- Proper file permissions for all components