Toon posts:

[FreeBSD] problemen met ipf

Pagina: 1
Acties:

Verwijderd

Topicstarter
Goed ik geef toe. Ik ben een komplete newbie......
Recentelijk gestort op FreeBSD (5.1.2] wil ik een server opzetten. Tot nog toe loopt het prima. Ik ben nu bezig met een fijne firewall maar dat wil niet echt.

Ik start ipf via rc.conf (niet gecompileerd in de kernel) en deze is ook geinitialiseerd getuige deze melding in de logs....
code:
1
Nov 10 15:38:28 pacsforum kernel: IP Filter: v3.4.31 initialized.  Default = pass all, Logging = enabled


Ik ben met een vrij simpel rules-scriptje begonnen maar stuit direct op problemen. Ik heb mijn al simpele script verder gestript tot er zowat niets meer instaat maar nog steeds enkel foutmeldingen wanneer ik de regels wil inlezen.

Zo ziet mijn ipf.rules er nu uit
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# start ipf script

# inkomend op Lo0

pass in                 quick on lo0    all

# uitgaand op lo0
pass out                quick on lo0    all

#inkomend op xl0

pass in         quick on xl0    proto tcp       from any to 10.2.2.189  port 25 flags S keep state
pass in         quick on xl0    proto tcp       from any to 10.2.2.189  port 80 flags S keep state
pass in         quick on xl0    proto tcp       from any to 10.2.2.189 port 443 flags S keep state
pass in         quick on xl0    proto tcp       from any to 10.2.2.189 port 22 flags S keep state
pass in         quick on xl0    proto tcp       from any to 10.2.2.189 port 21 flags S keep state

# uitgaand op xl0
pass out        quick on xl0    proto udp       from 10.2.2.189 to any port 53 keep state
pass out        quick on xl0    proto tcp       from 10.2.2.189 to any port 53 flags S keep state

# einde script


Dit zijn de fouten die ik krijg
code:
1
2
3
4
5
6
7
8
9
pacsforum# ipf -Fa -f /etc/ipf.rules
12: unknown range operator (flags)
13: unknown range operator (flags)
14: unknown range operator (flags)
15: unknown range operator (flags)
16: unknown range operator (flags)
19: unknown range operator (keep)
20: unknown range operator (flags)
pacsforum#


Kan iemand me een zetje in de rug geven?

Verwijderd

Gebruik eens ipv port <eenportnummer>, port = <eenpoortnummer> en dan zou het wel moeten werken.

[ Voor 13% gewijzigd door Verwijderd op 11-11-2004 11:12 ]


Verwijderd

Topicstarter
Helaas......Dan krijg ik dit te zien

code:
1
2
3
4
5
6
7
8
9
pacsforum# ipf -Fa -f /etc/ipf.rules
12: unknown words at end: [port=25 flags S keep state ]
13: unknown words at end: [port=80 flags S keep state ]
14: unknown words at end: [port=443 flags S keep state ]
15: unknown words at end: [port=22 flags S keep state ]
16: unknown words at end: [port=21 flags S keep state ]
19: unknown words at end: [port=53 keep state ]
20: unknown words at end: [port=53 flags S keep state ]
pacsforum#

  • serkoon
  • Registratie: April 2000
  • Niet online

serkoon

mekker.

Er moeten spaties om die '=' heen: dus "port = 22".

Verwijderd

Topicstarter
Yoepie, de fouten zijn weg !!!!!

mijn dank is groot. Nu kan ik me storten op de feitelijke regels......
Dank !!!!! _/-\o_

Verwijderd

Topicstarter
ik ga maar even in dit topic verder.....

Ik heb nu een compleet script wat volgens mij aardig werkt op 1 ding na.
wanneer ik een ftp sessie open naar de server kan ik wel inloggen maar daarna stopt de ftp client tijdens het ophalen van de dirs. Kan ieman zien hoe dat komt, ben ik een service/poort vergeten????
Zonder activering van ipf werkt de ftp nl prima.

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
#     ipf regels scriptje


#-----------------------------------------------------------------------
# anti-spoof regels
#-----------------------------------------------------------------------
block in log quick on xl0 from 192.168.0.0/16 to any  #RFC 1918 private IP
block in log quick on xl0 from 172.16.0.0/12 to any   #RFC 1918 private IP
# NU EVEN NIET    block in log quick on xl0 from 10.0.0.0/8 to any      #RFC 1918 private IP
block in log quick on xl0 from 127.0.0.0/8 to any     #loopback
block in log quick on xl0 from 0.0.0.0/8 to any       #loopback
block in log quick on xl0 from 169.254.0.0/16 to any  #DHCP auto-config
block in log quick on xl0 from 192.0.2.0/24 to any    #reserved for doc's
block in log quick on xl0 from 204.152.64.0/23 to any #Sun cluster interconnect
block in log quick on xl0 from 224.0.0.0/3 to any     #Class D & E multicast

# Block unwanted options
block in log quick from any to any with short
block in log quick from any to any with frags
# Block sourcerouting
block in log quick from any to any with opt lsrr
block in log quick from any to any with opt ssrr


#----------------------------------------------------------------
# Wat mag er allemaal naar binnen ????
#----------------------------------------------------------------
# Later Dit Stuk Aanpassen !!!!!!!!!!!!!
# Nu ff anders    pass in quick on xl0 proto tcp from X.X.0.0/16 to any port = ssh flags S keep state
pass in quick on xl0 proto tcp from any to any port = ssh flags S keep state
pass in quick on xl0 proto tcp from any to any port = ftp flags S keep state
pass in quick on xl0 proto tcp from any to any port = smtp flags S keep state
pass in quick on xl0 proto tcp from any to any port = http flags S keep state
pass in quick on xl0 proto tcp from any to any port = auth flags S keep state
pass in quick on xl0 proto tcp from any to any port = imap flags S keep state
pass in quick on xl0 proto tcp from any to any port = https flags S keep state
pass in quick on xl0 proto tcp from any to any port = smtps flags S keep state
pass in quick on xl0 proto icmp from any to any icmp-type 0
pass in quick on xl0 proto icmp from any to any icmp-type 3
pass in quick on xl0 proto icmp from any to any icmp-type 8
pass in quick on xl0 proto icmp from any to any icmp-type 11
pass out quick on xl0 proto udp from any to any port = 53 keep state

#  CVS poorten
pass in quick on xl0 proto tcp from any to any port 59999 >< 60051 flags S keep state

#----------------------------------------------------------------
# Block and log all remaining traffic coming into the firewall
# - Block TCP with a RST (to make it appear as if the service
# isn't listening)
# - Block UDP with an ICMP Port Unreachable (to make it appear
# as if the service isn't listening)
# - Block all remaining traffic the good 'ol fashioned way
#----------------------------------------------------------------
block return-rst in log quick on xl0 proto tcp from any to any
block return-icmp-as-dest(port-unr) in log quick on xl0 proto udp from any to any
block in log quick on xl0 all


#################################################################
# Loopback Interface
#################################################################

pass in quick on lo0 all
pass out quick on lo0 all


#     Einde script


output ftp client
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
Status: Connected with pacsforum.erasmusmc.nl. Waiting for welcome message...
Response:   220 ProFTPD 1.2.10 Server (Pacsforum.ErasmusMC) [10.2.2.189]
Command:    USER supervisor
Response:   331 Password required for supervisor.
Command:    PASS ****
Response:   230 User supervisor logged in.
Command:    FEAT
Response:   211-Features:
Response:    MDTM
Response:    REST STREAM
Response:    SIZE
Response:   211 End
Command:    SYST
Response:   215 UNIX Type: L8
Status: Connected
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/" is current directory.
Command:    PORT 10,2,2,126,4,119
Response:   200 PORT command successful
Command:    TYPE A
Response:   200 Type set to A
Command:    LIST
Response:   425 Unable to build data connection: Operation timed out
Error:  Could not retrieve directory listing

Verwijderd

Dan moet je een ftp client gebruiken die passive ftp ondersteunt. Of iets als ftp-proxy gaan gebruiken mocht je echt active ftp nodig hebben.

Verwijderd

Topicstarter
MMmhhh...
inderdaad passive maak ik wel een goed connectie....Toch nog eens kijken naar het grote verschil tussen active/passive.......

Dank

  • serkoon
  • Registratie: April 2000
  • Niet online

serkoon

mekker.

Je kunt ook inkomende tcp connects op poorten >= 49152 toelaten. De standaard ftpd onder FreeBSD gebruikt die poorten om active connects op te doen.

Je kunt het aanpassen dmv sysctl net.inet.ip.portrange.hifirst en .hilast of dmv de -U optie die 1024 .. 4999 zal gebruiken ipv die hifirst .. hilast.
Pagina: 1