> For AI agents: the complete documentation index is available at https://proxykite.com/docs/llms.txt, the full documentation bundle is available at https://proxykite.com/docs/llms-full.txt.

# Run a ProxyKite box as a Proxmox VM

You do not need a dedicated computer for your dongles. A small virtual machine on a Proxmox VE host works
just as well: Proxmox hands the USB stick to the VM, and the VM runs the ProxyKite agent like any other box.

This page is the exact procedure we use on our own Proxmox host (Proxmox VE 8.3, Huawei E3372 HiLink stick,
Debian 13 guest). Every command below was run during that setup; the timings at the end are what we measured.

## What you need

- A Proxmox VE host (7.x or 8.x) with a free USB 2.0/3.0 port.
- One or more [supported 4G sticks](https://proxykite.com/docs/guide/supported-dongles.md) with a SIM that has data: Huawei E3372 (HiLink firmware) or
  ZTE MF833T (agent 1.10.0 or newer). The commands below show the Huawei stick; for the ZTE look for `19d2:1405`
  instead of `12d1:14dc` (`lsusb | grep -i zte`).
- A ProxyKite licence key (`XXXX-XXXX-XXXX-XXXX`) from the panel under **Nodes**.
- Root shell on the Proxmox host (`ssh root@<host>` or the web shell).

One VM can hold several sticks. Give each stick its own USB port on the host and pass each port through;
the agent tells them apart by IMEI, so the order does not matter.

:::warning Two or more Huawei E3372 sticks? Read this first
With a cloud-init VM, a second E3372 stick can take your VM's own network card name at boot and the box drops off
the panel. Do [the fix below](#two-or-more-huawei-e3372-sticks) **before** you plug in the second stick.
:::

## 1. Plug the stick in and find its USB port

Plug the stick directly into the host (a powered hub is fine; an unpowered hub shared by several sticks is not).
After \~10 s the host sees it. HiLink sticks first show up as a CD-ROM (`12d1:1f01`) and switch to a network
card (`12d1:14dc`) by themselves; the host's `usb_modeswitch` package does that flip, so install it if missing:

```bash
apt-get install -y usb-modeswitch usbutils
lsusb | grep -i huawei
# Bus 001 Device 004: ID 12d1:14dc Huawei Technologies Co., Ltd. E3372 LTE/UMTS/GSM HiLink Modem/Networkcard
lsusb -t
# /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
#     |__ Port 7: Dev 4, If 0, Class=Communications, Driver=cdc_ether, 480M
```

Note the **bus and port**: here bus `1`, port `7`, so the port name is `1-7`. You can also read it from sysfs:

```bash
for d in /sys/bus/usb/devices/[0-9]-*; do [ -f $d/idProduct ] && echo "$(basename $d) $(cat $d/idVendor):$(cat $d/idProduct)"; done
# 1-7 12d1:14dc
```

Pass the stick through **by port**, not by its vendor/product ID. A port stays the same across reboots and
across the CD-ROM → network-card flip; an ID-based entry (`host=12d1:14dc`) grabs _any_ HiLink stick that
appears, which is exactly what you do not want with more than one VM or more than one stick.

:::warning Another VM may already own the stick
If an older VM on the same host has a `usb0: host=12d1:14dc` line in its config, it takes every HiLink stick
that is plugged in. Check with `grep -l usb /etc/pve/qemu-server/*.conf` and remove the entry from that VM
(`qm set <vmid> -delete usb0`). Removing a USB device from a _running_ VM only takes effect on its next
stop/start unless the VM uses the `q35` machine type.
:::

## 2. Create the VM

Any Debian 12/13 or Ubuntu 22.04/24.04 VM works. The agent is a single static binary and needs very little:

| Setting | Value we use                                                   |
| ------- | -------------------------------------------------------------- |
| CPU     | 1 core (`host` type)                                           |
| RAM     | 1024 MB (ballooning down to 512 MB is fine)                    |
| Disk    | 8 GB (the agent itself uses \~30 MB)                           |
| Network | one virtio NIC on your LAN bridge (`vmbr0`), static IP or DHCP |
| OS      | Debian 13 generic cloud image, or a normal ISO install         |

Cloud image example (template `8003` is a Debian 13 _generic_ cloud image with cloud-init; substitute your own):

```bash
qm clone 8003 108 --name proxykite-box --full 1
qm set 108 --memory 1024 --balloon 512 --cores 1 --agent enabled=1
qm resize 108 scsi0 8G
qm set 108 --ipconfig0 ip=192.168.1.50/24,gw=192.168.1.1 --nameserver "1.1.1.1 8.8.8.8"
qm set 108 --sshkeys ~/.ssh/id_rsa.pub          # cloud-init: root login with your key
```

:::tip Use the standard kernel, not a "cloud" kernel
The stick appears inside the VM as a USB network card (`cdc_ether`). Debian's _genericcloud_ images ship the
`linux-image-cloud` kernel, which leaves out most USB drivers. Use the _generic_ image or a normal install,
and check inside the VM with `modinfo cdc_ether`; it must print the module, not "not found".
:::

## 3. Give the VM the USB port and start it

```bash
qm set 108 -usb0 host=1-7      # the bus-port from step 1; usb1, usb2 … for more sticks
qm start 108
```

In the web UI this is **VM → Hardware → Add → USB Device → Use USB Port**. Do this while the VM is stopped;
USB hot-plug into a running VM is only supported for `q35` machines.

Check that the VM got it:

```bash
qm monitor 108 <<< "info usb"
#   Device 1.1, Port 1, Speed 480 Mb/s, Product HUAWEI_MOBILE, ID: usb0
```

## 4. Inside the VM: install the agent

Log in (`ssh root@192.168.1.50`) and confirm the stick is there:

```bash
apt-get install -y usb-modeswitch usbutils     # usb-modeswitch: in case the host did not flip the stick
lsusb | grep -i huawei                         # ID 12d1:14dc … HiLink Modem/Networkcard
ip -br link                                    # enx0c5b8f279a64  DOWN  0c:5b:8f:27:9a:64  ← the stick
```

The interface is `DOWN` with no address. That is normal, the agent configures it. Now run the one-line
installer from the panel (**Nodes → Add a box**), as root:

```bash
curl -fsSL https://proxykite.com/install.sh | sudo bash -s -- --key XXXX-XXXX-XXXX-XXXX
# Downloading hostyourproxy-linux-amd64 ...
# Registered as node 2. Service hostyourproxy.service is running.
```

Then:

```bash
hostyourproxy status
# Version:  1.9.2        Tunnel:   connected        Last OK heartbeat: 3s ago
# Interfaces:
#   enx0c5b8f279a64  0c:5b:8f:27:9a:64 192.168.8.11/24  gw 192.168.8.1  up  auto
# Dongles:
#   #10   enx0c5b8f279a64  192.168.8.11  enabled  users=1
```

The stick needs about **30 s** after the agent starts: the agent gives the interface a temporary address, reads
the stick's identity, gets a DHCP lease from it and registers it with the panel. Until then the journal shows
`hilink probe: unreachable: the interface has no IPv4 address yet`. That is expected, not an error.
Watch it with `journalctl -fu hostyourproxy`.

The proxy now appears in the panel under **Proxies** with its host, port, login and rotation link.

## 5. Check it

From any machine, with the login from the panel:

```bash
curl -x http://USER:PASS@ind1.proxykite.com:30003 https://api.ipify.org     # prints the SIM's public IP
```

Then press **Rotate** on the proxy page (or call the rotation link) and run the same curl again: the IP changes.
**Reboot box** on the node page reboots the VM from the panel; the agent and the stick come back on their own.

## Two or more Huawei E3372 sticks

:::warning Do this before you plug in the second E3372 stick
Every Huawei E3372 has **the same MAC address**. With one stick, it gets a name like `enx0c5b8f279a64`. With two or
more, only one stick can get that name; the others keep a kernel name such as `eth0` or `eth1`.

On a Proxmox VM set up with cloud-init, the network config (netplan) renames the VM's own virtio network card to
`eth0` at boot. If a stick already holds `eth0`, the rename fails, the VM's LAN card gets no IP address and **the
box drops off the panel** until you fix it from the Proxmox console.
:::

The fix: give the VM's LAN card a name that is not `ethN` (we use `lan0`), matched by its MAC address, and stop
cloud-init from rewriting the network config at boot. Run this inside the VM as root, from the Proxmox console
(**VM → Console**) rather than SSH, because the network restarts.

**1.** Note the MAC address of the VM's own network card (the virtio card, **not** an `enx…` stick):

```bash
ip -br link
# eth0             UP    bc:24:11:aa:bb:cc   <- the VM's LAN card (also shown in Proxmox: VM → Hardware → Network Device)
# enx0c5b8f279a64  DOWN  0c:5b:8f:27:9a:64   <- a stick
```

**2.** Turn off cloud-init's network config, so it does not put the `eth0` rename back at the next boot:

```bash
cat > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg <<'CFG'
network: {config: disabled}
CFG
```

**3.** Replace cloud-init's netplan file with your own. Put in your card's MAC and your own address and gateway
(or `dhcp4: true` instead of the `addresses` and `routes` lines):

```bash
mkdir -p /root/netplan-backup && mv /etc/netplan/*.yaml /root/netplan-backup/
cat > /etc/netplan/01-lan0.yaml <<'YAML'
network:
  version: 2
  ethernets:
    lan0:
      match:
        macaddress: "bc:24:11:aa:bb:cc"
      set-name: lan0
      addresses: [192.168.1.50/24]
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses: [1.1.1.1, 8.8.8.8]
YAML
chmod 600 /etc/netplan/01-lan0.yaml
netplan generate      # prints nothing when the file is valid
reboot
```

**4.** After the reboot, check that the card is called `lan0`, has its address and the box is online:

```bash
ip -br addr show lan0       # lan0  UP  192.168.1.50/24
hostyourproxy status        # Tunnel: connected
```

Now shut the VM down, pass the second stick's USB port through ([step 3](#3-give-the-vm-the-usb-port-and-start-it))
and start it again. The sticks can take any `ethN` or `enx…` name they like; the agent finds them by IMEI.

## Notes and troubleshooting

- **The stick's USB path inside the VM changes after a reboot** (`usb:2-1` one boot, `usb:1-1` the next). This
  is QEMU renumbering its virtual hubs; the agent re-identifies the stick by IMEI and keeps its proxy settings.
- **The very first request after the stick comes up (or after a reboot) answered 403.** The proxy shows
  _online_ as soon as the stick answers, a few seconds before the SIM's data session is up. In that window the
  stick's own DNS answers every name with its own address (`192.168.8.1`), which the agent refuses as a private
  destination, hence a 403 for that one request. Every request after it succeeded. Give a new or rebooted
  box \~10 s after the proxy appears before you point traffic at it.
- **`modinfo cdc_ether` says "not found"**: you are on a cloud kernel. `apt-get install linux-image-amd64`
  and reboot, or rebuild the VM from a generic image.
- **No proxy appears, `ip -br link` shows no `enx…`**: the VM did not get the stick. On the host run
  `qm monitor <vmid> <<< "info usb"`; if the stick is missing, another VM holds it (see the warning in step 1)
  or the port name is wrong (`lsusb -t` again).
- **The stick shows as `12d1:1f01`**: it is still in CD-ROM mode. `usb_modeswitch -v 12d1 -p 1f01 -J` inside
  the VM, or install `usb-modeswitch` there (it then flips every future plug automatically).
- **Memory.** The agent idles at \~30 MB. If your host is oversubscribed, keep the VM's minimum (balloon) at
  512 MB; it ran fine for us at 667 MB usable.
- **Backups.** Back the VM up like any other; the licence is bound to this box. If you rebuild the VM, click
  **Release machine** on the node page first, then run the installer again on the new VM.

## What we measured (Proxmox VE 8.3, Debian 13, E3372h, 1 vCPU / 1 GB)

| Step                                               | Time                             |
| -------------------------------------------------- | -------------------------------- |
| Installer (download + register + service up)       | \~10 s                           |
| Stick registered and proxy online in the panel     | \~35 s after the service started |
| IP rotation from the panel                         | \~10 s                           |
| Reboot box from the panel until the proxy was back | \~45 s                           |
| Test requests through the proxy (5 HTTPS sites)    | all 200, 1.2–2.8 s each          |
