From owner-freebsd-net@freebsd.org Tue Sep 15 10:28:08 2015 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2AFD0A02138 for ; Tue, 15 Sep 2015 10:28:08 +0000 (UTC) (envelope-from ohartman@zedat.fu-berlin.de) Received: from outpost1.zedat.fu-berlin.de (outpost1.zedat.fu-berlin.de [130.133.4.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DA5D01EFE; Tue, 15 Sep 2015 10:28:07 +0000 (UTC) (envelope-from ohartman@zedat.fu-berlin.de) Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.85) with esmtp (envelope-from ) id <1ZbnT3-000FmQ-VH>; Tue, 15 Sep 2015 12:28:05 +0200 Received: from p578a69f9.dip0.t-ipconnect.de ([87.138.105.249] helo=freyja.zeit4.iv.bundesimmobilien.de) by inpost2.zedat.fu-berlin.de (Exim 4.85) with esmtpsa (envelope-from ) id <1ZbnT3-000wtK-Jl>; Tue, 15 Sep 2015 12:28:05 +0200 Date: Tue, 15 Sep 2015 12:28:04 +0200 From: "O. Hartmann" To: "Alexander V. Chernikov" Cc: Kimmo Paasiala , FreeBSD Net Subject: Re: HELP! Mysterious socket 843/tcp listening on CURRENT system Message-ID: <20150915122804.60c2f5a6@freyja.zeit4.iv.bundesimmobilien.de> In-Reply-To: <1483331442311155@web17h.yandex.ru> References: <20150915090658.1e0b9074@freyja.zeit4.iv.bundesimmobilien.de> <20150915094757.3daef42c@freyja.zeit4.iv.bundesimmobilien.de> <1483331442311155@web17h.yandex.ru> Organization: FU Berlin X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; amd64-portbld-freebsd11.0) MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit X-Originating-IP: 87.138.105.249 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 10:28:08 -0000 On Tue, 15 Sep 2015 12:59:15 +0300 Alexander V. Chernikov wrote: > > > 15.09.2015, 10:48, "O. Hartmann" : > > On Tue, 15 Sep 2015 10:21:21 +0300 > > Kimmo Paasiala wrote: > > > >> šOn Tue, Sep 15, 2015 at 10:06 AM, O. Hartmann > >> š wrote: > >> š> Hopefully, I'm right on this list. if not, please forward. > >> š> > >> š> Running CURRENT as of FreeBSD 11.0-CURRENT #3 r287780: Mon Sep 14 > >> 13:34:16 > CEST 2015 amd64, I check via nmap for open sockets since I had > >> trouble > protecting a server with IPFW and NAT. > >> š> > >> š> I see a service (nmap) > >> š> > >> š> Host is up (0.041s latency). > >> š> Not shown: 998 filtered ports > >> š> PORT STATE SERVICE > >> š> 843/tcp open unknown > >> š> > >> š> and via sockstat -l -p 843, I get this: > >> š> ? ? ? ? tcp4 *:843 *:* > >> š> > >> š> I double checked all services on the server and i can not figure out > >> what > daemon or service is using this port. The port is exposed throught > >> NAT (I > use in-kernel NAT on that system). > >> š> This service is accessible via telnet host-ip 843: > >> š> > >> š> Trying 85.179.165.184... > >> š> Connected to xxx.xxx.xxx.xxx. > >> š> Escape character is '^]'. > >> š> > >> š> > >> š> Well, I feel pants-down right now since it seems very hard to find out > >> what > service is keeping this socket open for communications to the > >> outside world. > > >> š> Anyone any suggestions? > >> š> > >> š> Thanks in advance, > >> š> Oliver > >> > >> šAs delphij@ noted it's most likely something that uses rpcbind(3). Why > >> šare your filter rules allowing unknown ports to be open to the > >> šinternet? Don't you have a default deny policy in place? > > > > Hello. > > Many thanks for the fast response. > > > > I switched recently from PF to IPFW and utilise in-kernel NAT via libalias. > > I think the "wooden" concept of rules made me penetrate the IP filter and > > expose it to the outer world. The mysterious port 843/tcp isn't the only > > one that is exposed, NFS is also. I have rules that block all incoming > > trafiic from the exposed-to-the-internet interface and should allow all > > traffic on the inside and local interfaces. The rulesets I utilised work so > > far on machines without NAT (department, bureau, etc.). The moment NAT > > comes into play I do not understand the way IPFW works - it seems to blow a > > whole into any bunch of filterings walls I create. But that is an other > > issue and it is most likely due to the outdated documentation (that doc > > still uses port 37 for NTP purposes and referes to the outdated divert > > mechanism using natd, see the recent handbook). The internet is also full > > of ambigous examples. > > > > At the moment I have no access to the box since IPFW and it's reload/restart > > mechanism (etc/rc.d/ipfw) seems to be very instable when restartet too > > often. > Well, ipfw(8) rc script might really need some face-lifting, but I wonder > what is the source of instability might be. It would be great to hear more > details so we can do something to prevent that? The syntax and layout of the rc.firewall rc-script is ambigous and confusing. The script added to firewall_type="XXXXXX" in rc.conf is a direct ipfw script containing non-expanded ipfw commands. There is nothing about variable expanding from rc.conf or rc.conf.local. In the logic of the other firewall type, OPEN, WORKSTATION et cetera, one might think the rc.firewall script is utilising the variables set in rc.conf. But nothing so far! For me, that looked more like a logic break of the concept. The people at FreeBSD usually do a great work by defining default values. I like it to use the default settings done by the original rc.firewall script, especially for the loopback device and IPv6 and IPv4 enbaling/disabling. Using "firewall_type=" in rc.conf leaves you alone with a raw, unexpanded script which doesn't make use of the settings in rc.conf. The problems I face are sometimes related to syntax errors when creating ipfw tables - as this is done by the rc.firewall script preventing non-official IP ranges accessing the intranetwork. Somehow I can "service ipfw restart" the original-left-over service when using only type WORKSTATION or so - the scripts handle gracefully the restart, no established connectiong gets dropped off, no errors occur when creating/flushing tables. Using the "wooden" and clumsy firewall_type="" where the added set of rules is a pure ipfw-command script - the problems arise very quickly. > > > I did it serveral times with moderate delays of several seconds or minutes > > inbetween and now the box is "gone". Checking with nmap, port 22/tcp > > sometimes is open, then closed again. This is also very weird. > > > > > IPWF seems not to be right choice, even if it is FreeBSD native. > > > > @delphi: I will give an answer as soon I gain access to the box again. > > > > Regards and thanks, > > > > oh > > _______________________________________________ > > freebsd-net@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/freebsd-net > > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"