[BC3] iptables > wat gaat hier fout?

Pagina: 1
Acties:

  • Willem2
  • Registratie: Oktober 2000
  • Laatst online: 19-08 15:22

Willem2

Ω is futile

Topicstarter
ik ben nogal nieuw mbt iptables/chains, dus wie kan mij vertellen wat hier fout gaat?

mijn firewall/router draait op ip 192.168.0.1 (LAN). ik heb er een mailservertje naast staan die op ip 192.168.0.99 zit.
wat ik dus wil is dat als er iets binnenkomt op poort 25/110 van de firewall dat wordt doorgestuurd naar de mailserver.
de terugweg is geen probleem.

anyone?

dit is een stukje uit mijn script (en dat werkt dus niet ;)):
#accept pop (110) & smtp (25)
iptables -A FORWARD -p tcp -s any/0 --sport 25 -d 192.168.0.99 -j ACCEPT
iptables -A FORWARD -p tcp -s any/0 --sport 110 -d 192.168.0.99 -j ACCEPT

en nee, ik houd niet van voetbal... :)


Verwijderd

Hmm ik denk dat het volgende beter zal gaan werken.
Ik heb er wat commentaar bij gezet (welliswaar in het engels, maar daar zal je wel uitkomen ;) )
Verder denk ik dat de HOWTO niet overbodig voor je zal zijn.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# $EXTIF: The interface connected with the outside world.
# $UNIVERSE: The complete outside world (including LAN).
# $MAIL: The (internal) IP of the mailserver.
# $EXTIP: The IP-adres obtained from the DHCP-server of the ISP (Public IP).
EXTIF="eth0"
UNIVERSE="0.0.0.0/0"
MAIL="192.168.0.99"
EXTIP=`ifconfig $EXTIF | awk '/inet addr/ { gsub(".*:", "", $2) ; print $2 }'`
if [ "$EXTIP" = '' ]; then
   echo "Aborting: Unable to determine the IP-addres of $EXTIF ... Probably a DHCP error!"
   exit 1
fi


# Input rules for internal mail-server
# With iptables you don't have to fill in the external IP-adres,
# since iptables knows the destination already because off the PREROUTING chain.
#(in contrary to ipchains where you would have to fill in the external IP as the destination.
iptables -A INPUT -i $EXTIF -p tcp -s $UNIVERSE -d $MAIL --dport 25 -j ACCEPT
iptables -A INPUT -i $EXTIF -p tcp -s $UNIVERSE -d $MAIL --dport 110 -j ACCEPT


# Output rules for internal mail-server
# With iptables you don't have to fill in the external IP-adres,
# since iptables knows the destination already because off the PREROUTING chain.
#(in contrary to ipchains where you would have to fill in the external IP as the source.
iptables -A OUTPUT -o $EXTIF -p tcp -s $MAIL --sport 25 -d $UNIVERSE -j ACCEPT
iptables -A OUTPUT -o $EXTIF -p tcp -s $MAIL --sport 110 -d $UNIVERSE -j ACCEPT


# Portforwarding (Destination Nat in Prerouting Chain)
iptables -A PREROUTING -t nat -p tcp -d $EXTIP --dport 25 -j DNAT --to $MAIL:25
iptables -A PREROUTING -t nat -p tcp -d $EXTIP --dport 110 -j DNAT --to $MAIL:110

Tja dit moet toch wel werken :)

  • Willem2
  • Registratie: Oktober 2000
  • Laatst online: 19-08 15:22

Willem2

Ω is futile

Topicstarter
ok dan! :)
wel ietsje meer dan die lullige twee regels van mij... ;)

helaas moet ik nu weg, maar ik zal het morgen erin gooien, ben benieuwd!

ik heb al wel een paar howto''s bekeken, maar als het je ''eerste keer'' is onder linux valt het een beetje tegen!

iig bedankt!

en nee, ik houd niet van voetbal... :)


Verwijderd

Volgens mij heb je niet de input en output regels nodig, maar alleen de prerouting.
Bij iptables gaat de nat forwarding niet over de input en outputchain heen, wat bij ipchains wel het geval was.

Heeft iemand trouwens een idee wat mangle precies doet, en wanneer dat nuttig is?