Smoe wrote:
> Declan Moriarty wrote:
>
>>> Hello,
>>>
>>> I met a weird problem with my LFS:
>>> the 'netstat' command can not list ports
>>> listened by java code,such as Tomcat.
>>>
>>> following commands were issued:
>>>
>>> #netstat -t and
>>> #netstat -a |grep tcp
>>>
>>> none of the above commands shows that port 8080
>>> was listened by some process.
>>> but if I enter "http://localhost:8080/" in firefox,
>>> the welcome page of tomcat appears successfully.
>>>
>>>
>>> Then I wrote a small java program which simplly listnes
>>> on tcp port 4000, and waiting for incoming connections.
>>> the 'netstat' can not see the port ether, but I can
>>> telnet to the port.
>>>
>>> all established connections through the ports
>>> can be listed by netstat.
>>>
>>> and even the listening ports(tcp) can be seen with
>>> command 'fuser -uv -n tcp xxxx', (xxxx is the tcp port
>>> to be checked, the command line sholud be issued by root).
>>>
>>>
>>> I installed LFS6.0, kernel updated to 2.6.12.2, and udev
>>> to udev-058. other packages remain same as LFS6.0.
>>> oh,I also install gcc-3.3.4 in /opt.
>>>
>>>
>>> If someone met this problem too, please tell me your solution,
>>> thanks in advance.
>>> I had doubted whether my computer was infected by virus or
>>> root kit, but I am not sure on that.
>>>
>>>
>>>
>>> thanks
>>>
>>>
>>>
>>
>>
>> Netstat doesn't do it for me either, but then I didn't really expect it
>> to. From 'man netstat'
>>
>> /Proving I actually read _something_.
>>
>>
>> NAME
>> netstat - Print network connections, routing tables, interface
>> statistics, masquerade connections, and multicast memberships
>>
>>
>> A daemon that is listening on a port is not necessarily connected, or
>> routed, just listening. Why should netstat list it?
>>
>>
>>
> Hello,
>
> netstat has a couple of options, that should do the expected:
>
> #netstat -lntp
> for example shows all tcp-ports any process is listening as number and
> with the appropriate process.
> note, that port 8080 is interpreted as 'http-old' if the 'n'-options
> is not given
>
> see manpages for further explanations
>
> ciao
>
> ulf
Thanks all above answers.
I tried " netstat -lntp" with root privilege after I started a small
Java program which acts as a server, listening on port 4000,
(the small java server was run by normal user, its source code is
attached at the end of this mail), the result is:
[EMAIL PROTECTED]:~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name
tcp 0 0 0.0.0.0:6000 0.0.0.0:*
LISTEN 1818/X
[EMAIL PROTECTED]:~]#
But the java code was exactly listening on port 4000, I verified that by
"telnet localhost 4000", and by "fuser"
[EMAIL PROTECTED]:~]# fuser -uv -n tcp 4000
USER PID ACCESS COMMAND
4000/tcp eric 2527 f.... java
[EMAIL PROTECTED]:~]#
After I start squid, netstat shows this:
[EMAIL PROTECTED]:~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name
tcp 0 0 0.0.0.0:5642 0.0.0.0:*
LISTEN 2122/(squid)
tcp 0 0 0.0.0.0:6000 0.0.0.0:*
LISTEN 1818/X
[EMAIL PROTECTED]:~]#
(Squid is configured to listening on port 5642.)
The source code of the small server:
//-----Begin of source-------------------
import java.net.*;
public class Server
{
public static void main(String[] args) {
try{
InetAddress addr = InetAddress.getByName("0.0.0.0");
ServerSocket ss = new ServerSocket(5000, 5, addr);
Socket s = ss.accept();
System.out.println(s.toString());
}
catch(Exception e) {
e.printStackTrace();
}
}
}
//---------End of source-----------------------
Is there any problem in the java code?
By the way, I found netstat always open "/proc/net/tcp" to search
network connections, maybe I
should check the kernel configuration, or delve into netstat source.
could anyone give me more suggestions?
All best wishes
Eric
--
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page