Skip to content

Commit 64218b7

Browse files
committed
docs: Use udp to find preferred outbound ip address
- The previous macOS instructions were just as bad as the Linux instructions that were updated in 5cce5fe - Using socket+connect+getsockname matches how the real world behaves in a much more portable fashion - Include a hint about what a good ip address might look like for the alternative case Signed-off-by: Josh Soref <[email protected]>
1 parent 2f9bea6 commit 64218b7

1 file changed

Lines changed: 22 additions & 24 deletions

File tree

docs/developer-guide/toolchain-guide.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,28 @@ The configuration you will need for Argo CD virtualized toolchain:
6464

6565
1. For most users, the following command works to find the host IP address.
6666

67-
* For Mac:
68-
69-
```
70-
IP=`ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}'`
71-
echo $IP
72-
```
73-
74-
* For Windows:
75-
76-
Run the following command and look for the IP address of your active network adapter:
77-
78-
```
79-
ipconfig
80-
```
81-
82-
* For Linux:
83-
84-
```
85-
IP=$(hostname -I | awk '{print $1}')
86-
echo $IP
87-
```
88-
89-
> Note:
90-
> If you are using a VPN or running Docker, multiple IP addresses may be returned and the first address may not correspond to your primary network. In such cases, run `hostname -I` and select the IP associated with the network you want to expose.
67+
* If you have perl
68+
69+
```pl
70+
perl -e '
71+
use strict;
72+
use Socket;
73+
74+
my $target = sockaddr_in(53, inet_aton("8.8.8.8"));
75+
socket(my $s, AF_INET, SOCK_DGRAM, getprotobyname("udp")) or die $!;
76+
connect($s, $target) or die $!;
77+
my $local_addr = getsockname($s) or die $!;
78+
my (undef, $ip) = sockaddr_in($local_addr);
79+
print "IP: ", inet_ntoa($ip), "\n";
80+
'
81+
```
82+
83+
* If you don't
84+
85+
* Try `ip route get 8.8.8.8` on Linux
86+
* Try `ifconfig`/`ipconfig` (and pick the ip address that feels right -- look for `192.168.x.x` or `10.x.x.x` addresses)
87+
88+
Note that `8.8.8.8` is Google's Public DNS server, in most places it's likely to be accessible and thus is a good proxy for "which outbound address would my computer use", but you can replace it with a different IP address if necessary.
9189
9290
Keep in mind that this IP is dynamically assigned by the router so if your router restarts for any reason, your IP might change.
9391

0 commit comments

Comments
 (0)