> Documentation index for agents: /hcp/3.3/en/llms.txt

# VM network: IP pool, IP guard, routers

A virtual machine (VM) connects to a cluster network through a port. Center assigns the port an address from the IP pool of the network, and the guest gets this address from the node through cloud-init — the networks have no DHCP. **IP guard** on the port lets VM traffic through only from the assigned address. A router — a service VM with a firewall and NAT — connects networks to each other and to external networks. Its rules take effect only after you apply them.

## Network types

- **Isolated** — a VXLAN virtual network on top of the network for isolated networks; it is not visible outside the cluster.
- **GENEVE** — also an isolated network, but on Geneve instead of VXLAN. This type may appear in the list of networks, but you cannot create such a network in the web interface — [Networks and IP pools](/hcp/3.3/en/networks/index.md).
- **Routed** and **Q-in-Q** — a VLAN of the physical data center network, shared by all nodes.
- **The network is created on all nodes that are online**, so a VM keeps its network on any node: after live migration, pool failover and auto-restart.

## How a VM gets an address

1. **Center assigns an address to the port** when the port is connected to a network: a free address from the IP pool, or the address set by the user if it is in the pool and free.
2. **The guest gets the address, mask, gateway and DNS** from the node through cloud-init or Cloudbase-Init — over the service serial port of the VM. The cluster networks have no DHCP server. If the guest OS does not have such a program, the address is configured in the guest manually.
3. **The guest DNS** is the DNS set when the VM was created. If it was not set, Center takes the DNS servers and the DNS suffix of the network of the first port, set when the network was created; if the network has none, Center takes public DNS servers and the domain from the host name.
4. **The address is bound to the port.** It does not change during live migration and pool failover. The address returns to the pool when the port is disconnected from the network or the VM is deleted.

The node passes the current network settings of the ports to the guest at every VM start, except when the VM resumes after a suspend or is received through live migration. After a network is added to or disconnected from the VM, the node also updates the cloud-init settings. The guest gets IPv6 addresses in the initial network configuration together with IPv4.

Whether the guest applies new settings at the next start depends on its image.

## IP guard

- **What it does.** The virtual network adapter of the VM on the node lets guest traffic through only from the addresses assigned to the port. This prevents a VM from impersonating another device on the network.
- **Enabled by default** on every port of a VM and of a router.
- **You can disable it** only in an **Isolated** network — for a VM that itself routes other devices' traffic.
- **Directions.** The filter works both on transmit and on receive.

## How a router applies rules

1. **Rules are stored in Center.** A saved rule is not yet sent to the router.
2. **Apply rules** sends the whole set of firewall and NAT rules to the running router at once. On start and restart, the router gets the set on its own.
3. **The firewall checks the rules in the order of their numbers in the # column**, and the last matching rule applies. A rule with a higher number overrides a rule with a lower number.
4. **There are no rules by default.** Set a deny rule for all traffic as the first rule, then the allow rules — see the example below, in "What not to do".
5. **Pass keeps the connection state:** return traffic passes without a separate rule.
6. **Assign NAT rules numbers of the same length** — for example, from 100 to 999.
7. **DNAT changes the destination address before the firewall.** The firewall rule for such traffic is written for the address of the VM, not for the external address of the router.
8. **New rules apply only to new connections.** **Apply rules** does not terminate the connections already established through the router: they keep working until they are closed, even if a new rule denies them. A router restart resets all connections.

## Duration

- **Center assigns an address to the port** right when the port is connected.
- **Rules** take effect from the moment the router accepts the set. While the router is not in the **Started** status or is still booting, Center does not send the set.

## What you see

- **Network panel** in **All Networks**: the **IP pool** section shows the pool addresses, the **Allocations** section shows which objects use the addresses — [Exclude an address from an IP pool and view used addresses](/hcp/3.3/en/networks/set-ip-pool/index.md).
- **VM port** in the **Networks** section of the VM page: the **MAC**, **IP** and **IP guard** columns; **MBps limit** is changed in the port panel, which opens when you click the row.

* **Router page:** the status, the **Firewall rules** and **NAT rules** sections, the **Apply rules** button.
* **From the outside:** a VM without cloud-init stays without an address until the address is set in the guest.

## Limitations

- **Through the API**, a port can be assigned up to 8 IPv4 addresses and up to 7 allowed source MAC addresses, and an address or MAC held by another VM can be assigned to a second VM — with the **Share Occupied IP Address** privilege. The web interface shows and sets one IPv4 address per port. The interface of a powered-off VM is edited in place with the `vm-set-nic` method.

* **A router is a single VM.** Center does not configure a standby router, DHCP or static routes. After a node failure, Center starts the router on another node like a regular VM.
* **Router ports** can be changed only when the router is stopped; a rule cannot be changed — only deleted and added again.

## What not to do

- **Do not give Block a lower number than an allow rule** expecting it to take effect first: the last matching rule applies.

- **Do not leave a router port without a deny rule.** Set a deny rule for everything as the first rule, then the allow rules — for the network from which traffic enters the router (the **Network** field):

  1. **Block** with number 100: **Direction** — **In**, **Protocol** — **IP**, **From (CIDR)** and **Dst. (CIDR)** — `0.0.0.0/0`.
  2. **Pass** with number 101: **Direction** — **Out**, the rest as in the first rule. Without it, replies to the connections that VMs open through this network do not come back.
  3. Allow rules with numbers greater than 101 — for the inbound traffic that you allow. The last matching rule applies, so the allowed traffic passes, and **Block** drops the rest.

- **Do not change the address in the guest OS** to another address from the subnet: **IP guard** drops traffic from this address.

- **Do not disable IP guard** on a VM that does not route other devices' traffic.

- **Do not forget to click Apply rules** after changes: otherwise, a saved rule is not sent to the router.

## See also

- [Networks and IP pools](/hcp/3.3/en/networks/index.md)
- [Connect a VM to a network](/hcp/3.3/en/vms/connect-vm-network/index.md)
- [Routers](/hcp/3.3/en/edges/index.md)
- [Configure firewall rules](/hcp/3.3/en/edges/configure-firewall-rules/index.md)
- [Configure NAT rules](/hcp/3.3/en/edges/configure-nat-rules/index.md)
- [Cluster network (SDN)](/hcp/3.3/en/architecture/networking/index.md)
