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

  FORUM HardWare.fr
  Linux et OS Alternatifs
  réseaux et sécurité

  Un ptit coup de main sur iptables ;-)

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Un ptit coup de main sur iptables ;-)

n°901400
M300A
Sehr hopfen, vielen IBU, wow!
Posté le 08-04-2007 à 18:43:13  profilanswer
 

Bonjour à vous,
 
J'aurais besoin de vos connaissances sur iptables. En effet je me suis monté un openwrt et j'ai pas possibilité d'y faire tourner un shorewall facilement... Du coup... :(
 
Voila le bouzin:

  • WAN, dhcp (eth0.1)
  • LAN, 10.1.0.0/24 (br-lan)
  • WLAN, 10.1.1.0/24 (ath0)


La dessus j'y ai collé un OpenVPN

  • VPN, 10.100.0.0/24 (tun0)


Je souhaiterais tout simplement autoriser l'accès de LAN et WLAN vers un réseau 10.0.0.0/24 situé derrière le VPN.
(PS: tout fonctionne déjà sur la gateway).
 
Merci d'avance! :jap:

mood
Publicité
Posté le 08-04-2007 à 18:43:13  profilanswer
 

n°901446
Taz
bisounours-codeur
Posté le 09-04-2007 à 00:00:18  profilanswer
 

bah sur les deux routeurs il te faut rajouter des routes : ip route add ...
man ip quoi.
 
ìp route add 10.0.0.0/24 broadcast 10.0.0.255 via 10.100.0.x

n°901459
M300A
Sehr hopfen, vielen IBU, wow!
Posté le 09-04-2007 à 02:18:00  profilanswer
 

Non mais c'est pas un problème de route.
Mon server OpenVPN push la route du 10.0.0.0/24 a la seconde gw (client). Depuis cette gateway tout marche bien du coup.
Par contre les clients connectées à cette gw (qui est donc leur route par défaut) n'atteignent pas la 10.0.0.0/24 à cause de l'iptables :/

n°901472
Taz
bisounours-codeur
Posté le 09-04-2007 à 10:06:50  profilanswer
 

bah si tu nous donnes ni les route ni les iptables ...

n°901505
M300A
Sehr hopfen, vielen IBU, wow!
Posté le 09-04-2007 à 12:51:42  profilanswer
 

Code :
  1. root@gw:~# route -n
  2. Kernel IP routing table
  3. Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
  4. 10.100.0.13     0.0.0.0         255.255.255.255 UH    0      0        0 tun0
  5. 10.100.0.1      10.100.0.13     255.255.255.255 UGH   0      0        0 tun0
  6. 10.0.0.0        10.100.0.13     255.255.255.0   UG    0      0        0 tun0
  7. 82.241.96.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0.1
  8. 10.1.0.0        0.0.0.0         255.255.255.0   U     0      0        0 br-lan
  9. 10.1.1.0        0.0.0.0         255.255.255.0   U     0      0        0 ath0
  10. 0.0.0.0         82.241.96.254   0.0.0.0         UG    0      0        0 eth0.1


 
Pour iptables, voici le -L de base, mais tout n'est pas visible. Je sais pas comment tout afficher ;)
 

Code :
  1. root@gw:~# iptables -L
  2. Chain INPUT (policy DROP)
  3. target     prot opt source               destination
  4. DROP       all  --  anywhere             anywhere            state INVALID
  5. ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
  6. DROP       tcp  --  anywhere             anywhere            tcp option=!2 flags:SYN/SYN
  7. input_rule  all  --  anywhere             anywhere
  8. input_wan  all  --  anywhere             anywhere
  9. LAN_ACCEPT  all  --  anywhere             anywhere
  10. WLAN_ACCEPT  all  --  anywhere             anywhere
  11. ACCEPT     icmp --  anywhere             anywhere
  12. ACCEPT     gre  --  anywhere             anywhere
  13. REJECT     tcp  --  anywhere             anywhere            reject-with tcp-reset
  14. REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable
  15. Chain FORWARD (policy DROP)
  16. target     prot opt source               destination
  17. DROP       all  --  anywhere             anywhere            state INVALID
  18. TCPMSS     tcp  --  anywhere             anywhere            tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
  19. ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
  20. forwarding_rule  all  --  anywhere             anywhere
  21. forwarding_wan  all  --  anywhere             anywhere
  22. ACCEPT     all  --  anywhere             anywhere
  23. ACCEPT     all  --  anywhere             anywhere
  24. ACCEPT     all  --  anywhere             anywhere
  25. ACCEPT     all  --  anywhere             anywhere
  26. ACCEPT     all  --  anywhere             anywhere
  27. ACCEPT     all  --  anywhere             anywhere
  28. Chain OUTPUT (policy DROP)
  29. target     prot opt source               destination
  30. DROP       all  --  anywhere             anywhere            state INVALID
  31. ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
  32. output_rule  all  --  anywhere             anywhere
  33. ACCEPT     all  --  anywhere             anywhere
  34. REJECT     tcp  --  anywhere             anywhere            reject-with tcp-reset
  35. REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable
  36. Chain LAN_ACCEPT (1 references)
  37. target     prot opt source               destination
  38. RETURN     all  --  anywhere             anywhere
  39. ACCEPT     all  --  anywhere             anywhere
  40. Chain WLAN_ACCEPT (1 references)
  41. target     prot opt source               destination
  42. RETURN     all  --  anywhere             anywhere
  43. ACCEPT     all  --  anywhere             anywhere
  44. Chain forwarding_rule (1 references)
  45. target     prot opt source               destination
  46. Chain forwarding_wan (1 references)
  47. target     prot opt source               destination
  48. Chain input_rule (1 references)
  49. target     prot opt source               destination
  50. Chain input_wan (1 references)
  51. target     prot opt source               destination
  52. ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:22
  53. Chain output_rule (1 references)
  54. target     prot opt source               destination


 
Evidemment les machines connecté à la gateway ont 10.1.0.1 comme passerelle, donc niveau routage c'est ok !

n°901508
krifur
Posté le 09-04-2007 à 12:58:28  profilanswer
 

iptables -L -v -n est pas mal en principe...

n°901513
M300A
Sehr hopfen, vielen IBU, wow!
Posté le 09-04-2007 à 13:10:51  profilanswer
 

Code :
  1. root@gw:~# iptables -L -v
  2. Chain INPUT (policy DROP 0 packets, 0 bytes)
  3. pkts bytes target     prot opt in     out     source               destination
  4.     7   318 DROP       all  --  any    any     anywhere             anywhere            state INVALID
  5. 13825 1162K ACCEPT     all  --  any    any     anywhere             anywhere            state RELATED,ESTABLISHED
  6.    16   648 DROP       tcp  --  any    any     anywhere             anywhere            tcp option=!2 flags:SYN/SYN
  7. 11666  809K input_rule  all  --  any    any     anywhere             anywhere
  8. 8508  590K input_wan  all  --  eth0.1 any     anywhere             anywhere
  9. 11608  806K LAN_ACCEPT  all  --  any    any     anywhere             anywhere
  10. 8450  587K WLAN_ACCEPT  all  --  any    any     anywhere             anywhere
  11.    81  4953 ACCEPT     icmp --  any    any     anywhere             anywhere
  12.     0     0 ACCEPT     gre  --  any    any     anywhere             anywhere
  13. 8056  448K REJECT     tcp  --  any    any     anywhere             anywhere            reject-with tcp-reset
  14.   313  133K REJECT     all  --  any    any     anywhere             anywhere            reject-with icmp-port-unreachable
  15. Chain FORWARD (policy DROP 353 packets, 22692 bytes)
  16. pkts bytes target     prot opt in     out     source               destination
  17.    92  4784 DROP       all  --  any    any     anywhere             anywhere            state INVALID
  18. 5735  338K TCPMSS     tcp  --  any    any     anywhere             anywhere            tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
  19. 401K  314M ACCEPT     all  --  any    any     anywhere             anywhere            state RELATED,ESTABLISHED
  20. 3280  199K forwarding_rule  all  --  any    any     anywhere             anywhere
  21.     0     0 forwarding_wan  all  --  eth0.1 any     anywhere             anywhere
  22.     0     0 ACCEPT     all  --  br-lan br-lan  anywhere             anywhere
  23.     0     0 ACCEPT     all  --  ath0   ath0    anywhere             anywhere
  24.     0     0 ACCEPT     all  --  ath0   br-lan  anywhere             anywhere
  25.     0     0 ACCEPT     all  --  br-lan ath0    anywhere             anywhere
  26.   494 30662 ACCEPT     all  --  br-lan eth0.1  anywhere             anywhere
  27. 2433  146K ACCEPT     all  --  ath0   eth0.1  anywhere             anywhere
  28. Chain OUTPUT (policy DROP 4 packets, 340 bytes)
  29. pkts bytes target     prot opt in     out     source               destination
  30.     0     0 DROP       all  --  any    any     anywhere             anywhere            state INVALID
  31. 25102 1930K ACCEPT     all  --  any    any     anywhere             anywhere            state RELATED,ESTABLISHED
  32.   366 28692 output_rule  all  --  any    any     anywhere             anywhere
  33.   366 28692 ACCEPT     all  --  any    any     anywhere             anywhere
  34.     0     0 REJECT     tcp  --  any    any     anywhere             anywhere            reject-with tcp-reset
  35.     0     0 REJECT     all  --  any    any     anywhere             anywhere            reject-with icmp-port-unreachable
  36. Chain LAN_ACCEPT (1 references)
  37. pkts bytes target     prot opt in     out     source               destination
  38. 8450  587K RETURN     all  --  eth0.1 any     anywhere             anywhere
  39. 3158  219K ACCEPT     all  --  any    any     anywhere             anywhere
  40. Chain WLAN_ACCEPT (1 references)
  41. pkts bytes target     prot opt in     out     source               destination
  42. 8450  587K RETURN     all  --  eth0.1 any     anywhere             anywhere
  43.     0     0 ACCEPT     all  --  any    any     anywhere             anywhere
  44. Chain forwarding_rule (1 references)
  45. pkts bytes target     prot opt in     out     source               destination
  46. Chain forwarding_wan (1 references)
  47. pkts bytes target     prot opt in     out     source               destination
  48. Chain input_rule (1 references)
  49. pkts bytes target     prot opt in     out     source               destination
  50. Chain input_wan (1 references)
  51. pkts bytes target     prot opt in     out     source               destination
  52.    58  3480 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:22
  53. Chain output_rule (1 references)
  54. pkts bytes target     prot opt in     out     source               destination


 
;)

n°901575
Taz
bisounours-codeur
Posté le 09-04-2007 à 19:51:51  profilanswer
 

si tu vires iptables, ça marche ou pas ou fait ?
 
(Et par pitié les gars, passez à ip, moi j'y comprends plus rien à ifconfig, route, et c'est bêtises d'interface virtuelle).

n°901585
M300A
Sehr hopfen, vielen IBU, wow!
Posté le 09-04-2007 à 20:51:52  profilanswer
 

J'ai pas trop testé sans iptables, mais comme j'accède bien au 10.0.0.0/24 depuis la gateway... ;)
 
J'essayerais de couper iptables mais c'est sur que ca fontionnera!

n°901848
M300A
Sehr hopfen, vielen IBU, wow!
Posté le 10-04-2007 à 15:06:16  profilanswer
 

:bounce:
 
Y'a bien une commande simple qui peut dire, tu autorise le réseau 10.1.0.0/24 et 10.1.1.0/24 à sortir par tun0, non ?

mood
Publicité
Posté le 10-04-2007 à 15:06:16  profilanswer
 

n°901851
l0ky
Posté le 10-04-2007 à 15:20:48  profilanswer
 

oui
d'après betement le man d'iptables:

iptables -filter  -A FORWARD -s 10.1.0.0/24 -o tun0 -j ACCEPT
iptables -filter  -A FORWARD -s 10.1.1.0/24 -o tun0 -j ACCEPT


Et faut pas oublier les paquets dans l'autre sens...


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Linux et OS Alternatifs
  réseaux et sécurité

  Un ptit coup de main sur iptables ;-)

 

Sujets relatifs
comment bloquer une adresse mac avec iptables?filtrage accés internet par proxy et Iptables
[IPTABLES] Pb de forwarding asser complex.[Resolu] acces interface web neufbox via deux reseaux
OpenAguila - un coup de main pour l'installation[Résolu] Partage de connexion ne fonctionne pas
iptables + state RELATED,ESTABLISHEDRedirection vers serveur web avec IPTables
[Linux] partages connexion internet avec iptables 
Plus de sujets relatifs à : Un ptit coup de main sur iptables ;-)


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