Hopefully somebody can shed some light in helping me to understand something I am seeing on a 4.2 box. I am experimenting with a daemon that implements something very close to the VRRP (Virtual Router Redundancy Protocol). The VRRP portion of the daemon works correctly. The problem I am having has to do with the source IP address after a host has transitioned from "slave" to "master" mode. The problem can be illustrated on a standard 4.2 system not running the VRRP daemon by the following command line actions: Script started on Fri Jan 12 12:42:35 2001 sukebe# ifconfig xl0 inet 192.168.23.85 sukebe# sukebe# ifconfig xl0 xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet6 fe80::260:8ff:feaf:2bf5%xl0 prefixlen 64 scopeid 0x1 inet 192.168.23.85 netmask 0xffffff00 broadcast 192.168.23.255 ether 00:60:08:af:2b:f5 media: autoselect (none) status: no carrier supported media: autoselect 100baseTX <full-duplex> 100baseTX 10baseT/UTP <full-duplex> 10baseT/UTP 100baseTX <hw-loopback> sukebe# sukebe# ./getLocalIP 192.168.23.90 local = 192.168.23.85:1178 sukebe# sukebe# ifconfig xl0 inet 192.168.23.86 sukebe# sukebe# ifconfig xl0 xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet6 fe80::260:8ff:feaf:2bf5%xl0 prefixlen 64 scopeid 0x1 inet 192.168.23.86 netmask 0xffffff00 broadcast 192.168.23.255 ether 00:60:08:af:2b:f5 media: autoselect (none) status: no carrier supported media: autoselect 100baseTX <full-duplex> 100baseTX 10baseT/UTP <full-duplex> 10baseT/UTP 100baseTX <hw-loopback> sukebe# sukebe# ./getLocalIP 192.168.23.90 local = 192.168.23.85:1179 ^^^^ why is 192.168.23.85 still showing up?? This address should be gone. sukebe# sukebe# exit Script done on Fri Jan 12 12:44:35 2001 I have attached the source code to the getLocalIP program. Can anybody explain this? Thanks in advance for your help. -- ------------------------------------------------------------------------ Larry Baird Global Technology Associates, Inc. | Orlando, FL Email: [EMAIL PROTECTED] | TEL 407-380-0220, FAX 407-380-6080
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int main(int argc, char *argv[]) { int s; if ( argc != 2 ) fprintf( stderr, "USAGE: %s destIP[:port]\n", argv[0] ); else { if ( (s = socket( PF_INET, SOCK_DGRAM, 0 )) < 0 ) perror( "Unable to create socket" ); else { struct sockaddr_in servAddr; short port = 7; char *p; if ((p = strchr(argv[1], ':')) != NULL) { port = atoi(p + 1); *p = 0; } bzero(&servAddr, sizeof(servAddr)); servAddr.sin_family = AF_INET; servAddr.sin_port = htons( port ); if ( ! inet_aton( argv[1], &servAddr.sin_addr ) ) fprintf( stderr, "IP address invalid.\n" ); else { if ( connect( s, (struct sockaddr *)&servAddr, sizeof(servAddr) ) ) perror( "connect() failed" ); else { struct sockaddr_in local; int local_len = sizeof(local); if ( getsockname( s, (struct sockaddr *)&local, &local_len)) perror( "getsockname() failed" ); else { printf( "local = %s:%d\n", inet_ntoa(local.sin_addr), ntohs(local.sin_port)); exit( 0 ); } } } close(s); } } exit( 1 ); }