# TCP & UDP Support

:::warning

Before doing anything, make sure you've updated Newt to at least version 1.0.0-beta.5. Older versions of Newt will not work with TCP and UDP resources.

:::

Pangolin supports raw TCP and UDP traffic because under the hood because Newt can pass anything through the tunnel! There is a minor amount of manual setup you need to do to create a raw TCP or UDP resource.

### Video Demo

- ["Self-host a public Minecraft server without opening ports using Crafty and Pangolin" by Fossorial](https://youtu.be/acWB5wQQoOE?si=yONbB4o8r_gZqqU1&t=448)

## Configuring Firewall

This is highly OS and VPS dependent. Just in the same way you opened port 51820, 443, and 80, you need to open your desired port to your VPS so that Traefik can pass traffic out to the internet.

## Configuring Docker

:::note

In this example, we will expose two resources with one on port 1602 for TCP and another on port 1704 for UDP. You can use any port you like, but make sure it is not already in use on your VPS.

:::

If you are using the standard install with a Docker network you will need to expose your ports from the Gerbil Docker container as well. This can be done by simply adding a port mapping to the docker-compose.yml file you can find in the root where you installed Pangolin:

```yaml
gerbil:
    ports:
        - 51820:51820/udp # LEAVE ALONE: For Wireguard
        - 443:443 # LEAVE ALONE: For HTTPS
        - 80:80 # LEAVE ALONE: For HTTP

        - 1704:1704/udp # ADDED
        - 1602:1602 # ADDED
```

## Configuring Traefik

Once you have opened the port on your firewall you need to create an entry point in Traefik. Entry points define the port which will receive the packets, and whether to listen for TCP or UDP. Unfortunately this must be done manually because Traefik does not support pulling entry points from dynamic config locations.

But this is pretty simple! All you need to do is edit your static Traefik config in `config/traefik/traefik_config.yml` with your favorite text editor and add a new entry to the `entryPoints` section.

```yaml
entryPoints:
    udp-1704:
        address: ":1704/udp"
    tcp-1602:
        address: ":1602/tcp"
```

:::info

The _name_ of the entry point is important because it must be referenced by the dynamic config generated by Pangolin at run time. **Always name your entry point in the format `protocol-port` as shown in the examples!**

:::

Now, the whole entry points section would look something like this:

```yaml
entryPoints:
    web:
        address: ":80"
    websecure:
        address: ":443"
        http:
            tls:
                certResolver: letsencrypt
        transport:
            respondingTimeouts:
                readTimeout: 30m
    tcp-1602:
        address: ":1602/tcp"
    udp-1704:
        address: ":1704/udp"
```

## Update Config

Make sure that the `allow_raw_resources` flag in your `/config/config.yml` is set to `true`.

```yaml
flags:
    allow_raw_resources: true
```

## Restart The Stack

After you've made all of the changes above, you need to restart the stack. This can be done with the following command:

```bash
sudo docker compose down
sudo docker compose up -d
```
