> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/hacking-wifi/wpa-wpa2-psk-network-attacks/evil-twin/eviltwin-iptables-rules-and-network-interfaces.md).

# EvilTwin - reglas de iptables e interfaces de red

Configura la interfaz de red y las reglas de iptables para EvilTwin.

## Reglas de iptables e interfaces de red

Inicie Airbase para crear el punto de acceso.

### Crear el `at0` Interfaz

Cree la interfaz de red para el punto de acceso:

{% code overflow="wrap" %}

```bash
sudo ip tuntap add dev at0 mode tap
sudo ip link set at0 up
sudo ip addr add 192.168.1.129/25 dev at0
```

{% endcode %}

### Añadir la ruta de red

Añada la ruta para la nueva subred:

{% code overflow="wrap" %}

```bash
route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.129 
```

{% endcode %}

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FjiLCO3D5WQxB6G1BN8e1%2Fimage.png?alt=media&amp;token=e0676c15-c259-43eb-8eee-29c03fb95bbb" alt=""><figcaption></figcaption></figure>

La configuración debería verse así:

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FbpVLV9rfWzYBk1kIIs4G%2Fimage.png?alt=media&amp;token=6d7f5d66-d1a3-4cb6-b7de-4d67aaf423cf" alt=""><figcaption></figcaption></figure>

### Habilitar el reenvío IP

Establezca `ip_forward` a `1`:

{% code overflow="wrap" %}

```bash
echo 1 > /proc/sys/net/ipv4/ip_forward
```

{% endcode %}

### Borrar las reglas de iptables

Borre las reglas existentes:

{% code overflow="wrap" %}

```bash
sudo iptables --flush
sudo iptables --table nat --flush
sudo iptables --delete-chain
sudo iptables --table nat --delete-chain
```

{% endcode %}

### Verificar las reglas

Verifique las reglas activas:

{% code overflow="wrap" %}

```bash
iptables -S
iptables -L
```

{% endcode %}

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fy9YYWmyDDrb8Ef7qvSTp%2Fimage.png?alt=media&amp;token=b2e423d5-443d-4bea-a6d5-896bd33689ab" alt=""><figcaption></figcaption></figure>

### Configurar el reenvío y NAT

Configure la interfaz externa para reenviar tráfico a `at0`. Además, redirija el tráfico HTTP:

{% code overflow="wrap" %}

```bash
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface at0 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination $(hostname -I | awk '{print $1}'):80
iptables -t nat -A POSTROUTING -j MASQUERADE
```

{% endcode %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/es/hacking-wifi/wpa-wpa2-psk-network-attacks/evil-twin/eviltwin-iptables-rules-and-network-interfaces.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
