Iptables : partage de connexion internet
Comprendre
Partager une connexion sous linux est assez simple ...
mode console
# Forwarding ! Important... Permet de rediriger tout paquet sur le LANecho 1 > /proc/sys/net/ipv4/ip_forwardecho 1 > /proc/sys/net/ipv6/ip_forwardscript
En ip extérieur statique
iptables -t nat -A POSTROUTING -o eth1-j SNAT --to 1.2.3.4En ip extérieur dynamique
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADEExemple :
echo "NAT"iptables -A FORWARD -i eth0 -o ppp0 -s 192.168.0.0/24 -m state --state ! INVALID -j ACCEPTiptables -A FORWARD -i ppp0 -o eth0 -d 192.168.0.0/24 -m state --state ESTABLISHED,RELATED -j ACCEPTiptables -t nat -A POSTROUTING -o ppp0 -s 192.168.0.0/24 -j MASQUERADEFichier /etc/sysctl.conf
# Uncomment the next line to enable packet forwarding for IPv4net.ipv4.ip_forward=1# Uncomment the next line to enable packet forwarding for IPv6net.ipv6.ip_forward=1
<<| Page : IpTables : FAQ : partage_connexion : |>>