> For the complete documentation index, see [llms.txt](https://www.xtormin.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.xtormin.com/misc/kali-setup/vpn.md).

# VPN

## Mulldav

Mulldav - <https://mullvad.net/es>

Antes de ejecutar el siguiente comando, para no perder el acceso vía SSH, consultar la siguiente sección: [Excluir tráfico SSH](#excluir-trafico-ssh)

Posteriormente, para realizar la conexión:

```bash
sudo openvpn --config mullvad_us_mia.conf
```

### Excluir tráfico SSH

Si se desea utilizar la VPN en un VPS al que accederás mediante SSH, es posible excluir el tráfico SSH del túnel VPN para evitar la pérdida de conexión.

```bash
ip route | grep default
```

```bash
sudo ip rule add from <IP VPS> table 200
sudo ip route add default via <IP Gateway VPS> dev ens3 table 200
sudo iptables -t mangle -A OUTPUT -p tcp --sport 22 -j MARK --set-mark 2
sudo ip rule add fwmark 2 table 200
sudo iptables -t mangle -L OUTPUT -v -n
```

```bash
ip rule show
ip route show table 200
```

#### Como servicio

```bash
sudo vim /usr/local/bin/vpn_ssh_exclude.sh
sudo chmod +x /usr/local/bin/vpn_ssh_exclude.sh
```

```bash
#!/bin/bash
# Configurar reglas de enrutamiento
sudo ip rule add from <IP VPS> table 200
sudo ip route add default via <IP Gateway VPS> dev ens3 table 200

# Configurar iptables para marcar paquetes SSH
sudo iptables -t mangle -A OUTPUT -p tcp --sport 22 -j MARK --set-mark 2
sudo ip rule add fwmark 2 table 200
sudo iptables -t mangle -L OUTPUT -v -n
```

```bash
sudo dos2unix /usr/local/bin/vpn_ssh_exclude.sh
```

```bash
sudo vim /etc/systemd/system/vpnsshexclude.service
```

```bash
[Unit]
Description=Configurar reglas de rutas y iptables al inicio
After=network.target

[Service]
ExecStart=/usr/local/bin/vpn_ssh_exclude.sh
Restart=always
User=root

[Install]
WantedBy=multi-user.target
```

```bash
sudo systemctl daemon-reload
sudo systemctl restart vpnsshexclude.service
sudo systemctl status vpnsshexclude.service
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.xtormin.com/misc/kali-setup/vpn.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
