From 16e1b731f69284b0c9992ac755f9278de4cdd5cc Mon Sep 17 00:00:00 2001 From: Chris Hellberg Date: Tue, 28 Dec 2021 03:14:05 +0000 Subject: [PATCH] Linux server interfaces populated with V6 addresses --- src/iodine.c | 2 +- src/iodined.c | 16 +++++++++++----- src/tun.c | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/iodine.c b/src/iodine.c index 3f81495..2059779 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -372,7 +372,7 @@ int main(int argc, char **argv) fprintf(stderr, "Sending DNS queries for %s to %s\n", topdomain, format_addr(&nameservaddr, nameservaddr_len)); - if (client_handshake(dns_fd, raw_mode, autodetect_frag_size, max_downstream_frag_size)) { + if (client_handshake(dns_fd, raw_mode, autodetect_frag_size, max_downstream_frag_size, forward_v6)) { retval = 1; goto cleanup2; } diff --git a/src/iodined.c b/src/iodined.c index ff405a5..0a02632 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -2437,7 +2437,7 @@ main(int argc, char **argv) srand(time(NULL)); fw_query_init(); - while ((choice = getopt(argc, argv, "46vcsfhDu:t:d:m:l:L:p:n:b:P:z:F:i:")) != -1) { + while ((choice = getopt(argc, argv, "46vcsfhDuS:t:d:m:l:L:p:n:b:P:z:F:i:")) != -1) { switch(choice) { case '4': addrfamily = AF_INET; @@ -2678,11 +2678,17 @@ main(int argc, char **argv) } if (!skipipconfig) { const char *other_ip = users_get_first_ip(); - if (tun_setip(argv[0], other_ip, netmask, forward_v6) != 0 || tun_setmtu(mtu) != 0) { - retval = 1; + if (tun_setip(argv[0], other_ip, netmask, forward_v6) || tun_setmtu(mtu) != 0) { + retval = 1; free((void*) other_ip); - goto cleanup; - } + goto cleanup; + + } + if ((mtu < 1280) && (forward_v6)) { + warnx("Interface mtu of %d below the 1280 threshold needed for IPv6 tunneling.\n", mtu); + warnx("Proceeding without IPv6 tunneling\n"); + } + free((void*) other_ip); } diff --git a/src/tun.c b/src/tun.c index 804fad7..7c20404 100644 --- a/src/tun.c +++ b/src/tun.c @@ -595,9 +595,11 @@ int tun_setip(const char *ip, const char *other_ip, int netbits, int forward_v6) { char cmdline[512]; + char v6_cmdline[512]; int netmask; struct in_addr net; int i; + int v6_r; #ifndef LINUX int r; #endif @@ -630,6 +632,18 @@ tun_setip(const char *ip, const char *other_ip, int netbits, int forward_v6) # else display_ip = ip; # endif + fprintf(stderr, "Setting IPv6 of %s to ::%s\n", if_name, ip); + + snprintf(v6_cmdline, sizeof(cmdline), + IFCONFIGPATH "ifconfig %s inet6 add ::%s/64", + if_name, + display_ip); + + v6_r = system(v6_cmdline); + + if (v6_r != 0) { + return v6_r; + } snprintf(cmdline, sizeof(cmdline), IFCONFIGPATH "ifconfig %s %s %s netmask %s", if_name,