Re: ipfw- und natd-Problem

From: Bernd Walter <ticso(at)cicely8.cicely.de>
Date: Fri, 18 Jan 2002 00:10:11 +0100

On Thu, Jan 17, 2002 at 09:48:16PM +0100, Karsten Rothemund wrote:
> Hallo Liste,
>
> ich habe hier folgende Situation:
>
> Linux-Rechner ---- FreeBSD-Rechner ---- Modem ---- ISP
> 192.168.1.1 192.168.1.100
>
> Vom ISP kommt eine dyn IP. Deshalb muss(?) ich wohl natd einsetzen.
> Die relevanten Stellen im /etc/rc.conf:
>
> # -- Firewall mit ipfw -- #
> firewall_enable="YES"
> firewall_type="/etc/ipfw.rules"
> # -- Rechner arbeitet als Gateway -- #
> gateway_enable="YES"
> # -- NATD nicht vergessen -- #
> natd_enable="YES"
> natd_program="/sbin/natd"
> natd_interface="tun0"
> natd_flags="-f /etc/natd.conf"
>
> und in /etc/natd.conf:
>
> dynamic yes
> use_sockets yes
> same_ports yes
>
> Ich habe versucht die Firewallregeln statefull zu machen (aus diversen
> HowTos versucht zusammengebastelt): /etc/ipfw.rules:
>
> # Loopback-Device (damit auch noch nach einem Reload der Regeln da)
> add 100 pass all from any to any via lo0
> add 200 deny all from any to 127.0.0.0/8
> add 300 deny ip from 127.0.0.0/8 to any
> # ping
> add 1000 deny icmp from any to 192.168.1.0/24 in via tun0 icmptypes 8
> add 1010 check-state
> add 1020 allow icmp from 192.168.1.0/24 to any out via tun0 icmptypes
> 8 keep-state
> add 1030 allow icmp from 192.168.1.0/24 to 192.168.1.0/24
> add 1040 deny log icmp from any to any
> #
> # ssh, ftp, smtp und dns
> add 2000 allow tcp from any to any established
> add 3000 allow tcp from any to 192.168.1.0/24 ftp,ssh,smtp setup
> #add 3010 allow tcp from 192.168.1.0/24 ftp,ssh,smtp to any setup
> add 4000 allow udp from 192.168.1.0/24 to any domain
> add 4100 allow udp from any domain to 192.168.1.0/24
> #
> # default: alles dicht!
> add 65000 deny log all from any to any
>
> Nachdem ich die Modemverbindung aufgebaut habe, habe ich vom
> Linux-Rechner aus ein Ping und ein slogin auf einen externen Rechner
> versucht. Beides schlug fehl. Ein ipfw show zeigt folgendes:
>
> 00100 0 0 allow ip from any to any via lo0
> 00200 0 0 deny ip from any to 127.0.0.0/8
> 00300 0 0 deny ip from 127.0.0.0/8 to any
> 00500 1 78 divert 8668 ip from any to any via tun0
> 01000 0 0 deny icmp from any to 192.168.1.0/24 in recv tun0 icmptype 8
> 01010 0 0 check-state
> 01020 0 0 allow icmp from 192.168.1.0/24 to any keep-state out xmit
> tun0 icmptype 8
> 01030 0 0 allow icmp from 192.168.1.0/24 to 192.168.1.0/24
> 01040 4 336 deny log logamount 10 icmp from any to any
> 02000 0 0 allow tcp from any to any established
> 03000 0 0 allow tcp from any to 192.168.1.0/24 21,22,25 setup
> 03010 0 0 allow tcp from 192.168.1.0/24 21,22,25 to any setup
> 04000 1 78 allow udp from 192.168.1.0/24 to any 53
> 04100 0 0 allow udp from any 53 to 192.168.1.0/24
> 65000 1 78 deny log logamount 10 ip from any to any
> 65535 0 0 allow ip from any to any
>
> Offensichtlich sind die Regeln zu restriktiv (lasse ich 65000 weg,
> gehts - natuerlich, default is offen). Koennt ihr mir einen Tipp
> geben, wo.

1020 macht einen keep-state auf eine Verbindung von einer Internen IP.
Ein match kann aber niemals statfinden, weil Packete von innen in 500
bereits umgesetzt werden.
Ist aber eh Unsinn, weil natd ja bereits statefull ist.
Was natd nicht kennt setzt der auch nicht auf eine interne IP um und
kann demzufolge auch nicht auf einem internen Rechner landen.

Ipfws state-full Feature brauchst du nur um nicht interne IPs zu
schützen, also in der Regel den Router selber.
Vorsicht ist aber auch hierbei zu beachten das dynamische Einträge
auch nur bei den IPs als Absender erzeugt werden, da die Einträge
sonst nicht abgebaut werden.

-- 
B.Walter              COSMO-Project         http://www.cosmo-project.de
ticso(at)cicely.de         Usergroup           info(at)cosmo-project.de
To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Fri 18 Jan 2002 - 00:09:24 CET

search this site