Hi,

I was using a FreeBSD 4.7 box. The fxp1 is my internal interface and fxp0 is my external interface. I put in the following three rules to map internal IPs to external IP.

block out log quick on fxp0 proto tcp from 10.10.4.0/24 to 172.31.1.100 port = 3000
pass in log quick on fxp1 proto tcp from 10.10.4.0/24 to 172.31.1.100 port = 3000 flags S keep state keep frag


map fxp0 from 10.10.4.0/24 to 172.31.1.100 port = 3000 -> 172.31.1.66/32 portmap tcp 30000:40000 frag

After running 10,000 tcp connections through the box for a few times, I start to see the ipfilter let internal 10.10.4.0 IP to go out on the external interface. The tens of thousands of TCP connection was set up one after another with no delay in between. Except the three way hand shake, there is no other data passed on the connection, however, there may be TCP window update. I put the block rule there specifically to prevent the 10.10.4.0 ip from leaving the external interface, however here is a snap of the log to shown the leak. I have tcpdump to confirm that the IP does leak out.

some normal log (what I expect to see)
09/02/2004 15:15:50.050786 fxp1 @0:8 p 10.10.4.117,63818 -> 172.31.1.100,3000 PR tcp len 20 60 -S K-S K-F IN
09/02/2004 15:15:50.050885 fxp0 @0:8 p 172.31.1.66,30935 -> 172.31.1.100,3000 PR tcp len 20 60 -S K-S K-F OUT
09/02/2004 15:15:50.052111 fxp0 @0:8 p 172.31.1.100,3000 -> 10.10.4.117,63818 PR tcp len 20 60 -AS K-S K-F IN
09/02/2004 15:15:50.052147 fxp1 @0:8 p 172.31.1.100,3000 -> 10.10.4.117,63818 PR tcp len 20 60 -AS K-S K-F OUT
09/02/2004 15:15:50.052317 fxp1 @0:8 p 10.10.4.117,63818 -> 172.31.1.100,3000 PR tcp len 20 52 -A K-S K-F IN
09/02/2004 15:15:50.052336 fxp0 @0:8 p 172.31.1.66,30935 -> 172.31.1.100,3000 PR tcp len 20 52 -A K-S K-F OUT
09/02/2004 15:15:50.052464 fxp1 @0:8 p 10.10.4.117,63819 -> 172.31.1.100,3000 PR tcp len 20 60 -S K-S K-F IN
09/02/2004 15:15:50.052562 fxp0 @0:8 p 172.31.1.66,30936 -> 172.31.1.100,3000 PR tcp len 20 60 -S K-S K-F OUT
09/02/2004 15:15:50.053785 fxp0 @0:8 p 172.31.1.100,3000 -> 10.10.4.117,63819 PR tcp len 20 60 -AS K-S K-F IN
09/02/2004 15:15:50.053818 fxp1 @0:8 p 172.31.1.100,3000 -> 10.10.4.117,63819 PR tcp len 20 60 -AS K-S K-F OUT
09/02/2004 15:15:50.053987 fxp1 @0:8 p 10.10.4.117,63819 -> 172.31.1.100,3000 PR tcp len 20 52 -A K-S K-F IN
09/02/2004 15:15:50.054008 fxp0 @0:8 p 172.31.1.66,30936 -> 172.31.1.100,3000 PR tcp len 20 52 -A K-S K-F OUT


....
(start of internal IP leak)

09/02/2004 15:16:47.011648 fxp1 @0:8 p 10.10.4.117,64002 -> 172.31.1.100,3000 PR tcp len 20 60 -S K-S K-F IN
09/02/2004 15:16:47.177407 fxp0 @0:8 p 10.10.4.117,64002 -> 172.31.1.100,3000 PR tcp len 20 60 -S K-S K-F OUT
09/02/2004 15:16:47.178765 fxp0 @0:8 p 172.31.1.100,3000 -> 10.10.4.117,64002 PR tcp len 20 60 -AS K-S K-F IN
09/02/2004 15:16:47.178820 fxp1 @0:8 p 172.31.1.100,3000 -> 10.10.4.117,64002 PR tcp len 20 60 -AS K-S K-F OUT
09/02/2004 15:16:47.179047 fxp1 @0:8 p 10.10.4.117,64002 -> 172.31.1.100,3000 PR tcp len 20 52 -A K-S K-F IN
09/02/2004 15:16:47.343727 fxp0 @0:8 p 10.10.4.117,64002 -> 172.31.1.100,3000 PR tcp len 20 52 -A K-S K-F OUT
09/02/2004 15:16:47.343861 fxp1 @0:8 p 10.10.4.117,64003 -> 172.31.1.100,3000 PR tcp len 20 60 -S K-S K-F IN
09/02/2004 15:16:47.508589 fxp0 @0:8 p 10.10.4.117,64003 -> 172.31.1.100,3000 PR tcp len 20 60 -S K-S K-F OUT
09/02/2004 15:16:47.510059 fxp0 @0:8 p 172.31.1.100,3000 -> 10.10.4.117,64003 PR tcp len 20 60 -AS K-S K-F IN
09/02/2004 15:16:47.510122 fxp1 @0:8 p 172.31.1.100,3000 -> 10.10.4.117,64003 PR tcp len 20 60 -AS K-S K-F OUT
09/02/2004 15:16:47.514243 fxp1 @0:8 p 10.10.4.117,64003 -> 172.31.1.100,3000 PR tcp len 20 52 -A K-S K-F IN
09/02/2004 15:16:47.680109 fxp0 @0:8 p 10.10.4.117,64003 -> 172.31.1.100,3000 PR tcp len 20 52 -A K-S K-F OUT



Here is my little program that generated these 10, 000 connections.


main (int argc, char **argv)
{
    int conn=0;
    int i;
    struct in_addr addr, baddr;
    struct sockaddr_in ad;
    short  port;
    int sock;
    int on = 0;

    conn = atoi(argv[1]);
    addr.s_addr = inet_addr(argv[2]);
    port = atoi(argv[3]);
    baddr.s_addr = inet_addr(argv[4]);

for (i=0 ; i< conn; i++) {
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
perror("socket() error");
exit(1);
}
on = IP_PORTRANGE_HIGH;
if (setsockopt(sock, IPPROTO_IP, IP_PORTRANGE, (char *)&on, sizeof(on)) < 0) {
perror("setsockopt error:");
}
bzero(&ad, sizeof(ad));
ad.sin_family = AF_INET;
ad.sin_addr = baddr;
if (bind(sock, (struct sockaddr *)&ad, sizeof(ad)) < 0) {
perror("bind err");
exit(0);
}
bzero(&ad, sizeof(ad));
ad.sin_family = AF_INET;
ad.sin_port = htons(port);
ad.sin_addr = addr;
connect (sock, (struct sockaddr *)&ad, sizeof(ad));


    }
    getchar();
}

Any adivce is appreciated,
Ming





Reply via email to