From owner-freebsd-questions Tue Jul 18 12:26:40 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mojo.virtualservice.com (mojo.virtualservice.com [207.164.49.28]) by hub.freebsd.org (Postfix) with ESMTP id AA76D37BBFD for ; Tue, 18 Jul 2000 12:26:35 -0700 (PDT) (envelope-from matt@virtualservice.com) Received: from virtualservice.com (procyon.wiredsolutions.com [207.164.49.241]) by mojo.virtualservice.com (8.9.1a/8.9.1) with ESMTP id PAA12432; Tue, 18 Jul 2000 15:21:51 -0400 (EDT) Message-ID: <3974B13A.430C7298@virtualservice.com> Date: Tue, 18 Jul 2000 15:34:18 -0400 From: Matt Gostick X-Mailer: Mozilla 4.73 [en] (X11; I; FreeBSD 4.0-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: Drew Sanford , questions@freebsd.org Subject: Re: Mailing IP changes References: <3974A0A5.F4632A9A@planetwe.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I wrote a C program a while ago that retrieved the ip of the tun device. I quoted it below. When compiled just run it with `get_ip tun0` or whatever your tun device is. It doesn't work for normal interfaces.. I'm not quite sure why... but it does what I need it to and I left it at that :) To get it to mail you ... I believe a file in /etc/ppp can contain a list scripts that you want run when a connection is established. Just change the print below to a system call to sendmail or whatever and pop it in there. `man ppp` to find out what the file is called. I think ppp.linkup or something like that. Good luck. #include #include #include #include #include #include int main (int argc, char **argv) { int sock_fd; struct ifreq ifr; struct in_addr ip; /* open a socket for the ioctl calls */ if ((sock_fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { perror("socket"); return -1; } /* make the ioctl calls */ strcpy(ifr.ifr_name, argv[1]); if (ioctl(sock_fd, SIOCGIFADDR, &ifr) == -1) { perror("ioctl(SIOCGIFADDR)"); return -1; } ip = (struct in_addr) (((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr); if (ioctl(sock_fd, SIOCGIFDSTADDR, &ifr) == -1) { perror("ioctl(SIOCGIFDSTADDR)"); return -1; } /* close the socket */ close(sock_fd); /* print the ip address */ printf("%s\n", inet_ntoa(ip)); /* success */ return 0; } Drew Sanford wrote: > > Hi, > I'd like to know if anyone has a good way of emailing a machines IP > address to themselves when the machine (connected via PPP) has to > reconnect and is assigned a new IP. What is the most sensible way to do > this? > > -- > Drew Sanford > Systems Administrator > Planetwe.com > Email: drew@planetwe.com > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message -- Matt Gostick To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message