- Go 98.7%
- Batchfile 1.3%
| .gitattributes | ||
| .gitignore | ||
| adapter-restore.bat | ||
| adapter_windows.go | ||
| amp-lock.bat | ||
| amp-unlock.bat | ||
| cli_windows.go | ||
| dhcp_conn_windows.go | ||
| elevate_windows.go | ||
| go.mod | ||
| go.sum | ||
| GUIDE_UTILISATEUR_FR.md | ||
| GUIDE_UTILISATEUR_FR.pdf | ||
| main.go | ||
| README.md | ||
| USER_GUIDE.md | ||
| USER_GUIDE.pdf | ||
| websocket.go | ||
apex-network-rescue — DHCP Server
A minimal DHCP server written in Go using github.com/insomniacslk/dhcp.
Automatically configures the host Ethernet adapter with a static IP at startup and reverts it to its original settings (DHCP or previous static IP) when the server is stopped.
Requirements
- Go 1.21+
- Windows: must be run as Administrator (required to bind UDP port 67
and to run
netshto configure the adapter)
Build
go build -o apex-network-rescue.exe .
Usage
apex-network-rescue.exe [flags]
Flags:
-restore Restore the saved adapter configuration from a previous interrupted run, then exit
-iface string Ethernet adapter name (default: auto-detect first wired adapter)
-server-ip string IP to assign to the adapter; also used as gateway (default: 192.168.100.1)
-range-start string First IP in the assignable pool (default: 192.168.100.100)
-range-end string Last IP in the assignable pool (default: 192.168.100.200)
-lease duration Lease duration, e.g. 12h, 30m (default: 24h)
Quick start
- Connect your Windows machine to the target machine via an Ethernet cable.
- Open an Administrator command prompt and run:
apex-network-rescue.exe
The CLI will ask you to acknowledge the adapter warning and confirm the Ethernet cable is connected. It will then:
- Auto-detect the first wired Ethernet adapter
- Save its current IP configuration
- Assign it the static IP
192.168.100.1 / 255.255.255.0 - Check whether the amplifier already has a reachable IP on the subnet and use it directly when found
- Start the DHCP server
- Wait for the client to answer
pingand for TCP port5678to become reachable before attempting the WebSocket command - Restore the original adapter configuration before exiting
The target machine will receive an address in 192.168.100.100 – 192.168.100.200 with:
- Gateway:
192.168.100.1 - DNS:
1.1.1.1,8.8.8.8 - Lease: 24 hours
- Press Ctrl+C to cancel. The adapter is automatically reverted to its original configuration (DHCP or previous static IP) when a saved state is available.
If you run the program from a non-Administrator shell, it exits with a console error instead of opening a Windows elevation prompt.
If the program is interrupted and leaves the adapter in an intermediate state, relaunch it as Administrator with:
apex-network-rescue.exe -restore
The console only shows user-facing prompts, progress, and plain errors.
Detailed runtime logs are appended to apex-network-rescue.log next to the
executable. If the app hangs, that file should show the last completed startup
step.
Specifying the adapter manually
If auto-detection picks the wrong adapter, pass its name explicitly:
apex-network-rescue.exe -iface "Ethernet 2"
The adapter name is shown in Network Connections (ncpa.cpl).
Defaults at a glance
| Setting | Default value |
|---|---|
| Server IP | 192.168.100.1 |
| Subnet mask | 255.255.255.0 (/24) |
| Pool start | 192.168.100.100 |
| Pool end | 192.168.100.200 |
| Gateway | same as Server IP |
| DNS | 1.1.1.1, 8.8.8.8 |
| Lease time | 24h |
How it works
| Step | What happens |
|---|---|
| 1 | Finds the Ethernet adapter (auto or -iface) |
| 2 | Saves the adapter's current IP config via netsh |
| 3 | Applies the static server IP via netsh |
| 4 | Binds the DHCP socket to the server IP (forces Windows to route broadcasts out the correct adapter) |
| 5 | Handles DISCOVER → OFFER → REQUEST → ACK and RELEASE |
| 6 | On Ctrl+C / SIGTERM: reverts the adapter and exits |
Leases are held in memory only and are lost on restart.