View previous topic :: View next topic |
Author |
Message |
Marsu Guru


Joined: 18 Jun 2003 Posts: 329 Location: Lyon
|
Posted: Sun Sep 14, 2003 1:43 pm Post subject: [reseau] partage de connexion (résolu) |
|
|
j'aimerais partager ma connexion d'une gentoo à une installation de gentoo, mais j'y arrive pas, pourtant, le reseau marche, le ping est positif.
quand je fais route ça retourne ce que ça doit retourner
faut faire quelque chose de spécial sur la machine connectée pour que la connexion soit partagée ?? j'ai iptables qui marche, j'ai essayé
Code: |
# iptables -F
# iptables -X
# iptables -F FORWARD
# iptables -A FORWARD -j ACCEPT
# iptables -A POSTROUTING -t nat -o ppp0 -j MASQUERADE
|
enfin bon, ça marche toujours pas _________________ qui ne tente rien n'a rien
Last edited by Marsu on Wed Sep 17, 2003 2:49 pm; edited 1 time in total |
|
Back to top |
|
 |
Doudou Apprentice


Joined: 10 Jan 2003 Posts: 286 Location: Paris, France
|
Posted: Sun Sep 14, 2003 2:28 pm Post subject: |
|
|
Je te passe un petit script que j'avais fait pour patager ma connexion via un Sagem Fast 800 :
Code: |
doudou@doudou doudou $ cat /etc/init.d/pat
#!/sbin/runscript
# Doudou Made
depend() {
need eagle-adsl
}
start() {
ebegin "Starting Port Adress Translation"
# Obligatoir
echo 1 > /proc/sys/net/ipv4/ip_forward
# Anti Spoof
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter
# Config Masquerading
iptables -F FORWARD
iptables -A FORWARD -j ACCEPT
iptables -A POSTROUTING -t nat -o eth1 -j MASQUERADE
eend $? "Failed to lunch Port Adress Translation"
}
stop() {
ebegin "Stopping Port Adress Translation"
echo 0 > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
iptables -F FORWARD
eend $? "Failed to stop Port Adress Translation"
}
|
Ca devrait t'aider . |
|
Back to top |
|
 |
Marsu Guru


Joined: 18 Jun 2003 Posts: 329 Location: Lyon
|
Posted: Sun Sep 14, 2003 3:54 pm Post subject: |
|
|
merci, ça marche nickel, grâce à toi, je sens que je vais apprendre à faire des scripts
si je supprime la fonction depend, pourquoi ça me met un syntax error, cela arrive aussi si je la vide
PS : ça peut toujours servir de savoir faire des script
edit ::: enfait, non, ça marche pas, y'a juste le ping qui marche, j'arrive pas à accèder à quoi que ce soit à partir de l'ordi qui a besoin de l'accès _________________ qui ne tente rien n'a rien |
|
Back to top |
|
 |
Diorf n00b

Joined: 05 Jun 2003 Posts: 52 Location: Paris
|
Posted: Sun Sep 14, 2003 4:38 pm Post subject: |
|
|
d'apres ce que j'ai compris, tu n'arrives pas a pinger google.fr mais tu arrives a pinger 216.239.33.100 ou 216.239.37.100 ou encore 216.239.39.100 (les trois ip de google.fr).
Si c'est bien ca ton probleme, la solution pour le regler tres simplement c'est de rajouter l'addresse d'un dns sur internet (194.117.200.15 et 194.117.200.10 pour ceux de club-internet ou mets ceux de ton FAI ce sera mieux) sur la machine qui a besoin de l'acces internet et tout devrait rentrer dans l'ordre.
En esperant que j'aille bien saisi le problème  |
|
Back to top |
|
 |
yuk159 Veteran


Joined: 18 Apr 2003 Posts: 1803 Location: noumea ,nouvelle-caledonie
|
Posted: Sun Sep 14, 2003 5:38 pm Post subject: |
|
|
Voila un petit script que j'utilise pour mon poste chez moi :
Code: | #!/bin/sh
# firewall v1.0 Sept 15 20:45:21 PDT 2001 written by : Kernel <kernel@trustonme.net>
# this script is free software according to the GNU General Public License (see http://www.gnu.org/licenses/gpl.html)
# Start/stop/restart/status firewall:
firewall_start() {
echo "[Démarrage du firewall]"
############################### REGLES PAR DEFAUT ###########################
echo "[Initialisation de la table filter]"
iptables -F
iptables -X
echo "[Politique par défaut de la table filter]"
# On ignore tout ce qui entre ou transite par la passerelle
iptables -P INPUT DROP
iptables -P FORWARD DROP
# On accepte, ce qui sort
iptables -P OUTPUT ACCEPT
# Pour éviter les mauvaises suprises, on va
# autoriser l'accès à la loopback, c'est vital !
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
############################### LOCAL-INTERNET ###########################
echo "[On autorise les clients à accéder à internet ]"
#On créé une nouvelle chaîne, le nom est indifférent
# appelons-la "local-internet"
iptables -N local-internet
# On définit le profil de ceux qui appartiendront à "local-internet"
# "local-internet" concerne toutes les connections sauf celles venant d'internet ( ! = non)
# En gros avec ça, vous rendez, vos serveurs inaccessibles depuis internet.
# Pas de panique, certains serveurs seront autorisés explicitement dans la suite.
iptables -A local-internet -m state --state NEW -i ! ppp0 -j ACCEPT
#Evidemment, une fois acceptées comme "local-internet", les connections peuvent continuer
# et faire des petits :-)
iptables -A local-internet -m state --state ESTABLISHED,RELATED -j ACCEPT
# On termine en indiquant que les connections appartenant à "local-internet"
# accèdent à internet de manière transparente.
iptables -A INPUT -j local-internet
iptables -A FORWARD -j local-internet
############################### LES TABLES NAT ET MANGLE #############################
echo "[Initialisation des tables nat et mangle]"
iptables -t nat -F
iptables -t nat -X
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t mangle -F
iptables -t mangle -X
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
#################################### LE MASQUERADING ########################################
# Commentez ces 2 lignes, si vous ne faîtes pas du masquerading (nat)
echo "[Mise en place du masquerading]"
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o ppp0 -j MASQUERADE
################################# ACTIVATION DE LA PASSERELLE ##################
echo "[Activation de la passerelle]"
echo 1 > /proc/sys/net/ipv4/ip_forward
################################# PAS DE SPOOFING ############################
echo "[Pas de spoofing]"
if [ -e /proc/sys/net/ipv4/conf/all/rp_filter ] ; then
for filtre in /proc/sys/net/ipv4/conf/*/rp_filter
do
echo 1 > $filtre
done
fi
########################## PAS DE SYNFLOOD ####################
echo "[Pas de synflood]"
if [ -e /proc/sys/net/ipv4/tcp_syncookies ] ; then
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
fi
################################## PAS DE PING ###############################
# commentez ces 6 lignes, si vous autorisez les pings sur votre passerelle
echo "[Pas ping]"
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
if [ -e /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses ] ; then
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
fi
############################ Fonctionnalités serveurs #####################################
echo "[Etude des fonctionalités serveurs, visibles depuis internet ]"
# A ce stade, tous vos clients du réseau local et de la passerelle ont accès à internet. Mieux,
# vos clients du réseau local, ont accès à vos serveurs apache, proftp ... localement. Mais personne
# depuis internet ne peux accéder à l'un des serveurs que vous hébergés.
# Il est bien-sûr possible de dévérrouiller pontuellement l'accès à un serveur depuis internet,
# en décommentant les 2 ou 3 lignes correspondantes.
#echo "[autorisation du serveur ssh(22) ...]"
#iptables -A INPUT -p tcp --dport ssh -j ACCEPT
#echo "[autorisation du serveur smtp(25) ...]"
#iptables -A INPUT -p tcp --dport smtp -j ACCEPT
#echo "[autorisation du serveur http(80) ...]"
#iptables -A INPUT -p tcp --dport www -j ACCEPT
#echo "[autorisation du serveur https(443) ...]"
#iptables -A INPUT -p tcp --dport https -j ACCEPT
#echo "[autorisation du serveur DNS(53) ...]"
#iptables -A INPUT -p udp --dport domain -j ACCEPT
#iptables -A INPUT -p tcp --dport domain -j ACCEPT
#echo "[autorisation du serveur irc(6667) ...]"
#iptables -A INPUT -p tcp --dport ircd -j ACCEPT
#echo "[autorisation du serveur cvs (2401) ...]"
#iptables -A INPUT -p tcp --dport cvspserver -j ACCEPT
#echo "[autorisation du serveur FTP(21 et 20) ...]"
#iptables -A INPUT -p tcp --dport ftp -j ACCEPT
#iptables -A INPUT -p tcp --dport ftp-data -j ACCEPT
# Ne pas décommenter les 3 lignes qui suivent.
# Plus généralement :
#echo "[autorisation du serveur Mon_truc(10584) ...]"
#iptables -A INPUT -p tcp --dport 10584 -j ACCEPT
echo "[firewall activé !]"
}
firewall_stop() {
iptables -F
iptables -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -F
iptables -t nat -X
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t mangle -F
iptables -t mangle -X
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
echo " [firewall descativé! ]"
}
firewall_restart() {
firewall_stop
sleep 2
firewall_start
}
case "$1" in
'start')
firewall_start
;;
'stop')
firewall_stop
;;
'restart')
firewall_restart
;;
'status')
iptables -L
iptables -t nat -L
iptables -t mangle -L
;;
*)
echo "Usage: firewall {start|stop|restart|status}"
esac |
Comme ca tu a un petit firewall et tu peu partager ta connection.
Ce n'est pas de moi donc pour les credits ca ce passe tout en haut du script
Leur site : http://trustonme.net/
Par contre si c'est un probleme de DNS il ne fonctionnera pas plus que le script de Doudou
PS:si tu veux l'activer au demarrage je te conseil de le mettre dans /etc/init.d/firewall et de rajouter dans /etc/conf.d/local.start comme ceci : /etc/init.d/firewall start _________________ The box said: "Requires Windows 98/2000/XP/NT, or better."
So, I installed LINUX!
Instagram |
|
Back to top |
|
 |
TGL Bodhisattva

Joined: 02 Jun 2002 Posts: 1978 Location: Rennes, France
|
Posted: Sun Sep 14, 2003 10:46 pm Post subject: |
|
|
yuk, j'adore ta notion de "petit script"
Bon, alors quand à moi, les bits qui vont bien je les ai mis dans dans mon /etc/sysctl.conf, et puis j'utilise shorewall pour configurer le partage en suivant cette howto qu'est pas bien compliqué, et puis voilà. Bah ouais, j'sais pas, iptable à la mano, j'ai toujours fait un blocage... Mais j'admire votre érudition à tous sur ce terrain  |
|
Back to top |
|
 |
Leander256 l33t


Joined: 05 Jul 2003 Posts: 910 Location: Singapour
|
Posted: Sun Sep 14, 2003 11:31 pm Post subject: |
|
|
Oui petit script en effet... Je pense qu'il va marcher, mais juste pour le principe, je vais donner mon avis. J'ai l'impression que ça coince parce que tu n'a pas autorisé le INPUT et/ou le OUTPUT sur ta machine:
Code: | iptables -F INPUT
iptables -F OUTPUT
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
|
Tu as peut-être de vieilles règles pour ces chaînes qui empêchent l'échange de paquets autres que ICMP entre tes deux ordis.
Attention qu'avec ces règles n'importe qui peut se connecter sur ta passerelle depuis internet, à la place de la troisième ligne il vaudrait mieux (en considérant que eth0 est ta carte réseau pour le réseau local):
Code: | iptables -P INPUT DROP
iptables -A INPUT -i eth0 -j ACCEPT
|
Voilà c'était ma petite contribution, je suis pas un spécialiste du firewall, j'ai presque tout appris grâce aux deux hors série de linux mag en coopération avec misc magazine: "le firewall, votre meilleur ennemi?". C'est peut-être pas le meilleur point de départ mais en tout cas c'est très intéressant/instructif. |
|
Back to top |
|
 |
yuk159 Veteran


Joined: 18 Apr 2003 Posts: 1803 Location: noumea ,nouvelle-caledonie
|
Posted: Mon Sep 15, 2003 6:22 am Post subject: |
|
|
Merci Leander je vais regarder ca  _________________ The box said: "Requires Windows 98/2000/XP/NT, or better."
So, I installed LINUX!
Instagram |
|
Back to top |
|
 |
Leander256 l33t


Joined: 05 Jul 2003 Posts: 910 Location: Singapour
|
Posted: Mon Sep 15, 2003 6:34 am Post subject: |
|
|
yuk159 wrote: | Merci Leander je vais regarder ca  |
Heu.. c'était pas de ton script que je parlais pour les éventuelles corrections Je faisais juste une suggestion tardive pour son problème. Ou alors j'ai mal compris? |
|
Back to top |
|
 |
yuk159 Veteran


Joined: 18 Apr 2003 Posts: 1803 Location: noumea ,nouvelle-caledonie
|
Posted: Mon Sep 15, 2003 6:44 am Post subject: |
|
|
je l'ai pris pour moi desoler _________________ The box said: "Requires Windows 98/2000/XP/NT, or better."
So, I installed LINUX!
Instagram |
|
Back to top |
|
 |
Marsu Guru


Joined: 18 Jun 2003 Posts: 329 Location: Lyon
|
Posted: Mon Sep 15, 2003 11:58 am Post subject: |
|
|
j'essayerais ça ce soir, pour l'instant, j'ai encore plein de DMs à faire pour demain (je sais, je ne m'y prends pas à l'avance ... ) _________________ qui ne tente rien n'a rien |
|
Back to top |
|
 |
Doudou Apprentice


Joined: 10 Jan 2003 Posts: 286 Location: Paris, France
|
Posted: Mon Sep 15, 2003 8:17 pm Post subject: |
|
|
TGL wrote: | yuk, j'adore ta notion de "petit script"
... Mais j'admire votre érudition à tous sur ce terrain  |
votre quoi?!?  |
|
Back to top |
|
 |
ttgeub Guru


Joined: 20 Jan 2003 Posts: 494 Location: Eindhoven
|
Posted: Mon Sep 15, 2003 8:40 pm Post subject: |
|
|
moi aussi je veux jouer, voici mon petit script pour mon partage de connection et le firewall associé :
Code: |
#!/bin/bash
# Philippe DUMONT
# 13 jully 2003
# Firewall for lan bridge
###########################################################
#
# Configuration part of the script
#
###########################################################
CONF_FILE_PATH=/etc
CONF_FILE_NAME=firewall.conf ;
CONF_FILE=$CONF_FILE_PATH/$CONF_FILE_NAME
if [ -e $CONF_FILE ]; then
source $CONF_FILE
else
echo "Unable to find the configuration file !"; exit 1;
fi
#################################################################
#
# Don't change the following lines unless you know what to do
#
#################################################################
#
# Netfilter function
#
#Clear all rules of the firewall
firewall-clear()
{
# on enleve toutes les chaines existantes de la table FILTER
$IPTABLES -F
$IPTABLES -X
# on enleve toutes les chaines existantes de la table NAT
$IPTABLES -t nat -F
$IPTABLES -t nat -X
}
#Show the status of the firewall
firewall-status()
{
echo "################### FILTER ###################"
$IPTABLES -L -v
echo ""
echo "#################### NAT ####################"
$IPTABLES -t nat -L -v
}
#Common rules for all the functions
filter-commonrules()
{
if [ "$COMMONRULES" != DEFINED ]
then
COMMONRULES=DEFINED
#des chaines simples
#chaine BLOCK
$IPTABLES -N BLOCK
if [ "$LOG" = enable ]; then
$IPTABLES -A BLOCK -j LOG --log-level warning --log-prefix 'IPFILTER - BLOCK '
fi
if [ "$ULOG" = enable ]; then
$IPTABLES -A BLOCK -j ULOG --ulog-nlgroup 1 --ulog-prefix ' - BLOCK - '
fi
$IPTABLES -A BLOCK -j DROP
#chaine NOTIFY
$IPTABLES -N NOTIFY
if [ "$LOG" = enable ]; then
$IPTABLES -A NOTIFY -j LOG --log-level warning --log-prefix 'IPFILTER - NOTIFY '
fi
if [ "$ULOG" = enable ]; then
$IPTABLES -A NOTIFY -j ULOG --ulog-nlgroup 1 --ulog-prefix ' - NOTIFY - '
fi
$IPTABLES -A NOTIFY -j REJECT --reject-with icmp-port-unreachable
#chaine WATCH
$IPTABLES -N WATCH
if [ "$LOG" = enable ]; then
$IPTABLES -A WATCH -j LOG --log-level warning --log-prefix 'IPFILTER - LOG '
fi
if [ "$ULOG" = enable ]; then
$IPTABLES -A WATCH -j ULOG --ulog-nlgroup 1 --ulog-prefix ' - WATCH - '
fi
$IPTABLES -A WATCH -j ACCEPT
#chaine ICMP
$IPTABLES -N ICMP
$IPTABLES -A ICMP -p icmp --icmp-type echo-reply -j ACCEPT
$IPTABLES -A ICMP -p icmp --icmp-type destination-unreachable -j ACCEPT
$IPTABLES -A ICMP -p icmp --icmp-type echo-request -j WATCH
$IPTABLES -A ICMP -p icmp --icmp-type time-exceeded -j ACCEPT
$IPTABLES -A ICMP -p icmp --icmp-type parameter-problem -j ACCEPT
$IPTABLES -A ICMP -p icmp --icmp-type timestamp-request -j ACCEPT
$IPTABLES -A ICMP -p icmp --icmp-type timestamp-reply -j ACCEPT
fi
}
#Function called when the lan protection is disable
lan-protection-disable()
{
# on fixe le comportement par defaut
$IPTABLES -P FORWARD ACCEPT
}
#Function called when the lan protection is enable
lan-protection-enable()
{
#on fixe le comportement par defaut
$IPTABLES -P FORWARD DROP
filter-commonrules
#la chaine pour FORWARD
#chaine EXT_FORWARD
$IPTABLES -N EXT_FORWARD
$IPTABLES -A EXT_FORWARD -s 127.0.0.0/8 -j BLOCK
#de LAN vers NET
$IPTABLES -A EXT_FORWARD -i $LAN -o $NET -p icmp -j ACCEPT
for PORT in $FORWARD_LAN_NET_TCP_PORT_ACCEPTED; do
$IPTABLES -A EXT_FORWARD -i $LAN -o $NET -p tcp --destination-port $PORT -j ACCEPT
done
for PORT in $FORWARD_LAN_NET_UDP_PORT_ACCEPTED; do
$IPTABLES -A EXT_FORWARD -i $LAN -o $NET -p udp --destination-port $PORT -j ACCEPT
done
for PORT in $FORWARD_LAN_NET_TCP_PORT_WATCHED; do
$IPTABLES -A EXT_FORWARD -i $LAN -o $NET -p tcp --destination-port $PORT -j WATCH
done
for PORT in $FORWARD_LAN_NET_UDP_PORT_WATCHED; do
$IPTABLES -A EXT_FORWARD -i $LAN -o $NET -p udp --destination-port $PORT -j WATCH
done
#du NET vers LAN
for PORT in $FORWARD_NET_LAN_TCP_PORT_ACCEPTED; do
$IPTABLES -A EXT_FORWARD -i $NET -o $LAN -p tcp --destination-port $PORT -j ACCEPT
done
for PORT in $FORWARD_NET_LAN_UDP_PORT_ACCEPTED; do
$IPTABLES -A EXT_FORWARD -i $NET -o $LAN -p udp --destination-port $PORT -j ACCEPT
done
for PORT in $FORWARD_NET_LAN_TCP_PORT_WATCHED; do
$IPTABLES -A EXT_FORWARD -i $NET -o $LAN -p tcp --destination-port $PORT -j WATCH
done
for PORT in $FORWARD_NET_LAN_UDP_PORT_WATCHED; do
$IPTABLES -A EXT_FORWARD -i $NET -o $LAN -p udp --destination-port $PORT -j WATCH
done
#en general
$IPTABLES -A EXT_FORWARD -p tcp -m state --state RELATED -j ACCEPT
$IPTABLES -A EXT_FORWARD -p icmp -m state --state ESTABLISHED -j ICMP
$IPTABLES -A EXT_FORWARD -p tcp -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A EXT_FORWARD -p udp -m state --state ESTABLISHED -j ACCEPT
if [ "$DEDICATED" = false ]
then
for PORT in $GAMES_PORTS; do
$IPTABLES -A EXT_FORWARD -p tcp --destination-port $PORT -j ACCEPT
$IPTABLES -A EXT_FORWARD -p udp --destination-port $PORT -j ACCEPT
done
fi
$IPTABLES -A EXT_FORWARD -p tcp -j NOTIFY
$IPTABLES -A EXT_FORWARD -p udp -j NOTIFY
#on relie le tout a la chaine FORWARD
$IPTABLES -A FORWARD -j EXT_FORWARD
}
#Function called when the local protection is disable
local-protection-disable()
{
# on fixe le comportement par defaut
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
}
#Function called when the local protection is enable
local-protection-enable()
{
# on fixe le comportement par defaut
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT ACCEPT
# on accept tout ce qui vient de localhost et du lan
$IPTABLES -A INPUT -i $LO -j ACCEPT
$IPTABLES -A INPUT -i $LAN -j ACCEPT
filter-commonrules
#chaine EXT_INPUT
$IPTABLES -N EXT_INPUT
$IPTABLES -A EXT_INPUT -s 127.0.0.0/8 -j BLOCK
$IPTABLES -A EXT_INPUT -p icmp -j ICMP
for PORT in $INPUT_TCP_PORT_ACCEPTED; do
$IPTABLES -A EXT_INPUT -p tcp --destination-port $PORT -j ACCEPT
done
for PORT in $INPUT_UDP_PORT_ACCEPTED; do
$IPTABLES -A EXT_INPUT -p udp --destination-port $PORT -j ACCEPT
done
if [ "$DEDICATED" = true ]
then
for PORT in $GAMES_PORTS; do
$IPTABLES -A EXT_INPUT -p tcp --destination-port $PORT -j ACCEPT
$IPTABLES -A EXT_INPUT -p udp --destination-port $PORT -j ACCEPT
done
fi
$IPTABLES -A EXT_INPUT -p tcp -m state --state RELATED -j ACCEPT
$IPTABLES -A EXT_INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A EXT_INPUT -p udp -m state --state ESTABLISHED -j ACCEPT
for PORT in $INPUT_TCP_PORT_WATCHED; do
$IPTABLES -A EXT_INPUT -p tcp --destination-port $PORT -j WATCH
done
for PORT in $INPUT_UDP_PORT_WATCHED; do
$IPTABLES -A EXT_INPUT -p udp --destination-port $PORT -j WATCH
done
for PORT in $INPUT_TCP_PORT_NOTIFIED; do
$IPTABLES -A EXT_INPUT -p tcp --destination-port $PORT -j NOTIFY
done
for PORT in $INPUT_UDP_PORT_NOTIFIED; do
$IPTABLES -A EXT_INPUT -p udp --destination-port $PORT -j NOTIFY
done
$IPTABLES -A EXT_INPUT -p tcp -j REJECT --reject-with icmp-port-unreachable
$IPTABLES -A EXT_INPUT -p udp -j REJECT --reject-with icmp-port-unreachable
#on relie le tout a la chaine INPUT
$IPTABLES -A INPUT -i $NET -j EXT_INPUT
}
#Function called when the masquerading is disable
masquerading-disable()
{
echo "0" > /proc/sys/net/ipv4/ip_forward
if [ ! -z "$ALLOWED_HOST" ]
then
$IPTABLES -t nat -N EXT_POSTROUTING
for DEST in $ALLOWED_HOST; do
$IPTABLES -t nat -A EXT_POSTROUTING -d $DEST -j ACCEPT
done
$IPTABLES -t nat -A POSTROUTING -o $NET -j EXT_POSTROUTING
fi
}
#Function called when the masquerading is enable
masquerading-enable()
{
echo "1" > /proc/sys/net/ipv4/ip_forward
$IPTABLES -t nat -N EXT_POSTROUTING
if [ ! -z "$ALLOWED_HOST" ]
then
for DEST in $ALLOWED_HOST; do
$IPTABLES -t nat -A EXT_POSTROUTING -d $DEST -j MASQUERADE
done
else
$IPTABLES -t nat -A EXT_POSTROUTING -o $NET -j MASQUERADE
fi
$IPTABLES -t nat -A POSTROUTING -o $NET -j EXT_POSTROUTING
}
#Function called when the masquerading is enable
nat-conf()
{
# on fixe le comportement par defaut
$IPTABLES -t nat -P OUTPUT ACCEPT
$IPTABLES -t nat -P PREROUTING ACCEPT
if [ ! -z "$ALLOWED_HOST" ]
then
$IPTABLES -t nat -P POSTROUTING DROP
elif [ ! -z "$DISALLOWED_HOST" ]
then
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -N EXT_POSTROUTING_2
for DEST in $DISALLOWED_HOST; do
$IPTABLES -t nat -A EXT_POSTROUTING_2 -d $DEST -j DROP
done
$IPTABLES -t nat -A POSTROUTING -o $NET -j EXT_POSTROUTING_2
else
$IPTABLES -t nat -P POSTROUTING ACCEPT
fi
if [ "$DEDICATED" = false ]
then
$IPTABLES -t nat -N EXT_PREROUTING
for PORT in $GAMES_PORTS; do
$IPTABLES -t nat -A EXT_PREROUTING -d $NET_IP -p tcp --dport $PORT -j DNAT --to $GAME_SERVER
$IPTABLES -t nat -A EXT_PREROUTING -d $NET_IP -p udp --dport $PORT -j DNAT --to $GAME_SERVER
done
$IPTABLES -t nat -A PREROUTING -i $NET -j EXT_PREROUTING
fi
}
#################################################################
#
# Script function
#
help()
{
if [ -z "$DISALLOWED_HOST" ]; then
H_DISALLOWED_HOST=none
else
H_DISALLOWED_HOST=$DISALLOWED_HOST
fi
if [ -z "$ALLOWED_HOST" ]; then
H_ALLOWED_HOST=none
else
H_ALLOWED_HOST=$ALLOWED_HOST
fi
if [ -z "$GAME_SERVER" ]; then
H_GAME_SERVER=none
else
H_GAME_SERVER=$GAME_SERVER
fi
cat <<EOF
Usage: $0 [OPTIONS] mode
Configuration:
-h, --help display this help and exit
Mode: (choose only one)
e, enable-protection enable all firewall and masquerading
d, disable-protection disable all firewall and masquerading
s, status display the firewall rules for table filter and nat
Optional features :
--disable-FEATURE disable this feature
--enable-FEATURE enable this feature
Features list :
local-protection firewall for localhost on input and output
lan-protection firewall for localhost forward
masquerading masquerading between lan and net
Simple options :
--disable-OPTION disable this option
--enable-OPTION enable this option
Options list :
status show the state of the firewall at the end [$STATUS]
syslog use syslog to log firewall [$LOG]
ulogd use ulogd to log firewall [$ULOG]
Advanced options : (IP_HOST is list of IP separated by space)
--allow-host=IP_HOST allow communication only with selected host [$H_ALLOWED_HOST]
--disallow-host=IP_HOST disallow communication only with selected host [$H_DISALLOWED_HOST]
--with-game-server=IP_LOCAL set the ip of the lan game server 192.168.x.y [$H_GAME_SERVER]
EOF
}
launchfeature()
{
firewall-clear
nat-conf
if [ "$LOCAL_PROTECTION" = enable ]
then
local-protection-enable
else
local-protection-disable
fi
if [ "$LAN_PROTECTION" = enable ]
then
lan-protection-enable
else
lan-protection-disable
fi
if [ "$MASQUERADING" = enable ]
then
masquerading-enable
else
masquerading-disable
fi
if [ "$STATUS" = enable ]
then
firewall-status
fi
}
launchmode()
{
# Test if a major mode has been selected
if [ -z "$MAJOR_MODE" ]
then
echo "you have to choose a major mode !"
exit 1
fi
# Include the scripts in the path
PATH=$PATH:$SCRIPT_PATH
# Display the filter and nat table if major mode is status
if [ "$MAJOR_MODE" = s ]
then
firewall-status
# Set the default value for the major mode diable
elif [ "$MAJOR_MODE" = d ]
then
if [ -z "$LOCAL_PROTECTION" ]
then
LOCAL_PROTECTION=disable
fi
if [ -z "$LAN_PROTECTION" ]
then
LAN_PROTECTION=disable
fi
if [ -z "$MASQUERADING" ]
then
MASQUERADING=disable
fi
launchfeature
exit 0
# Set the default value for the major mode enable
elif [ "$MAJOR_MODE" = e ]
then
if [ -z "$LOCAL_PROTECTION" ]
then
LOCAL_PROTECTION=enable
fi
if [ -z "$LAN_PROTECTION" ]
then
LAN_PROTECTION=enable
fi
if [ -z "$MASQUERADING" ]
then
MASQUERADING=enable
fi
launchfeature
exit 0
fi
}
checkip2()
{
TEST_IP=`echo $IP | sed 's/[0-9]//g'`
TEST_IP=`echo $TEST_IP | sed 's/\.//g'`
if [ ! -z "$TEST_IP" ]
then
echo "$IP is not a valid IP address"; exit 1;
fi
TEST_IP=`echo $IP | sed 's/\./ /g'`
for I in $TEST_IP; do
if [ "$I" -gt 255 ]
then
echo "$IP is not a valid IP address (0-255)"; exit 1;
fi
done
}
checkip()
{
if [ ! -z "$ALLOWED_HOST" ]
then
for IP in $ALLOWED_HOST; do
checkip2
done
fi
if [ ! -z "$DISALLOWED_HOST" ]
then
for IP in $DISALLOWED_HOST; do
checkip2
done
fi
if [ ! -z "$GAME_SERVER" ]
then
IP=$GAME_SERVER
checkip2
if [ "$GAME_SERVER" = "$LAN_IP" ]
then
DEDICATED=true
else
DEDICATED=false
fi
fi
}
checkhost()
{
if [ ! -z "$ALLOWED_HOST" ] && [ ! -z "$DISALLOWED_HOST" ]
then
echo "allow-selected-host and disallow-selected-host can't be used at the same time"
exit 1
fi
}
checkmode()
{
if [ -z "$MAJOR_MODE" ]
then
MAJOR_MODE=$CHECK
else
echo "only one major mode at once"
exit 1
fi
}
default()
{
MAJOR_MODE=
DEDICATED=disable
if [ -x /sbin/iptables ]
then
IPTABLES=/sbin/iptables
elif [ -x /usr/sbin/iptables ]
then
IPTABLES=/usr/sbin/iptables
elif [ -x /usr/local/sbin/iptables ]
then
IPTABLES=/usr/local/sbin/iptables
else
echo "you have to install iptables!" ; exit 1 ;
fi
if [ -x /sbin/ifconfig ]
then
IFCONFIG=/sbin/ifconfig
elif [ -x /usr/sbin/ifconfig ]
then
IFCONFIG=/usr/sbin/ifconfig
elif [ -x /usr/local/sbin/ifconfig ]
then
IFCONFIG=/usr/local/sbin/ifconfig
else
echo "you have to install ifconfig!" ; exit 1 ;
fi
NET_IP=` $IFCONFIG $NET | grep "inet ad" | cut -f2 -d":" | cut -f1 -d" "`
LAN_IP=` $IFCONFIG $LAN | grep "inet ad" | cut -f2 -d":" | cut -f1 -d" "`
}
default
for ac_option
do
case "$ac_option" in
--*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'`;;
*) ac_optarg= ;;
esac
case "$ac_option" in
-h | --help) help; exit 0;;
#MAJOR
e | enable-protection) CHECK=e; checkmode; shift 1;;
d | disable-protection) CHECK=d; checkmode; shift 1;;
s | status) CHECK=s; checkmode; shift 1;;
#FEATURES
--enable-local-protection) LOCAL_PROTECTION=enable; shift 1;;
--enable-lan-protection) LAN_PROTECTION=enable; shift 1;;
--enable-masquerading) MASQUERADING=enable; shift 1;;
--disable-local-protection) LOCAL_PROTECTION=disable; shift 1;;
--disable-lan-protection) LAN_PROTECTION=disable; shift 1;;
--disable-masquerading) MASQUERADING=disable; shift 1;;
#OPTIONS
--enable-status) STATUS=enable; shift 1;;
--enable-syslog) LOG=enable; shift 1;;
--enable-ulogd) ULOG=enable; shift 1;;
--disable-status) STATUS=disable; shift 1;;
--disable-syslog) LOG=disable; shift 1;;
--disable-ulogd) ULOG=disable; shift 1;;
#ADVANCED
--allow-host=*) ALLOWED_HOST="$ac_optarg"; shift 1;;
--disallow-host=*) DISALLOWED_HOST="$ac_optarg"; shift 1;;
--with-game-server=*) GAME_SERVER="$ac_optarg"; shift 1;;
*) echo "invalid option: $ac_option"; exit 1;;
esac
done
checkhost
checkip
launchmode
exit 0
|
et le fichier de config :
Code: |
#!/bin/bash
# Philippe DUMONT
# 13 jully 2003
# Firewall for lan bridge configuration file
###########################################################
# INTERFACE
# Lan interface
LAN=eth0
# Net interface
NET=ppp0
# Localhost interface
LO=lo
###########################################################
# OPTIONS
# Show the status of the table nat and filter at the end
STATUS=enable
# Use syslog system
LOG=enable
# Use ulogd system
ULOG=disable
###########################################################
# ADVANCED OPTIONS
#
# Set the port accepted in input by localhost on ppp0
# if localprotection is enable
INPUT_TCP_PORT_ACCEPTED="http https ssh"
INPUT_UDP_PORT_ACCEPTED=""
# Set the port watched in input by localhost
# if localprotection is enable
# (watched means accepted but logged)
INPUT_TCP_PORT_WATCHED=""
INPUT_UDP_PORT_WATCHED=""
# Set the port notified in input by localhost
# if localprotection is enable
# (notified means logged and dropped)
INPUT_TCP_PORT_NOTIFIED="telnet smtp netbios-ssn"
INPUT_UDP_PORT_NOTIFIED=""
# Others packets are simply rejected
#
# Set the port forward by localhost
# if lanprotection is enable
FORWARD_LAN_NET_TCP_PORT_ACCEPTED="domain http https ssh ftp imap imaps nntp"
FORWARD_LAN_NET_UDP_PORT_ACCEPTED="domain"
FORWARD_NET_LAN_TCP_PORT_ACCEPTED=""
FORWARD_NET_LAN_UDP_PORT_ACCEPTED=""
# Set the port watched in input by localhost
# if lanprotection is enable
# (watched means accepted but logged)
FORWARD_LAN_NET_TCP_PORT_WATCHED=""
FORWARD_LAN_NET_UDP_PORT_WATCHED=""
FORWARD_NET_LAN_TCP_PORT_WATCHED=""
FORWARD_NET_LAN_UDP_PORT_WATCHED=""
# Others packets are notified by default
#
# List of ip which will be unreachable
# This option can't be use with ALLOWED_HOST
DISALLOWED_HOST=
# This option disallow all internet
# but the machine in this list
ALLOWED_HOST=
# IP of the lan game server (ip should be 192.168.x.y)
GAME_SERVER=
# Set the ports of the game servers (used by GAME-SERVER option)
# NB: it can be used to make DNAT
GAMES_PORTS="27960 27950"
echo "You have to configure the script and to comment this line !"; exit 1;
|
|
|
Back to top |
|
 |
yuk159 Veteran


Joined: 18 Apr 2003 Posts: 1803 Location: noumea ,nouvelle-caledonie
|
Posted: Mon Sep 15, 2003 9:01 pm Post subject: |
|
|
mort de rire si chacun post son "petit" firewall gentoo va devoir chercher d'autre serveurs pour stocker ces forums  _________________ The box said: "Requires Windows 98/2000/XP/NT, or better."
So, I installed LINUX!
Instagram |
|
Back to top |
|
 |
Marsu Guru


Joined: 18 Jun 2003 Posts: 329 Location: Lyon
|
Posted: Tue Sep 16, 2003 8:03 pm Post subject: |
|
|
en fait, mon problème ça doit être un truc de dns, vu que j'arrive à pinger les adresses IP du oueb, mais je n'arrive à faire rien d'autre, pas de telechargement etc...
PS : je fais comment pour qu'il me résolve les dns, j'ai les dns de mon FAI, mais je sais pas comment spécifier à l'ordi secondaire de les trouver _________________ qui ne tente rien n'a rien |
|
Back to top |
|
 |
yuk159 Veteran


Joined: 18 Apr 2003 Posts: 1803 Location: noumea ,nouvelle-caledonie
|
Posted: Tue Sep 16, 2003 8:12 pm Post subject: |
|
|
Sur la passerelle ou du client ? _________________ The box said: "Requires Windows 98/2000/XP/NT, or better."
So, I installed LINUX!
Instagram |
|
Back to top |
|
 |
Diorf n00b

Joined: 05 Jun 2003 Posts: 52 Location: Paris
|
Posted: Tue Sep 16, 2003 8:20 pm Post subject: |
|
|
je pense que c'est sur le client que tu veux les installer (a moins que tu fasse tourner un serveur DNS sur ta passerelle).
Si ta machine secondaire est sous linux il te suffit juste d'ajouter quelques lignes a ton fichier /etc/resolv.conf
Code: | nameserver xxx.xxx.xxx.xxx
nameserver yyy.yyy.yyy.yyy |
en remplacant bien evidemment les xxx et yyy par les ips des DNS et si tu en a plus de deux il te suffit juste de rajouter des lignes a la suite.
sinon si ta machine secondaire est un w*nd*ws il te suffit juste de les spécifier dans les propriétes TCP/IP de ta connection (ca doit etre dans les paramètres avancés)
Sinon si ta machine secondaire est sous autre chose normalement tu dois savoir le faire
Et hop normalement problème résolu  |
|
Back to top |
|
 |
Marsu Guru


Joined: 18 Jun 2003 Posts: 329 Location: Lyon
|
Posted: Tue Sep 16, 2003 9:04 pm Post subject: |
|
|
exact, problème résolu, merci à tous, pour l'instant, j'ai que essayé le premier script, j'ai essayé le deuxième mais il ne marchait pas dès le départ alors j'étais trop paresseux pour l'adapter _________________ qui ne tente rien n'a rien |
|
Back to top |
|
 |
Doudou Apprentice


Joined: 10 Jan 2003 Posts: 286 Location: Paris, France
|
Posted: Wed Sep 17, 2003 7:12 am Post subject: |
|
|
Bien content que ca marche , peux tu juste changer le sujet du topic et rajouer (résolu) a la fin.
Doudou. |
|
Back to top |
|
 |
Marsu Guru


Joined: 18 Jun 2003 Posts: 329 Location: Lyon
|
Posted: Wed Sep 17, 2003 2:50 pm Post subject: |
|
|
j'ai fermé la fenêtre avant de le faire hier et j'ai été trop paresseux pour la rouvrir shame on me! j'aurais du le faire dès le départ _________________ qui ne tente rien n'a rien |
|
Back to top |
|
 |
yuk159 Veteran


Joined: 18 Apr 2003 Posts: 1803 Location: noumea ,nouvelle-caledonie
|
Posted: Wed Sep 17, 2003 3:00 pm Post subject: |
|
|
Bo du moment que c'est fait
Merci de jouer le jeu  _________________ The box said: "Requires Windows 98/2000/XP/NT, or better."
So, I installed LINUX!
Instagram |
|
Back to top |
|
 |
|