Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1318 connectés 

 


Dernière réponse
Sujet : ip masquerading (kernel 2.4)
HNO3

Kyser a écrit a écrit :

Okay ca y est ca marche!
En fait, dans le -o du masquerade, fallait mettre ppp0 et non eth0 (bien que g un modem ethernet)
 
Merci a tous! :hap:  




 
C'est complétement logique, car ta carte ne te sert que de lien physique. La couche TCP/IP ne sait meme pas que ton modem est relié via eth1.
Pour preuve, tu peux ne pas assigner d'adresse IP à eth1, cela fonctionnera aussi bien (en pppoe, pas en pptp).


Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
HNO3

Kyser a écrit a écrit :

Okay ca y est ca marche!
En fait, dans le -o du masquerade, fallait mettre ppp0 et non eth0 (bien que g un modem ethernet)
 
Merci a tous! :hap:  




 
C'est complétement logique, car ta carte ne te sert que de lien physique. La couche TCP/IP ne sait meme pas que ton modem est relié via eth1.
Pour preuve, tu peux ne pas assigner d'adresse IP à eth1, cela fonctionnera aussi bien (en pppoe, pas en pptp).

246tNt Evite de mettre le -P avant le -F ... vus que le -F fait un flush y compris de la policy
Kyser

Zzozo a écrit a écrit :

 
Euh  ... ton fw est grand ouvert là ... aie aie aie ...  :non:  




 
avec $IPTABLES -A FORWARD -i eth0 -s 192.168.0.0/2 -j ACCEPT
c'est mieux ?

Zzozo

Kyser a écrit a écrit :

 
 
je ne sais pas, j'ai fait tout simplement :
 
 

Code :
  1. echo "1" > /proc/sys/net/ipv4/ip_forward
  2. echo "1" > /proc/sys/net/ipv4/ip_dynaddr
  3. $IPTABLES -P INPUT ACCEPT
  4. $IPTABLES -F INPUT
  5. $IPTABLES -P OUTPUT ACCEPT
  6. $IPTABLES -F OUTPUT
  7. $IPTABLES -P FORWARD DROP
  8. $IPTABLES -F FORWARD
  9. $IPTABLES -t nat -F
  10. $IPTABLES -A FORWARD -s 192.168.0.0/2 -j ACCEPT
  11. $IPTABLES -A FORWARD -d 192.168.0.0/2 -j ACCEPT
  12. $IPTABLES -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

 
 
et ca marche tres bien  :)  
 




Euh  ... ton fw est grand ouvert là ... aie aie aie ...  :non:

Kyser

Zzozo a écrit a écrit :

 
Bon bah j'aurais appris un truc là ... même si j'ai un speedtouch USB ca me servira pour plus tard ;)
Le reste du script marche alors ?




 
je ne sais pas, j'ai fait tout simplement :
 
 

Code :
  1. echo "1" > /proc/sys/net/ipv4/ip_forward
  2. echo "1" > /proc/sys/net/ipv4/ip_dynaddr
  3. $IPTABLES -P INPUT ACCEPT
  4. $IPTABLES -F INPUT
  5. $IPTABLES -P OUTPUT ACCEPT
  6. $IPTABLES -F OUTPUT
  7. $IPTABLES -P FORWARD DROP
  8. $IPTABLES -F FORWARD
  9. $IPTABLES -t nat -F
  10. $IPTABLES -A FORWARD -s 192.168.0.0/2 -j ACCEPT
  11. $IPTABLES -A FORWARD -d 192.168.0.0/2 -j ACCEPT
  12. $IPTABLES -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

 
 
et ca marche tres bien  :)  

246tNt ... Ben oui ... comme je l'avais dit ...  :sarcastic:
Zzozo

Kyser a écrit a écrit :

Okay ca y est ca marche!
En fait, dans le -o du masquerade, fallait mettre ppp0 et non eth0 (bien que g un modem ethernet)
 
Merci a tous! :hap:  




Bon bah j'aurais appris un truc là ... même si j'ai un speedtouch USB ca me servira pour plus tard ;)
Le reste du script marche alors ?

Kyser Okay ca y est ca marche!
En fait, dans le -o du masquerade, fallait mettre ppp0 et non eth0 (bien que g un modem ethernet)
 
Merci a tous! :hap:
Kyser Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
ANice-101-1-1-1 *               255.255.255.255 UH    0      0        0 ppp0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
10.0.0.0        *               255.0.0.0       U     0      0        0 eth1
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
default         ANice-101-1-1-1 0.0.0.0         UG    0      0        0 ppp0
 
le fichier /etc/network/interfaces n'existe pas...
djoh

Kyser a écrit a écrit :

 
 
Ouais c'est bien ca mon LAN...
Bon ca marche tjs pas la  :pt1cable:  
 
si je lance ton script, je n'ai plus acces a internet... je met donc INPUT et OUTPUT en ACCEPT, la ca marche... mais le forward marche tjs pas !!!
 
voila l'iptable :
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW
 
Chain FORWARD (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  192.168.0.0/24       anywhere           state NEW
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW
 
en fait le firewall je m'en tape pour l'instant, on peut pas faire du masquerading tres tres simplement ?
 




 
cf mon script plus haut
 
si il marche pas, fait voir tes route :
 

$> route && cat /etc/network/interfaces

246tNt


iptables -F
iptables -F -t nat
iptables -F -t mangle
 
iptables -P FORWARD DENY
iptables -A FORWARD -s 192.168.0.0/16 -j ACCEPT
iptables -A FORWARD -d 192.168.0.0/16 -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE
 
echo "1" > /proc/sys/net/ipv4/ip_forward

Kyser

Zzozo a écrit a écrit :

 
Je suppose que ton lan est un réseau IP qui a cette tête là : 192.168.0.0 / 255.255.255.0 (cé le Netmask)
Cé bien ca j'espère, passke j'avais pris cette hypothèse en te donnant le script ...




 
Ouais c'est bien ca mon LAN...
Bon ca marche tjs pas la  :pt1cable:  
 
si je lance ton script, je n'ai plus acces a internet... je met donc INPUT et OUTPUT en ACCEPT, la ca marche... mais le forward marche tjs pas !!!
 
voila l'iptable :
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW
 
Chain FORWARD (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  192.168.0.0/24       anywhere           state NEW
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW
 
en fait le firewall je m'en tape pour l'instant, on peut pas faire du masquerading tres tres simplement ?

Kyser Merci pr les conseils!
jvais me coucher, on revoit tout ça demain  :D  
Zzozo

Kyser a écrit a écrit :

Bonjour a tous,
 
Je n'arrive pas a faire fonctionner le routage sur ma becane...
J'ai une redhat linux 7.3, deux cartes reseau :
eth0 192.168.0.1 -> VERS LAN
eth1 10.0.0.42 -> VERS MODEM ADSL (pptp)
 
J'ai retente 15 fois avec le HOWTO sur l'ip masquerading, mais rien a faire, les autres machines n'arrivent pas a acceder a internet...
 
Please help!
Merci d'avance...




Je suppose que ton lan est un réseau IP qui a cette tête là : 192.168.0.0 / 255.255.255.0 (cé le Netmask)
Cé bien ca j'espère, passke j'avais pris cette hypothèse en te donnant le script ...

Zzozo

Kyser a écrit a écrit :

je crois qu'il y a des pb dans ton script :  
 
root@StarLight goinfre # -> iptables -t OUTPUT -o lo -m state --state NEW -j ACCEPT
iptables v1.2.5: no command specified
 
j'ai essaye avec iptables -A OUTPUT ...  
j'ai bien rajouter 1 dans ip_forward, mais ca marche tjs pas  :cry:  
 
helpppppppp




Oups .... relisez moi qd j'ai pas dormi (j'avais pas prévenu, moi ?? :o ... [:ddr555]) .... vi vi cété bien un -A et pas un -t ... désolé ...  :ange:  :ange:

Gaellick Il est plus la j'crois :D
246tNt met juste celle de forward en drop ...
 
Les autre, ne met aucune rule et laisse accept, c bon.
Gaellick Fait voir ton scrip complet stp.
Kyser Quand je met les policy en DROP, je n'ai plus acces a internet  :pt1cable:  
 
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW
 
Chain FORWARD (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  192.168.0.0/24       anywhere           state NEW
 
Chain OUTPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW  
 
il doit surement manquer une regle ??  :??:
Kyser Faudrait savoir les enfants, bon je teste avec l'un puis l'autre  :D
Gaellick

246tNt a écrit a écrit :

Dans la regle masquerade ce serait pas plutot -o ppp0 ? si c'est de l'adsl ?




 
Exact.

djoh

246tNt a écrit a écrit :

Dans la regle masquerade ce serait pas plutot -o ppp0 ? si c'est de l'adsl ?




 
ben pas s'il a un modem ethernet
d'ailleurs je me suis trompé dans ma regle : c'est eth1 apparemment, ton interface internet et non eth0

246tNt Dans la regle masquerade ce serait pas plutot -o ppp0 ? si c'est de l'adsl ?
djoh

Kyser a écrit a écrit :

et voila la iptable apres le script :
 
root@StarLight root # -> iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW
 
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  192.168.0.0/24       anywhere           state NEW
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW
 




 
lol  :lol:  
tes policy sont a accept et t'as aucune rules à drop donc tes rules a accept sont redondantes  ;)

djoh

# On vide la table
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
 
# On masque l'ip des paquets sortant sur eth0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
 
# On active enfin le forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

Kyser et voila la iptable apres le script :
 
root@StarLight root # -> iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW
 
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  192.168.0.0/24       anywhere           state NEW
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           state NEW
ACCEPT     all  --  anywhere             anywhere           state NEW
Kyser root@StarLight root # -> lsmod
Module                  Size  Used by    Tainted: P
ipt_MASQUERADE          2464   3  (autoclean)
iptable_nat            20980   1  (autoclean) [ipt_MASQUERADE]
ipt_state               1536   8  (autoclean)
ip_conntrack           21132   2  (autoclean) [ipt_MASQUERADE iptable_nat ipt_state]
iptable_filter          2752   1  (autoclean)
ip_tables              13952   6  [ipt_MASQUERADE iptable_nat ipt_state iptable_filter]
ppp_deflate             4000   0  (autoclean)
zlib_deflate           21344   0  (autoclean) [ppp_deflate]
ppp_async               8256   1  (autoclean)
ppp_generic            24140   3  (autoclean) [ppp_deflate ppp_async]
slhc                    6508   0  (autoclean) [ppp_generic]
via82cxxx_audio        20480   1  (autoclean)
ymfpci                 44196   2  (autoclean)
ac97_codec             11936   0  (autoclean) [via82cxxx_audio ymfpci]
uart401                 7936   0  (autoclean) [via82cxxx_audio ymfpci]
sound                  71916   0  (autoclean) [via82cxxx_audio uart401]
soundcore               6692   6  (autoclean) [via82cxxx_audio ymfpci sound]
tuner                  10436   1  (autoclean)
tvaudio                13632   0  (autoclean) (unused)
bttv                   70560   0  (autoclean)
videodev                6624   2  (autoclean) [bttv]
i2c-algo-bit            8300   1  (autoclean) [bttv]
i2c-core               18720   0  (autoclean) [tuner tvaudio bttv i2c-algo-bit]
agpgart                39456   3  (autoclean)
NVdriver             1022304  10  (autoclean)
ne2k-pci                6720   1
8390                    8180   0  [ne2k-pci]
8139too                16480   1
mii                     2408   0  [8139too]
ide-scsi                9664   0
scsi_mod              108608   1  [ide-scsi]
ide-cd                 30272   0
cdrom                  32224   0  [ide-cd]
nls_iso8859-1           3488   3  (autoclean)
nls_cp437               5120   3  (autoclean)
vfat                   12092   3  (autoclean)
fat                    37432   0  (autoclean) [vfat]
printer                 8352   0  (unused)
mousedev                5312   1
hid                    21344   0  (unused)
input                   5984   0  [mousedev hid]
usb-uhci               24452   0  (unused)
usbcore                73216   1  [printer hid usb-uhci]
ext3                   67136   4
jbd                    49400   4  [ext3]
djoh

Kyser a écrit a écrit :

je crois qu'il y a des pb dans ton script :  
 
root@StarLight goinfre # -> iptables -t OUTPUT -o lo -m state --state NEW -j ACCEPT
iptables v1.2.5: no command specified
 
j'ai essaye avec iptables -A OUTPUT ...  
j'ai bien rajouter 1 dans ip_forward, mais ca marche tjs pas  :cry:  
 
helpppppppp




 
 
lsmod

Kyser je crois qu'il y a des pb dans ton script :  
 
root@StarLight goinfre # -> iptables -t OUTPUT -o lo -m state --state NEW -j ACCEPT
iptables v1.2.5: no command specified
 
j'ai essaye avec iptables -A OUTPUT ...  
j'ai bien rajouter 1 dans ip_forward, mais ca marche tjs pas  :cry:  
 
helpppppppp
Kyser merci, je vais essayer!
 
le HOWTO sur l'ip masquerading propose un script dans le genre, mais ça ne fonctionne pas!
 
je vous tiens au courant..
Zzozo

djoh a écrit a écrit :

 
 
faut pas oublier ça :
 

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






Exact ... mais je dors à moitié là ...  
faut relire mes posts attentivement ... :D
 :jap:

djoh

Kyser a écrit a écrit :

Bonjour a tous,
 
Je n'arrive pas a faire fonctionner le routage sur ma becane...
J'ai une redhat linux 7.3, deux cartes reseau :
eth0 192.168.0.1 -> VERS LAN
eth1 10.0.0.42 -> VERS MODEM ADSL (pptp)
 
J'ai retente 15 fois avec le HOWTO sur l'ip masquerading, mais rien a faire, les autres machines n'arrivent pas a acceder a internet...
 
Please help!
Merci d'avance...




 
faut pas oublier ça :
 

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

Zzozo

Kyser a écrit a écrit :

Bonjour a tous,
 
Je n'arrive pas a faire fonctionner le routage sur ma becane...
J'ai une redhat linux 7.3, deux cartes reseau :
eth0 192.168.0.1 -> VERS LAN
eth1 10.0.0.42 -> VERS MODEM ADSL (pptp)
 
J'ai retente 15 fois avec le HOWTO sur l'ip masquerading, mais rien a faire, les autres machines n'arrivent pas a acceder a internet...
 
Please help!
Merci d'avance...




Essaies ca comme script :
 

Code :
  1. #!/bin/sh
  2. MODULE_DIR="/lib/modules/`uname -r`/kernel/net/ipv4/netfilter/"
  3. MODULES="ipt_conntrack ipt_conntrack_ftp ipt_nat_ftp ipt_conntrack_irc ipt_nat_irc"
  4. for module in $(echo $MODULES); do
  5.   if [ -e "${MODULE_DIR}/${module}.o" -o -e "${MODULE_DIR}/${module}.o.gz" ]; then
  6.     modprobe -k ${module} ||  exit 1
  7.   fi
  8. done
  9. FWD=`cat /proc/sys/net/ipv4/ip_forward`
  10. echo "0" > /proc/sys/net/ipv4/ip_forward
  11. iptables -P OUTPUT  DROP
  12. iptables -P INPUT   DROP
  13. iptables -P FORWARD DROP
  14. cat /proc/net/ip_tables_names | while read table; do
  15.   iptables -t $table -L -n | while read c chain rest; do
  16.       if test "X$c" = "XChain" ; then
  17.         iptables -t $table -F $chain
  18.       fi
  19.   done
  20.   iptables -t $table -X
  21. done
  22. iptables -A INPUT   -m state --state ESTABLISHED,RELATED -j ACCEPT
  23. iptables -A OUTPUT  -m state --state ESTABLISHED,RELATED -j ACCEPT
  24. iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
  25. iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
  26. iptables -t OUTPUT -o lo -m state --state NEW -j ACCEPT
  27. iptables -t OUTPUT -o eth0 -m state --state NEW -j ACCEPT
  28. iptables -t INPUT -i lo -m state --state NEW -j ACCEPT
  29. iptables -t INPUT -i eth0 -m state --state NEW -j ACCEPT
  30. iptables -t FORWARD -i eth0 -s 192.168.0.0/24 -m state --state NEW -j ACCEPT
  31. echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter
  32. echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts


 
Par contre ca ne te protégera qu'un minimum des intrusions extérieures ...

Kyser Bonjour a tous,
 
Je n'arrive pas a faire fonctionner le routage sur ma becane...
J'ai une redhat linux 7.3, deux cartes reseau :
eth0 192.168.0.1 -> VERS LAN
eth1 10.0.0.42 -> VERS MODEM ADSL (pptp)
 
J'ai retente 15 fois avec le HOWTO sur l'ip masquerading, mais rien a faire, les autres machines n'arrivent pas a acceder a internet...
 
Please help!
Merci d'avance...

Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR