> 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/pt-br/hacking-wifi/wpa-wpa2-psk-network-attacks/evil-twin/eviltwin-iptables-rules-and-network-interfaces.md).

# EvilTwin - Regras de iptables e Interfaces de Rede

Configure a interface de rede e as regras de iptables para o EvilTwin.

## Regras do iptables e interfaces de rede

Inicie o Airbase para criar o ponto de acesso.

### Crie o `at0` Interface

Crie a interface de rede para o ponto de acesso:

{% 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 %}

### Adicionar a rota de rede

Adicione a rota para a nova sub-rede:

{% 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://783634792-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>

A configuração deve ficar assim:

<figure><img src="https://783634792-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>

### Ativar o encaminhamento de IP

Defina `ip_forward` para `1`:

{% code overflow="wrap" %}

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

{% endcode %}

### Limpar as regras do iptables

Limpe as regras 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 as regras

Verifique as regras ativas:

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="https://783634792-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 encaminhamento e NAT

Configure a interface externa para encaminhar tráfego para `at0`. Além disso, redirecione o tráfego 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/pt-br/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.
