Date: Thu, 30 Oct 1997 12:48:33 -0800 (PST) From: sameer <sameer@c2.net> To: freebsd-hackers@freebsd.org Subject: Whee, PPP over TCP working Message-ID: <199710302048.MAA15533@gabber.c2.net>
next in thread | raw e-mail | index | archive | help
So I didn't see anything in the archives about how to get PPP over TCP working, so I figured it out myself. =) Here's how to do it.. hopefully someone can integrate this into the docs, etc. On the client, edit ppp.conf as follows: ppptcp: set device remotehost:1324 set dial "" set ifaddr 10.1.1.1 10.1.1.2 On the server, edit ppp.conf as follows: tcpserver: set ifaddr 10.1.1.2 10.1.1.1 If you want to use PAP/CHAP, whatever, then you should add appropriate configuration for PAP/CHAP. On the server, you need to plug the ppp user-land program onto a port. I wrote the following program to do that -- it has zero error-checking, it probably leaks fd's left and right, and it could be improved to do a login/password thing... there's a lot you can do to improve it, but I didn't have the time, I just wanted to put together a proof of concept. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> int main(void) { int s = socket(PF_INET, SOCK_STREAM, 0); int a; struct sockaddr_in addr; addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_port = htons(1324); addr.sin_family = AF_INET; bind(s, (struct sockaddr *) &addr, sizeof(addr)); listen(s, 15); while(1) { struct sockaddr_in remote; int size; a = accept(s, (struct sockaddr *) &remote, &size); /* Fork the subprocess to do proxying */ if(!fork()) { char *message = "PPP/TCP Server Connected\n"; /* Spit out some stuff to the client to know we're connected */ write(a, message, strlen(message)); /* Dup some fd's and run ppp -direct */ dup2(a, STDOUT_FILENO); dup2(a, STDIN_FILENO); close(a); execl("/usr/sbin/ppp", "ppp", "-direct", "tcpserver", NULL); } } } So then on the server, you just run > ./ppp-tcp Then on the client you can run > ppp ppptcp User Process PPP. Written by Toshiharu OHNO. Log level is 09 can't open /etc/ppp/ppp.secret. Warning: No password entry for this host in ppp.secret Warning: All manipulation is allowed by anyone in the world Using interface: tun0 Interactive mode ppp ON gabber> dial Dial attempt 1 dial OK! login OK! ppp ON gabber> Packet mode. ppp ON gabber> PPP ON gabber> On the server you'll end up seeing: {0} lachesis:sameer/ppp-tcp 12:46pm [14] > ./ppp-tcp Log level is 281 can't open /etc/ppp/ppp.secret. Warning: No password entry for this host in ppp.secret Warning: All manipulation is allowed by anyone in the world then you'll be all set. You can ping, etc. -- Sameer Parekh Voice: 510-986-8770 President FAX: 510-986-8777 C2Net http://www.c2.net/ sameer@c2.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710302048.MAA15533>