|
1 | | -# NAT Firewall |
| 1 | +# Configure a Liqo gateway server behind a NAT |
2 | 2 |
|
3 | | -In Case a **gateway server** is behind a NAT firewall, the following steps are required to establish the connection: |
4 | | -You can configure the settings for the connection by setting the following *annotations* in the `values.yaml` file or by using the `liqoctl` command line `--set` option: |
| 3 | +There might be some cases, especially when working in lab environments, where **it is not possible to configure the gateway server service as `LoadBalancer`**, and it should be configured via a `NodePort` service. |
| 4 | +However, the nodes of the cluster might not be directly reachable, as for example, they are behind a NAT. |
5 | 5 |
|
6 | | -Under the `networking.gatewayTemplates.server.service.annotations` key, you can set the following annotations: |
| 6 | +In such cases, it is not possible to configure the Liqo peering directly with the `liqoctl peer` command, as the gateway client would point to the internal address and port of the server gateway. |
7 | 7 |
|
8 | | -* **liqo.io/override-address**: the public IP address of the NAT firewall. |
9 | | -* **liqo.io/override-port**: the public port of the NAT firewall. |
| 8 | +In this documentation page, we are going to describe how to configure Liqo in this kind of cases. |
10 | 9 |
|
11 | | -```{admonition} Tip |
12 | | -In case you need to have multiple gateways behind the same NAT firewall, you need to override the port for each peer using the `--server-port` flag at peering time. |
13 | | -This flag works with `liqoctl peer` and `liqoctl network connect` commands. |
| 10 | +## Case A: Use a NodePort service with the provider cluster behind a NAT and client directly reachable |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +There might be the case in which the cluster provider nodes are not directly reachable, as for example they are behind a NAT, while the consumer can be directly reached. |
| 15 | + |
| 16 | +By default using the `peer` command, the gateway server is configured on the provider cluster, which, in this case, is not directly reachable, as behind the NAT. |
| 17 | +To fix this issue, we can swap the roles of the gateways, configuring the client on the cluster provider and the server on the consumer. |
| 18 | +To do so, you need to use [manual peering](./manual-peering.md), setting the inter-cluster network up separately. |
| 19 | + |
| 20 | +This solution allows to configure the Liqo networking without the need to configure port-mapping on the NAT, as we moved the gateway server on the nodes that are directly reachable. |
| 21 | + |
| 22 | +In the case you would like to keep the gateway server on the provider, you can follow the instructions on the next paragraph. |
| 23 | + |
| 24 | +## Case B: Use a NodePort service when both cluster provider and consumer are behind a NAT |
| 25 | + |
| 26 | +The solution presented in this section is valid when both consumer and provider clusters are reachable from an IP and a port different than the ones configured on the nodes of the clusters, for example, when they both are behind a NAT. |
| 27 | + |
| 28 | +In this case, **you must configure port-mapping on the NAT** so that the traffic directed on a specific port of the NAT can be forwarded to one of nodes of the cluster. |
| 29 | + |
| 30 | +When network is configured via `liqoctl` commands, if the service is of type `NodePort`, Liqo automatically uses the external IPs of the nodes to configure the gateway client. |
| 31 | +You can force Liqo to use the public IP of the NAT and the port of the NAT where we configured port mapping, by providing some options at installation time. |
| 32 | + |
| 33 | +Create a `values.yaml` file like the following: |
| 34 | + |
| 35 | +```{code-block} yaml |
| 36 | +:caption: "values.yaml" |
| 37 | +networking: |
| 38 | + gatewayTemplates: |
| 39 | + server: |
| 40 | + service: |
| 41 | + annotations: |
| 42 | + liqo.io/override-address: <NAT_ADDRESS> |
| 43 | + liqo.io/override-port: <NAT_PORT> |
| 44 | +``` |
| 45 | + |
| 46 | +Where: |
| 47 | + |
| 48 | +- **liqo.io/override-address** is the public IP address of the NAT firewall. |
| 49 | +- **liqo.io/override-port** is the public port of the NAT firewall where you configured port mapping. |
| 50 | + |
| 51 | +At this point you can pass this file to the `install` command: |
| 52 | + |
| 53 | +```bash |
| 54 | +liqoctl install <HERE_YOUR_PROVIDER> <ARG...> --values <PATH_TO>/values.yaml |
14 | 55 | ``` |
| 56 | + |
| 57 | +If you use [Helm to install Liqo](../installation/install.md#install-with-helm), you can add those fields in your own `values.yaml`. |
0 commit comments