---
title: "ezgh compute network-gateways attach"
description: "Attach a network gateway to a VPC."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ezgh compute network-gateways attach

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh compute network-gateways attach <gateway> --vpc <vpc> [--add-default-route=false] [flags]
```

Attach a network gateway to a VPC of the project (needs permission to update the VPC too). A VPC has at most one (vpc_has_gateway).

Attaching changes no routes. `--add-default-route` (on by default) then routes 0.0.0.0/0 and ::/0 in the VPC's main route table to the gateway, where the table lacks them or they point at a gateway that's gone, unless the table changes meanwhile; it says on stderr what it added. A gateway already attached keeps its routes as they are: running attach again doesn't restore routes removed since, and it says how to add them. `--add-default-route=false` leaves the routes alone: a subnet whose table has no route to the gateway has no internet path.

Part of [`ezgh compute network-gateways`](/cli/reference/compute-network-gateways).

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--add-default-route` | boolean | `true` | route 0.0.0.0/0 and ::/0 in the VPC's main route table to the gateway |
| `--vpc` | string |  | the VPC (ID, UUID or name; required) |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/compute-network-gateways-attach/index.mdx
