summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2016-03-31 20:35:02 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2016-03-31 20:35:02 +0200
commit137533bd69847030d716658e1772c6320f9282bb (patch)
tree10ec546011363c1e31bec733d091dd00bd1b4faf /sys
parenteed13a5c22662fe4c77b8587e7a53c9b1ae96acb (diff)
6in4: allow setting the local IPv4 address with -i flag (thanks k0ga)
Diffstat (limited to 'sys')
-rw-r--r--sys/man/8/6in49
-rw-r--r--sys/src/cmd/ip/6in4.c7
2 files changed, 14 insertions, 2 deletions
diff --git a/sys/man/8/6in4 b/sys/man/8/6in4
index 004beac2b..6e44d2a96 100644
--- a/sys/man/8/6in4
+++ b/sys/man/8/6in4
@@ -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
diff --git a/sys/src/cmd/ip/6in4.c b/sys/src/cmd/ip/6in4.c
index 3d3759af4..ae591a607 100644
--- a/sys/src/cmd/ip/6in4.c
+++ b/sys/src/cmd/ip/6in4.c
@@ -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);