[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Exim and IPv6 Help
On Thu, 12 Jul 2001 10:23:51 +0100, Philip Hazel wrote:
> Please go ahead and try. Whether or not it is the long-term solution, we
> need to know whether an IPv6 socket can be made to listen to an
> IPv6-mapped IPv4 address.
Weird stuff abounds. :-)
I've just double-checked, and Exim's definitely binding to the
wildcard address in such a way as to accept both IPv4 and IPv6
connections.
Note, however, that I have the system tunable (sysctl)
net.inet6.ip6.v6only set to 0.
FreeBSD's ip6(4) manual page (which I understand comes from the KAME
project) says this:
int on = 1;
setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
If set to 1, AF_INET6 wildcard listening socket will accept IPv6 traffic
only. If set to 0, it will accept IPv4 traffic as well, as if it was
from IPv4 mapped address like ::ffff:10.1.1.1. Note that if you set it
this to 0, IPv4 access control gets much more complicated. For example,
even if you have no listening AF_INET listening socket on port X, you
will end up accepting IPv4 traffic by AF_INET6 listening socket on the
same port. The default value for this flag is copied at socket instanti-
ation time, from net.inet6.ip6.v6only sysctl(3) variable. The option
affects TCP and UDP sockets only.
Kevin, when you run this small program on your OpenBSD box, do you get
immediate "Connection refused" when trying to connect to port 2525, or
does telnet "hang in waiting"? If the former, then can you look at your
ip6(4) manual page and see if it mentions anything surrounding the
IPV6_V6ONLY socket option?
Ciao,
Sheldon.
#include <sys/types.h>
#include <sys/socket.h>
#include <err.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#define TESTPORT (2525)
int
main(void)
{
struct sockaddr_in6 lsin;
int s;
if ((s = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
err(EXIT_FAILURE, "creating AF_INET6 socket:");
memset(&lsin, 0, sizeof(lsin));
lsin.sin6_family = AF_INET6;
lsin.sin6_port = htons(TESTPORT);
if (bind(s, (struct sockaddr *)&lsin, sizeof(lsin)) < 0)
err(EXIT_FAILURE, "binding to port %d:", TESTPORT);
/*
* Sleep while the operator checks the output of sockstat(1)
* or tries a few connection attempts (which won't be accepted
* but which should not be refused).
*/
while (1)
sleep(1);
/* NOTREACHED */
exit(EXIT_SUCCESS);
}