[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

IPv4 localhost network problem



Hi,

I have problem with IPv4 on my local network. Applications that is trying to 
connect to localhost with IPv4 gets “connection refused”. I have constructed a 
simple Java program that is triggering the problem. The program simple just 
open a socket port and waiting for a connection.

Starting by doing the following:
    $ java DummyServer 7000

When testing with telnet:
    $ telnet -4 localhost 7000
    Trying 127.0.0.1...
    telnet: Unable to connect to remote host: Connection refused
    $ 

By forcing with IPv6 is working:
    $ telnet -6 localhost 7000
    Trying ::1...
    Connected to ip6-localhost.
    Escape character is '^]'.
    Connection closed by foreign host.
    $

My /etc/hosts
    127.0.0.1       localhost
    127.0.1.1       gizmo

    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts

IPConfig:
$ /sbin/ifconfig
    eth0     *hidden*

    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:516 errors:0 dropped:0 overruns:0 frame:0
              TX packets:516 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:37316 (36.4 KiB)  TX bytes:37316 (36.4 KiB)

IPTables:
    $ sudo iptables --list
    WARNING: All config files need .conf: /etc/modprobe.d/nvidia-kernel-nkc, 
it will be ignored in a future release.
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination

    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination

    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination

When running the iptables command, the kernel also output the following in 
it's log:
    [ 3456.030975] ip_tables: (C) 2000-2006 Netfilter Core Team


My /etc/network/interface file
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    # The loopback network interface
    auto lo eth0
    iface lo inet loopback

    # The primary network interface
    allow-hotplug eth0
    iface eth0 inet dhcp


Any ideas what can be wrong?

   Martin
import java.net.*;

public class DummyServer
{
	public static void main(String [] args) throws Exception {
		if (args.length != 1) {
			System.out.println("port");
			return;
		}
	
		int port = Integer.parseInt(args[0]);
		ServerSocket ss = new ServerSocket(port);
		System.out.println(String.format("Waiting on %d...", port));
		Socket s = ss.accept();
		System.out.println(String.format("Accepted: %s", s.getRemoteSocketAddress()));
	}
}

Reply to: