Date: Fri, 12 Jan 2001 17:39:03 -0800 (PST) From: Luigi Rizzo <rizzo@aciri.org> To: lab@gta.com (Larry Baird) Cc: freebsd-net@FreeBSD.ORG Subject: Re: Strange source address problem Message-ID: <200101130139.f0D1d3a79644@iguana.aciri.org> In-Reply-To: <3A5F4820.634D626B@gta.com> from Larry Baird at "Jan 12, 2001 1: 8:32 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
a simplified setup to show the problem larry is experiencing is the following. Say you have a machine with address X.A and want to change it to X.B (same subnet), the router is X.C At boot you have something like ifconfig xl0 X.A route add default X.C now do a ping somehost and packets go out with a SrcIP = X.A Now do ifconfig xl0 X.B # change to new address ping somehost and packets still go out with SrcIP = X.A , which is wrong (with TCPdump you even see a reply coming in as the outside world even knows the correct MAC address, but the packet is then discarded because it fails to match any local IP). This is cured by doing a route delete default route add default X.C ping somehost at which point packets go out with the correct SrcIP = X.B (and now if you change back to X.A, you need to change the route to make the packets use the correct address). There must be something wrong in the routing table which is not deleted when the interface address changes. Problem is, it is not shown by netstat -nra -- so where should i look ? cheers luigi > [at boot:] > ifconfig xl0 192.150.187.36 netmask 0xffffff80 > route add default 192.150.187.1 > > ping x.y.z.t -> pkts go out with srcIP=92.150.187.36 > > ifconfig xl0 192.150.187.64 netmask 0xffffff80 > > ping x.y.z.t -> pkts still go out with srcIP=92.150.187.36 (wrong) > > route delete default; > route add default 192.150.187.1 > > ping x.y.z.t -> pkts now go out with srcIP=92.150.187.64 (right) > 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: lab@gta.com | 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 ); > } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101130139.f0D1d3a79644>