Date: Tue, 12 Feb 2019 19:04:52 -0800 (PST) From: "Rodney W. Grimes" <freebsd-rwg@pdx.rh.CN85.dnsmgr.net> To: Rick Macklem <rmacklem@uoguelph.ca> Cc: "Bjoern A. Zeeb" <bz@freebsd.org>, "freebsd-current@FreeBSD.org" <freebsd-current@freebsd.org> Subject: Re: what do jails map 127.0.0.1 to? Message-ID: <201902130304.x1D34qvI079431@pdx.rh.CN85.dnsmgr.net> In-Reply-To: <QB1PR01MB353764CC569FA17BC08B5A2FDD660@QB1PR01MB3537.CANPRD01.PROD.OUTLOOK.COM>
next in thread | previous in thread | raw e-mail | index | archive | help
[ Charset windows-1252 unsupported, converting... ]
> Bjoern A. Zeeb wrote:
> [good stuff snipped]
> >Yes, could do easily but wouldn?t work for my above case, would it? I
> >can help you with the code for v4 and jails if you help me with the code
> >for IPv6?
> Well, not quite what you volunteered to do, but can you fill in the INET6 code
> for this code snippet? (It does what Alan suggested for INET.)
>
>
> /*
> * Find out what IP# localhost maps to and whether or not use of
> * INET6 is required. Jails will map 127.0.0.1 to another INET
> * address.
> */
> use_inet6 = 0;
> s = socket(PF_INET, SOCK_DGRAM, 0);
> if (s < 0) {
> use_inet6 = 1;
> s = socket(PF_INET6, SOCK_DGRAM, 0);
> }
> if (s < 0)
> err(1, "Can't create a inet/inet6 socket");
> if (use_inet6 != 0) {
> ; /* Needs code... */
> } else {
> memset(&sad, 0, sizeof(sad));
> sad.sin_len = sizeof(sad);
> sad.sin_family = AF_INET;
> sad.sin_addr.s_addr = inet_addr("127.0.0.1");
> sad.sin_port = 0;
> ret = bind(s, (struct sockaddr *)&sad, sizeof(sad));
> if (ret > 0)
> err(1, "Can't bind 127.0.0.1");
> memset(&sad, 0, sizeof(sad));
> slen = sizeof(sad);
> ret = getsockname(s, (struct sockaddr *)&sad, &slen);
> if (ret < 0)
> err(1, "Can't get bound sockaddr");
> printf("locaddr: %s\n", inet_ntoa(sad.sin_addr));
> }
>
> If the IPv4 code isn't sufficient, please let me know. (I think I know how to make
> the RPC code use IPv6, but I need to know what IPv6 address to use. I get confused
> by link local/site local/? It needs to be an address that is "this machine".
ipv4 127.0.0.1 == ipv6 ::1, see /etc/hosts
>
> Thanks for your help with this, rick
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
>
>
--
Rod Grimes rgrimes@freebsd.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902130304.x1D34qvI079431>
