Partage de connexion internet

Bojour à tous,
Je souhaiterais configurer mon pc sous debian pour qu’il partage sa connexion internet (interface wifi) par le biais de l’interface ethernet (eth0) mais je ne sais pas comment m’y prendre.
Quelqu’un saurait il m’expliquer la procédure à suivre, svp?
Merci d’avance.

Ci-joint les fichiers de configuration du serveur dhcp et de /etc/network/interfaces:
Fichier de configuration interfaces:

auto lo
iface lo inet loopback
// Interface ethernet (sur laquelle je souhaiterais que les ordinateurs puissent utiliser la connexion wifi de ce même pc)
auto eth0
allow-hotplug eth0
iface eth0 inet static
        address 192.168.0.1
        netmask 255.255.255.0
        broadcast 192.168.0.255
        network 192.168.0.0

Fichier de configuration du serveur dhcp:

# DHCP configuration generated by Firestarter
ddns-update-style interim;
ignore client-updates;
authoritative;

subnet 192.168.0.0 netmask 255.255.255.0 {
        option routers 192.168.0.1;
        option subnet-mask 255.255.255.0;
        option domain-name-servers 192.168.0.1;
        option ip-forwarding off;
        range dynamic-bootp 192.168.0.2 192.168.0.254;
        default-lease-time 21600;
        max-lease-time 43200;
}

host utilisat-9d751d
{
        hardware ethernet 00:14:0B:39:A2:93;
        fixed-address 192.168.0.2;
}

Iptables est ton ami :slightly_smiling: Je ne vais pas t’expliquer ici toute la procedures de configuration il y’a enormement de documentations dispo sur le net au sujet d’iptables. D’autant que la config n’est pas forcement simple au debut il faut un moment avant de bien maitriser les options de base :slightly_smiling:

Ok, et comment je fais pour qu’il daigne l’activer au boot (parce que mon autre pc a une carte wifi dont je ne détient pas le pilote adapté pour une architecture 64 bits)?

Salut, déjà active le forward :
vim /etc/sysctl.conf

decommente la ligne :
net.ipv4.ip_forward=1

Ce qui te permettra de l’avoir à chaque démarrage
(ou pour tester tu peux faire echo 1 > /proc/sys/net/ipv4/ip-forward)

après comme dit nokcy “Iptables est ton ami :slightly_smiling:
Pour exemple je peux te passer celui d’un chillispot, c’est mieux que rien :wink:!!
Oupss… désolé je n’arrive pas à mettre un fichier joint… :arrow_right:
du coup :

[quote]#!/bin/sh

Firewall script for ChilliSpot

A Wireless LAN Access Point Controller

Uses $EXTIF (eth0) as the external interface (Internet or intranet) and

$INTIF (eth1) as the internal interface (access points).

SUMMARY

* All connections originating from chilli are allowed.

* Only ssh is allowed in on external interface.

* Nothing is allowed in on internal interface.

* Forwarding is allowed to and from the external interface, but disallowed

to and from the internal interface.

* NAT is enabled on the external interface.

IPTABLES="/sbin/iptables"
EXTIF=“eth0”
INTIF=“ath0”

$IPTABLES -P INPUT DROP
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT

#Allow related and established on all interfaces (input)
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

#Allow releated, established and ssh on $EXTIF. Reject everything else.
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -j REJECT

#Allow related and established from $INTIF. Drop everything else.
$IPTABLES -A INPUT -i $INTIF -j DROP

#Allow http and https on other interfaces (input).
#This is only needed if authentication server is on same server as chilli
$IPTABLES -A INPUT -p tcp -m tcp --dport 80 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 443 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 500 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 264 --syn -j ACCEPT
$IPTABLES -A INPUT -p udp --dport 259 -m state --state ESTABLISHED -j ACCEPT

#Allow 3990 on other interfaces (input).
$IPTABLES -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT

#Allow everything on loopback interface.
$IPTABLES -A INPUT -i lo -j ACCEPT

Drop everything to and from $INTIF (forward)

This means that access points can only be managed from ChilliSpot

$IPTABLES -A FORWARD -i $INTIF -j DROP
$IPTABLES -A FORWARD -o $INTIF -j DROP

#Enable NAT on output device
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

#Renouvellement des baux
$IPTABLES -A INPUT -i $INTIF -p udp --sport 68 --dport 67 -j ACCEPT[/quote]

ceci n’est qu’un exemple à toi de jouer maintenant
++ :smt006

Salut,
Merci pour le script.
J’ai une question a propos de tes deux variables $EXTIF et $INTIF:
Tu me conseillerais de mettre l’interface wifi (wlan0) qui possède l’accès à internet dans laquelle de ces deux variables?
Merci d’avance.

Uses $EXTIF (eth0) as the external interface (Internet or intranet) and

$INTIF (eth1) as the internal interface (access points).

$EXTIF est l’interface externe(internet). donc wlan0 pour toi
et $INIF pour eth0
mais l’iptable est pour un chillispot et je ne l’ai pas testé sans chilli…

vas plutôt voir cette article :

Unixgarden

bon week
++

Merci pour le script.
Tout fonctionne maintenant.
Bon week-end à toi.