ce petit tuto se base sur la doc officielle pour créer un AP mais adapté au but poursuivi ici.
je vais prendre pour principe:
votre RPI est connecté au wifi
SSH est actif
se loger en SSH au rpi
donner une IP fixe a eth0
Code: Select all
sudo nano /etc/dhcpcd.conf
Code: Select all
#Example static IP configuration:
interface eth0
static ip_address=192.168.0.254/24puis sauvegardez et quittez nano
Activez ipv4 forwarding dans sysctl.conf
Code: Select all
sudo nano /etc/sysctl.confCode: Select all
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1dans /etc/rc.local on ajoute a la fin (il doit se finir par exit 0):
Code: Select all
# wlan0 txpower
iwconfig wlan0 txpower 5
# IP table ruls
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
Et on reboot
Code: Select all
sudo rebootCode: Select all
sudo apt install dnsmasq
Code: Select all
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv
Code: Select all
# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
interface=eth0Code: Select all
# Uncomment this to enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
dhcp-range=192.168.0.10,192.168.0.99,12h
on sauvegarde le fichier puis on redémarre le service
Code: Select all
sudo service dnsmasq restartUn router fonctionnel.
Petit bémol entre le PC et le PI on est en ipv4 mais entre le pi et internet c'est ipv4 et ipv6, pour le reste a vous de voir.