Subject: Re: failure from bizarre NAT setup
To: <>
From: Steven M. Bellovin <smb@research.att.com>
List: tech-net
Date: 04/23/2004 14:08:05
This is a multipart MIME message.

--==_Exmh_-7546941040
Content-Type: text/plain; charset=us-ascii

I'm no longer convinced I'm seeing a NAT-related problem.  I tried a 
simple program; it's failing on my laptop (running 2.0beta from about a 
week ago), but succeeding on a 1.6.2 machine.  Unfortunately, I don't
have access to any other 2.0 machines or -current machines at the 
moment.

The test program is attach; here's the output and other data I believe 
to be relevant.  The route to 12.155.186.198 is a dreg from an Ethernet 
connection last night.

b166$ ifconfig -a 
fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: 00:10:a4:8b:9b:7a
        media: Ethernet autoselect (none)
        status: no carrier
        inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255
        inet6 fe80::210:a4ff:fe8b:9b7a%fxp0 prefixlen 64 scopeid 0x1
lo0: flags=8009<UP,LOOPBACK,MULTICAST> mtu 33196
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
ppp1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 296
sl1: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 296
strip0: flags=0 mtu 1100
strip1: flags=0 mtu 1100
wi0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ssid CFP
        powersave off
        bssid 00:0c:ce:85:7a:07 chan 11
        address: 00:60:1d:f0:34:fb
        media: IEEE802.11 autoselect (DS11)
        status: active
        inet 172.19.2.96 netmask 0xfffff800 broadcast 172.19.7.255
        inet6 fe80::260:1dff:fef0:34fb%wi0 prefixlen 64 scopeid 0x9
b167$ netstat -nrf inet
Routing tables

Internet:
Destination        Gateway            Flags     Refs     Use    Mtu  Interface
0/8                link#1             UC          0        0      -  fxp0 =>
default            172.19.0.1         UGS         3     9040      -  wi0
12.155.186.198     127.0.0.1          UGHS        0        0  33196  lo0
127/8              127.0.0.1          UGRS        0        0  33196  lo0
127.0.0.1          127.0.0.1          UH          8    45660  33196  lo0
172.19/21          link#9             UC          1        0      -  wi0
172.19.0.1         00:02:b3:d8:3b:af  UHLc        3      193      -  wi0
172.19.2.96        127.0.0.1          UGHS        0        0  33196  lo0
172.19.5.7         127.0.0.1          UGHS        0        0  33196  lo0
172.19.5.26        127.0.0.1          UGHS        0        0  33196  lo0
172.19.5.49        127.0.0.1          UGHS        0        0  33196  lo0
172.19.5.66        127.0.0.1          UGHS        0        0  33196  lo0
b168$ ./a.out
family 2 port 61688 addr 0.0.0.0
connect: Can't assign requested address


--==_Exmh_-7546941040
Content-Type: text/plain ; name="x.c"; charset=us-ascii
Content-Description: x.c
Content-Disposition: attachment; filename="x.c"

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

struct sockaddr_in us, them, who;

void
fatal(char *s)
{
	perror(s);
	exit(1);
}

main(int argc, char *argv[])
{
	int fd;
	int nlen;

	fd = socket(PF_INET, SOCK_STREAM, 0);
	if (fd < 0) {fatal("socket");}

	us.sin_family = AF_INET;
	if (bind(fd, (struct sockaddr *)&us, sizeof us) < 0) fatal("bind");

	nlen = sizeof who;
	if (getsockname(fd, (struct sockaddr *)&who, &nlen) < 0)
		fatal("getsockname");
	printf("family %d port %d addr %s\n", who.sin_family, who.sin_port,
	    inet_ntoa(who.sin_addr));

	them.sin_family = AF_INET;
	if (inet_aton("147.28.0.62", &them.sin_addr) == 0) fatal("inet_aton");
	them.sin_port = htons(22);

	if (connect(fd, (struct sockaddr *)&them, sizeof them) < 0)
		fatal("connect");
	return 0;
}


--==_Exmh_-7546941040
Content-Type: text/plain; charset=us-ascii

		--Steve Bellovin, http://www.research.att.com/~smb

--==_Exmh_-7546941040--