how does "ipfw fordward' work?
how does "ipfw fordward' work?
- Subject: how does "ipfw fordward' work?
- From: James J <email@hidden>
- Date: Tue, 06 Mar 2012 00:06:29 +0200
Hello
I have created an ipfw rule:
00100 fwd 127.0.0.1,8080 tcp from any to any proto ip dst-port 80
And have written a simple application, that would accept connections
on the 8080 port and receive data from it:
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main() {
int servsock = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in saddr, claddr;
memset(&saddr, 0, sizeof(struct sockaddr_in));
memset(&claddr, 0, sizeof(struct sockaddr_in));
saddr.sin_addr.s_addr = INADDR_ANY;
saddr.sin_family = AF_INET;
saddr.sin_port = htons(8080);
size_t saddrlen = sizeof(struct sockaddr_in), claddrlen =
sizeof(struct sockaddr_in);
bind(servsock, (struct sockaddr*)&saddr, saddrlen);
listen(servsock, 0);
int clsock = accept(servsock, (struct sockaddr*)&claddr, &claddrlen);
printf("Accepted\n");
char buf[1000];
int nread;
while(nread = read(clsock, buf, sizeof(buf))) {
printf("read %d bytes:\n",nread);
int i;
for(i=0; i<nread; i++)
putchar(buf[i]);
}
}
When I enter that ipfw rule, all the HTTP traffic stops (I can't use
my browser for example), but I do not get anything in my application,
where this traffic is supposed to be forwarded to.
In this ipfw rule I had tried specifying "tcp" instead of "ip", but
that didn't change anything - the application still "hangs" on the
accept function, receving no data and accepting no connections..
What am I doing wrong?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden