[IPTables] Telnet naar buiten werkt niet

Pagina: 1
Acties:

  • urk_forever
  • Registratie: Juni 2001
  • Laatst online: 18-02 16:15
Hi, ik heb een Slackware 9.1 met iptables als firewall. En ik probeer toe te staan dat clients naar buiten toe kunnen telnetten naar een server. Dus ik heb het volgende in mijn script gezet:

$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 23 -j ACCEPT

Alleen dit werkt niet, en als ik de policy van FORWARD op ACCEPT zet dan werkt het wel :? Dus ik snap niet helemaal waar het probleem zit.

Ik heb even wat gelogd:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Feb  5 17:23:50 mail-gateway kernel: Telnet: ?IN=eth1 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=62246 DF PROTO=TCP SPT=1055 DPT=23 WINDOW=8192 RES=0x00 SYN URGP=0 
Feb  5 17:23:53 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=28968 DF PROTO=TCP SPT=1055 DPT=23 WINDOW=8192 RES=0x00 SYN URGP=0 
Feb  5 17:23:59 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=29224 DF PROTO=TCP SPT=1055 DPT=23 WINDOW=8192 RES=0x00 SYN URGP=0 
Feb  5 17:24:11 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=29480 DF PROTO=TCP SPT=1055 DPT=23 WINDOW=8192 RES=0x00 SYN URGP=0 

Policy Accept

Feb  5 17:30:12 mail-gateway kernel: Telnet: ?IN=eth1 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=58667 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8192 RES=0x00 SYN URGP=0 
Feb  5 17:30:13 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=40 TOS=0x00 PREC=0x00 TTL=127 ID=4908 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8974 RES=0x00 ACK URGP=0 
Feb  5 17:30:13 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=43 TOS=0x00 PREC=0x00 TTL=127 ID=5164 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8962 RES=0x00 ACK PSH URGP=0 
Feb  5 17:30:13 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=49 TOS=0x00 PREC=0x00 TTL=127 ID=5932 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8962 RES=0x00 ACK PSH URGP=0 
Feb  5 17:30:13 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=51 TOS=0x00 PREC=0x00 TTL=127 ID=8236 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8956 RES=0x00 ACK PSH URGP=0 
Feb  5 17:30:13 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=43 TOS=0x00 PREC=0x00 TTL=127 ID=10284 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8941 RES=0x00 ACK PSH URGP=0 
Feb  5 17:30:13 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=52 TOS=0x00 PREC=0x00 TTL=127 ID=15660 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8941 RES=0x00 ACK PSH URGP=0 
Feb  5 17:30:13 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=43 TOS=0x00 PREC=0x00 TTL=127 ID=18988 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8854 RES=0x00 ACK PSH URGP=0 
Feb  5 17:30:13 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=43 TOS=0x00 PREC=0x00 TTL=127 ID=19756 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8835 RES=0x00 ACK PSH URGP=0 
Feb  5 17:30:21 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=40 TOS=0x00 PREC=0x00 TTL=127 ID=12080 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8835 RES=0x00 ACK FIN URGP=0 
Feb  5 17:30:21 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=40 TOS=0x00 PREC=0x00 TTL=127 ID=14640 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8835 RES=0x00 ACK URGP=0 
Feb  5 17:30:21 mail-gateway kernel: Telnet: ?IN=eth0 OUT=eth1 SRC=192.168.0.219 DST=213.10.126.79 LEN=40 TOS=0x00 PREC=0x00 TTL=127 ID=14896 DF PROTO=TCP SPT=1056 DPT=23 WINDOW=8835 RES=0x00 ACK URGP=0


Hier ff het complete script:

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#Iptables script gemaakt door P. de Bruine
#
#!/bin/bash

#Eerst alles leegmaken!
/etc/rc.d/rc.flush-iptables

#Ip_forward aanzetten aangezien dit standaard uit staat.
echo "1" > /proc/sys/net/ipv4/ip_forward

###############################################################################
#Configuratie van de interfaces.

#Loopback lo
LO_IFACE="lo"
LO_IP="127.0.0.1/32"

#Lokaal netwerk eth0
LAN_IFACE="eth0"
LAN_IP=`ifconfig $LAN_IFACE | grep inet | cut -d : -f 2 | cut -d \  -f 1`
LAN_MASK=`ifconfig $LAN_IFACE | grep Mask | cut -d : -f 4`
LAN_NET="$LAN_IP/$LAN_MASK"

#Internet Interface eth1
INET_IFACE="eth1"
INET_IP=`ifconfig $INET_IFACE | grep inet | cut -d : -f 2 | cut -d \  -f 1`
INET_MASK=`ifconfig $INET_IFACE | grep Mask | cut -d : -f 4`
INET_NET="$INET_IP/$INET_MASK"

#echo "IPTABLES script!"
#echo "Internal: $LAN_NET"
#echo "External: $INET_NET"

#Locatie iptables
IPTABLES="/usr/local/sbin/iptables"

###############################################################################
#Default Policies instellen.
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP

#IP-forwarding en NAT aanzetten
$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_IP

#IP's blokkeren
#$IPTABLES -A FORWARD -s 192.168.0.150 -d 0.0.0.0/0 -j REJECT
#$IPTABLES -A FORWARD -s 192.168.0.156 -d 0.0.0.0/0 -j REJECT
#$IPTABLES -A FORWARD -s 192.168.0.157 -d 0.0.0.0/0 -j REJECT

#Transparante proxy voor poort 80
#$IPTABLES -t nat -A PREROUTING -i $LAN_IFACE -p tcp --destination-port 80 -j REDIRECT --to-port 3128

#Alles toestaan op de loopback interface
$IPTABLES -A INPUT -i $LO_IFACE -j ACCEPT
$IPTABLES -A OUTPUT -o $LO_IFACE -j ACCEPT

#Alles toestaan op interne netwerk
$IPTABLES -A INPUT -i $LAN_IFACE -j ACCEPT
$IPTABLES -A OUTPUT -o $LAN_IFACE -j ACCEPT

#Regels voor het ICMP protocol
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p icmp --icmp-type 0 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p icmp --icmp-type 3 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p icmp --icmp-type 5 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p icmp --icmp-type 8 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p icmp --icmp-type 11 -j ACCEPT

#Regels voor het UDP protocol
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p udp --destination-port 53 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p udp --destination-port 1024:65535 -j ACCEPT

#Regels voor het TCP protocol
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 20 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 21 -j ACCEPT
$IPTABLES -A FORWARD -p tcp --destination-port 23 -j LOG --log-prefix "Telnet: ?" --log-level info
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --source-port 23 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 23 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 25 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 80 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 110 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 443 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 1024:65535 -j ACCEPT

#Toegang tot mailserver maken
# SMTP Mailmonitor
$IPTABLES -A INPUT -i $INET_IFACE -p tcp --destination-port 25 -j ACCEPT
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --source-port 25 -j ACCEPT
# POP3
# $IPTABLES -A INPUT -i $INET_IFACE -p tcp --destination-port 110 -j ACCEPT
# $IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --source-port 110 -j ACCEPT
# Apache webserver
$IPTABLES -A INPUT -i $INET_IFACE -p tcp --destination-port 9090 -j ACCEPT
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --source-port 9090 -j ACCEPT
# Proftpd FTP Server
$IPTABLES -A INPUT -i $INET_IFACE -p tcp --destination-port 20 -j ACCEPT
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --destination-port 20 -j ACCEPT
$IPTABLES -A INPUT -i $INET_IFACE -p tcp --destination-port 21 -j ACCEPT
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --destination-port 21 -j ACCEPT 

# Rules voor de Linux machine zelf naar Internet
# ICMP
$IPTABLES -A OUTPUT -o $INET_IFACE -p icmp --icmp-type 8 -j ACCEPT
#UDP
$IPTABLES -A OUTPUT -o $INET_IFACE -p udp --destination-port 53 -j ACCEPT
# TCP
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --destination-port 20 -j ACCEPT
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --destination-port 21 -j ACCEPT
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --destination-port 25 -j ACCEPT
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --destination-port 80 -j ACCEPT
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --destination-port 1024:65535 -j ACCEPT

# Bestaande en gerelateerde verbindingen toestaan
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT


heb al wel gezocht maar geen echt antwoord gevonden, misschien dat jullie me kunnen helpen?

Hail to the king baby!


  • Obliterator
  • Registratie: November 2000
  • Laatst online: 18-02 16:34
In plaats van zomaar wat loggen kun je ook elke tabel aan het einde loggen, zodat je kunt zien in welke tabel het pakket niet geaccept word.

[ Voor 12% gewijzigd door Obliterator op 05-02-2004 16:26 ]


  • Lancer
  • Registratie: Januari 2002
  • Laatst online: 21-02 19:48

Lancer

What the......

Er moet een regel zijn voor heengaand en terugkomend verkeer. Als je nu kijkt naar:

$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --source-port 23 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 23 -j ACCEPT

Dan zul je toch bij 1 de -i en -o flags moeten omdraaien.

[note]
Ik heb een gevoel dat iemand straks |:( gaat doen
[/note]

edit:

Ik gebruik zelf webmin (http://www.webmin.com) en de Turtefirewall (http://www.turtlefirewall.com). Werkt heel makkelijk.

[ Voor 17% gewijzigd door Lancer op 05-02-2004 16:33 ]

Je kunt niet in een systeem meten zonder het systeem te beinvloeden.... (gevolg van de Heisenberg onzekerheidsrelatie)


  • urk_forever
  • Registratie: Juni 2001
  • Laatst online: 18-02 16:15
Maakt niet uit, als ik alleen de --destination-port erin zet werkt het ook niet.

Hail to the king baby!


  • Lancer
  • Registratie: Januari 2002
  • Laatst online: 21-02 19:48

Lancer

What the......

urk_forever schreef op 05 februari 2004 @ 16:35:
Maakt niet uit, als ik alleen de --destination-port erin zet werkt het ook niet.
Heb je dit

$IPTABLES -A FORWARD -o $LAN_IFACE -i $INET_IFACE -p tcp --source-port 23 -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -p tcp --destination-port 23 -j ACCEPT

al geprobeerd?

Je kunt niet in een systeem meten zonder het systeem te beinvloeden.... (gevolg van de Heisenberg onzekerheidsrelatie)


  • urk_forever
  • Registratie: Juni 2001
  • Laatst online: 18-02 16:15
Dat werkt, bedankt!

Hail to the king baby!

Pagina: 1