6in4: allow setting the local IPv4 address with -i flag (thanks k0ga)

This commit is contained in:
cinap_lenrek 2016-03-31 20:35:02 +02:00
parent eed13a5c22
commit 137533bd69
2 changed files with 14 additions and 2 deletions

View file

@ -11,6 +11,9 @@
] [
.B -o
.I outnetmtpt
] [
.B -i
.I local4
] [
.IB local6 [ /mask ]
[
@ -92,6 +95,12 @@ for
permit any remote IPv4 address as the far end of a tunnel.
This is likely to be useful for the server side of a tunnel.
.TP
.B -i
for
.IR 6in4 ,
define what is the local IPv4 address, otherwise it takes the first
non-loopback address of the outside IP stack.
.TP
.B -g
use the tunnel as the default route for global IPv6 addresses
.TP

View file

@ -71,7 +71,7 @@ static void tunnel2ip(int, int);
static void
usage(void)
{
fprint(2, "usage: %s [-ag] [-x mtpt] [-o mtpt] [local6[/mask]] [remote4 [remote6]]\n",
fprint(2, "usage: %s [-ag] [-x mtpt] [-o mtpt] [-i local4] [local6[/mask]] [remote4 [remote6]]\n",
argv0);
exits("Usage");
}
@ -261,11 +261,14 @@ main(int argc, char **argv)
case 'o':
outside = EARGF(usage());
break;
case 'i':
parseip(myip, EARGF(usage()));
break;
default:
usage();
} ARGEND
if (myipaddr(myip, outside) < 0)
if (ipcmp(myip, IPnoaddr) == 0 && myipaddr(myip, outside) < 0)
sysfatal("can't find my ipv4 address on %s", outside);
if (!isv4(myip))
sysfatal("my ip, %I, is not a v4 address", myip);