[4063] in linux-net channel archive

home help back first fref pref prev next nref lref last post

Re: Virtual web server

daemon@ATHENA.MIT.EDU (Bernd Eckenfels)
Fri Aug 16 20:25:39 1996

To: submit-linux-dev-net@ratatosk.yggdrasil.com
From: ecki@inka.de (Bernd Eckenfels)
Date: 	16 Aug 1996 08:58:03 GMT

Al Longyear <longyear@netcom.com> wrote:
: However, this customer wants to dedicate the entire class-C network to
: this one computer for web services. This is ONE computer and 255
: IP addresses -- all on one network -- all on one computer.

It depends on your server-software. With the transparent proxy stuff in
recent Linux kernels it is rather easy to redirect a whole class-c net to a
server bound to INADDR_ANY or one 'physical' address. But if you use servers
which need to bind to all of the addresses, then it wont work with
redirection.

Just use

ipfwadm -I -a acc -P tcp -S0.0.0.0/0 -D10.0.0.0/8 80 -r 8080

this will rediect all TCP connections to ALL of the Class-A net to the port
8080 of you system. You simply need to install an WWW Server listening, and
you will get connections like:

2.ecki@cuzco:~> telnet 10.3.0.1 80
Trying 10.3.0.1...
Connected to 10.3.0.1.
Escape character is '^]'.
getpeername:
  sin_family: 512
  sin_port  : 1789
  sin_addr  : 193.197.84.8
getsockname:
  sin_family: 512
  sin_port  : 80
  sin_addr  : 10.3.0.1
Connection closed by foreign host.

(the above output is from: /etc/inetd.conf
8080            stream tcp nowait nobody /usr/sbin/tcpd /home/ecki/src/tp_test
)

/*
 * tp_test.c    test program for linux transparent proxies
 *
 * Copyright (c) 1996 Bernd Eckenfels, Germany
 *               This work is under the GPL.
 */
#include <stdlib.h>
#include <sys/socket.h>
#include <linux/in.h>

void dump_name(char *, struct sockaddr, int);

int main(int argc,char **argv) {
  struct sockaddr name;
  int namelen;

  namelen = sizeof(name);
  if (getpeername(0, &name, &namelen) < 0) {
    perror("getpeername");
    exit(1);
  }
  dump_name("getpeername",name,namelen);
  namelen = sizeof(name);
  if (getsockname(0, &name, &namelen) < 0) {
    perror("getsockname");
    exit(1);
  }
  dump_name("getsockname",name,namelen);
}

void dump_name(char *descr, struct sockaddr name, int namelen) {
  struct sockaddr_in *sin;

  sin=(struct sockaddr_in *)&name;

  printf("%s:\n",descr);
  printf("  sin_family: %d\n",ntohs(sin->sin_family));
  printf("  sin_port  : %d\n",ntohs(sin->sin_port));
  printf("  sin_addr  : %s\n",inet_ntoa(sin->sin_addr));
}

Note: my 386 has now 16581375 addresses with sl0 and lo :)
-- 
  (OO)      -- Bernd_Eckenfels@Wittumstrasse13.76646Bruchsal.de --
 ( .. )  ecki@lina.{inka.de,ka.sub.org}  http://home.pages.de/~eckes/
  o--o     *plush*  2048/93600EFD  eckes@irc  +4972573817  *plush*
(O____O)       If privacy is outlawed only Outlaws have privacy

home help back first fref pref prev next nref lref last post