Toon posts:

iptables is dit goed

Pagina: 1
Acties:

Verwijderd

Topicstarter
is dit wel goed zo mijn poorten lijken dicht te staan voor de buiten wereld dus niemand kan ftp of iets dergelijks doen naar mijn machine??????



[root@master etc]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp spt:bootpc dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp spt:bootpc dpt:bootps
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc
ACCEPT tcp -- anywhere anywhere tcp spt:bootps dpt:bootpc
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain

Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 192.168.0.0/24 anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination





een newbie

  • a casema user
  • Registratie: Januari 2000
  • Laatst online: 14-08 13:49
volgens mij staat nu alles gewoon open bij jou !

Taaaa taa taa taaaa taa taa ta taaataaaaa.


Verwijderd

Je kunt het beste alles standaard laten droppen.
code:
1
2
3
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

en dan alles doorlaten wat je nodig hebt.

Hier staan een aantal howto's. Altijd verstandig om er een aantal door te nemen.

  • sirdupre
  • Registratie: Maart 2002
  • Laatst online: 27-04-2025
man iptables? zoek een firewall builder?
zijn zat leuke dingetjes te vinden op internet, maar dit laat volgens mij alles door ja (maar ik heb eigenlijk alleen maar met ipchains gewerkt :P).

Verwijderd

Topicstarter
raar maar ik kan niet ssh ftp of telnet via mijn eigen machine doen???????

newbie

  • SJR
  • Registratie: Januari 2000
  • Laatst online: 15-02 13:58

SJR

Dit is mijn iptables config:
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
#!/bin/sh

INET_IF="ppp0"
LAN_IF="eth0"
LAN_IP="192.168.0.254"
LAN="192.168.0.0/24"

IPTABLES="/sbin/iptables"

/etc/init.d/iptables-flush.sh

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

$IPTABLES -t filter -N block
$IPTABLES -t filter -A block -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -t filter -A block -m state --state NEW -i ! $INET_IF -j ACCEPT

########## START portmapping
# www
$IPTABLES -t filter -A block -i $INET_IF -p tcp --dport 80 -j ACCEPT

# ftp
$IPTABLES -t filter -A block -i $INET_IF -p tcp --dport 21 -j ACCEPT

# ssh
$IPTABLES -t filter -A block -i $INET_IF -p tcp --dport 22 -j ACCEPT

# dnet proxy
$IPTABLES -t filter -A block -i $INET_IF -p tcp --dport 2064 -j ACCEPT

# edonkey
$IPTABLES -t filter -A block -i $INET_IF -p tcp --dport 4661 -j ACCEPT
$IPTABLES -t filter -A block -i $INET_IF -p tcp --dport 4662 -j ACCEPT
$IPTABLES -t filter -A block -i $INET_IF -p udp --dport 4665 -j ACCEPT

# ms games
$IPTABLES -t filter -A block -i $INET_IF -p tcp --dport 47624 -j ACCEPT
$IPTABLES -t filter -A block -i $INET_IF -p tcp --dport 2300:2400 -j ACCEPT
$IPTABLES -t filter -A block -i $INET_IF -p udp --dport 2300:2400 -j ACCEPT
$IPTABLES -t filter -A block -i $INET_IF -p udp --dport 6073 -j ACCEPT

# netmeeting
$IPTABLES -t filter -A block -i $INET_IF -p tcp --dport 1720 -j ACCEPT
########## END portmapping


$IPTABLES -t filter -A block -j DROP
$IPTABLES -t filter -A INPUT -j block
$IPTABLES -t filter -A FORWARD -j block

########## START portmapping
# www
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 80 -j DNAT --to-destination 192.168.0.11

# ftp
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 21 -j DNAT --to-destination 192.168.0.10

# dnet proxy
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 2064 -j DNAT --to-destination 192.168.0.11

#edonkey
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 4661 -j DNAT --to-destination 192.168.0.10
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 4662 -j DNAT --to-destination 192.168.0.10
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p udp --dport 4665 -j DNAT --to-destination 192.168.0.10

# ms games
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 47624 -j DNAT --to-destination 192.168.0.210
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p udp --dport 6073 -j DNAT --to-destination 192.168.0.210
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 2300:2400 -j DNAT --to-destination 192.168.0.210
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p udp --dport 2300:2400 -j DNAT --to-destination 192.168.0.210

# netmeeting
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 1720 -j DNAT --to-destination 192.168.0.1-192.168.0.253
########## END portmapping


# NAT
$IPTABLES -t nat -A POSTROUTING -o $INET_IF -s $LAN -d 0/0 -j MASQUERADE

Dit werkt hier redelijk goed, al het internet verkeer vanuit het netwerk werkt gewoon, maar vanaf internet ben ik volledig stealth'ed (zie test op http://www.pcflank.com/).
Zoals je ziet route ik ook nog redelijk wat traffic naar binnen in het netwerk op verscheidene services te kunnen draaien (de portmapping sectie's).
Ik heb nou eigenlijk ook nog 1 vraagje. Om edonkey/ms games te laten werken moet je zoals je ziet wat porten mappen, maar nu werkt dit maar op 1 host in het netwerk. Is er ook een manier op edonkey/ms games op elke host te laten werken? Ik dacht zoiets, maar dat werkt niet echt:
code:
1
2
3
4
5
6
7
8
9
#edonkey
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 4661 -j DNAT --to-destination 192.168.0.1-192.168.0.253
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 4662 -j DNAT --to-destination 192.168.0.1-192.168.0.253
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p udp --dport 4665 -j DNAT --to-destination 192.168.0.1-192.168.0.253
# ms games
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 47624 -j DNAT --to-destination 192.168.0.1-192.168.0.253
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p udp --dport 6073 -j DNAT --to-destination 192.168.0.1-192.168.0.253
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p tcp --dport 2300:2400 -j DNAT --to-destination 192.168.0.1-192.168.0.253
$IPTABLES -t nat -A PREROUTING -i $INET_IF -p udp --dport 2300:2400 -j DNAT --to-destination 192.168.0.1-192.168.0.253

Ow, dit is trouwens de inhoud van iptables-flush.sh:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

IPTABLES="/sbin/iptables"

$IPTABLES -t filter -P INPUT ACCEPT
$IPTABLES -t filter -P FORWARD ACCEPT
$IPTABLES -t filter -P OUTPUT ACCEPT

$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT

$IPTABLES -t mangle -P PREROUTING ACCEPT
$IPTABLES -t mangle -P OUTPUT ACCEPT

$IPTABLES -t filter -F
$IPTABLES -t nat -F
$IPTABLES -t mangle -F

$IPTABLES -t filter -X
$IPTABLES -t nat -X
$IPTABLES -t mangle -X

Zoals je ziet heb ik default policy op ACCEPT staan, zou dat beter DROP kunnen zijn?

(excuses voor de grote lappen text :) )
Pagina: 1