You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* optionally configured services, for example NetBIOS/LLMNR/WINS
147
178
179
+
If multiple addresses available, it uses a [prefix policy table](https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-ipv6-in-windows)
180
+
and dynamically adjusts preference based on interface reachability and past success.
@@ -1160,21 +1196,51 @@ The server then decides whether to gzip the returned payload, which is uncompres
1160
1196
Where `x` is an IP address as an int atom, returns its hostname as a symbol atom.
1161
1197
1162
1198
```q
1163
-
q).Q.host .Q.addr`localhost
1199
+
q).Q.host 2130706433i
1164
1200
`localhost
1165
-
q).Q.addr`localhost
1166
-
2130706433i
1201
+
```
1167
1202
1203
+
The operator [`$`](tok.md#ip-address) (tok) can be used to convert an IP address in dotted-decimal string representation to an integer
1204
+
```q
1168
1205
q)"I"$"104.130.139.23"
1169
1206
1753385751i
1170
1207
q).Q.host "I"$"104.130.139.23"
1171
1208
`netbox.com
1172
-
q).Q.addr `netbox.com
1173
-
1753385751i
1209
+
```
1210
+
1211
+
Each underlying operating system deals with resolving a hostname to IP (and vice-versa) in different ways, reference [`.Q.addr`](#addr-iphost-as-int) for details.
1212
+
1213
+
When the resolving leads to consulting a DNS server, the DNS server can also have rules on which IP (or the sort order of IPs) it can return when multiple IPs associated with one host.
1214
+
Therefore performing an IP lookup from a given hostname, then using the resuling IP to get its hostname, can return a different hostname.
1215
+
For example:
1216
+
1217
+
```q
1218
+
q).Q.host .Q.addr `$"www.yahoo.co.uk"
1219
+
`a7de0457831fd11f7.awsglobalaccelerator.com / alternative hostname for IP
1220
+
```
1221
+
1222
+
When using `/etc/hosts` on MacOS/Linux, the order in which multiple hosts are associated with an IP will effect the value returned.
1223
+
For example, `/etc/hosts` with the entry
1224
+
```bash
1225
+
172.17.0.4 test1 test2
1226
+
```
1227
+
will cause 172.17.0.4 to be resolved to test1
1228
+
```q
1229
+
q).Q.host "I"$"172.17.0.4"
1230
+
`test1
1231
+
```
1232
+
but `/etc/hosts` with the machine names in a different order
1233
+
```bash
1234
+
172.17.0.4 test2 test1
1235
+
```
1236
+
will cause 172.17.0.4 to be resolved to test2
1237
+
```q
1238
+
q).Q.host "I"$"172.17.0.4"
1239
+
`test2
1174
1240
```
1175
1241
1176
1242
:fontawesome-regular-hand-point-right:
1177
-
[`.Q.addr`](#addr-iphost-as-int) (IP/host as int), [`$`](tok.md#ip-address)tok (IP address as int)
1243
+
[`.Q.addr`](#addr-iphost-as-int) (IP/host as int), [`.z.h`](dotz.md#zh-host) (host), [`.z.a`](dotz.md#za-ip-address) (IP address)
Copy file name to clipboardExpand all lines: docs/ref/dotz.md
+45-52Lines changed: 45 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,39 +77,39 @@ q).z.a
77
77
-1408172030i
78
78
```
79
79
80
-
Note its relationship to [`.z.h`](#zh-host) for the hostname, converted to an int using [`.Q.addr`](dotq.md#host-ip-to-hostname).
81
-
```q
82
-
q).Q.addr .z.h
83
-
-1408172030i
84
-
```
85
-
86
-
It can be split into components as follows:
87
-
88
-
```q
89
-
q)"i"$0x0 vs .z.a
90
-
172 17 0 2i
91
-
```
92
-
93
-
When invoked inside a `.z.p*` callback via a TCP/IP connection, it is the IP address of the client session, not the current session. For example, connecting from a remote machine:
94
-
95
-
```q
96
-
q)h:hopen myhost:1234
97
-
q)h"\"i\"$0x0 vs .z.a"
98
-
192 168 65 1i
99
-
```
100
-
or from same machine:
101
-
```q
102
-
q)h:hopen 1234
103
-
q)h"\"i\"$0x0 vs .z.a"
104
-
127 0 0 1i
105
-
```
106
-
107
-
When invoked via a Unix Domain Socket, it is 0.
108
-
```q
109
-
q)h:hopen `:unix://1234
110
-
q)h".z.a"
111
-
0i
112
-
```
80
+
The dotted-decimal string representation can be obtained from an integer using [`vs`](vs.md#integer-based-ip-address).
81
+
82
+
The return value depends on whether it is invoked in an IPC callback or not.
83
+
84
+
***Not invoking in an IPC callback**
85
+
<br>Returns the current IP address associated with the hostname.
86
+
<br>This pre-populated value is equivalent to passing [`.z.h`](#zh-host) to [`.Q.addr`](dotq.md#host-ip-to-hostname) to find the IP address of the current host.
87
+
```q
88
+
q).z.a
89
+
-1408172030i
90
+
q).Q.addr .z.h
91
+
-1408172030i
92
+
```
93
+
***Invoking in an IPC callback**
94
+
<br>When invoked inside a `.z.p*` callback via a TCP/IP connection, it is the IP address of the client session, not the current session.
95
+
For example, connecting from a remote machine:
96
+
```q
97
+
q)h:hopen myhost:1234
98
+
q)h"\"i\"$0x0 vs .z.a"
99
+
192 168 65 1i
100
+
```
101
+
or from same machine:
102
+
```q
103
+
q)h:hopen 1234
104
+
q)h"\"i\"$0x0 vs .z.a"
105
+
127 0 0 1i
106
+
```
107
+
When invoked via a Unix Domain Socket, it is 0.
108
+
```q
109
+
q)h:hopen `:unix://1234
110
+
q)h".z.a"
111
+
0i
112
+
```
113
113
114
114
:fontawesome-solid-hand-point-right:
115
115
[`.z.h`](#zh-host) (host), [`.Q.host`](dotq.md#host-ip-to-hostname) (IP to hostname)
@@ -351,33 +351,26 @@ q).z.h
351
351
`demo.kx.com
352
352
```
353
353
354
-
On Linux this should return the same as the shell command `hostname`. If you require a fully qualified domain name, and the `hostname`command returns a hostname only (with no domain name), this should be resolved by your system administrators. Often this can be traced to the ordering of entries in `/etc/hosts`, e.g.
354
+
If you require a fully qualified domain name, and the command returns a hostname only (with no domain name), this should be resolved by your system administrators.
355
355
356
-
Non-working `/etc/host` looks like :
356
+
**Linux**
357
357
358
-
```txt
359
-
127.0.0.1 localhost.localdomain localhost
360
-
192.168.1.1 myhost.mydomain.com myhost
361
-
```
358
+
On Linux this should return the same value as the shell command `hostname`.
359
+
Linux stores the current hostname in `/proc/sys/kernel/hostname`. The operating system reads the hostname from `/etc/hostname`.
362
360
363
-
Working one has this ordering :
361
+
**MacOS**
364
362
365
-
```txt
366
-
127.0.0.1 localhost.localdomain localhost
367
-
192.168.1.1 myhost myhost.mydomain.com
368
-
```
363
+
On MacOS this should return the same value as `sysctl kern.hostname` or `scutil --get HostName`.
369
364
370
-
One solution seems to be to flip around the entries, i.e. so the entries should be
365
+
**Microsoft Windows**
371
366
372
-
```txt
373
-
ip hostname fqdn
367
+
On Windows this should return the same value as `hostname` via cmd.exe or Powershell,
368
+
which typically gets the hostname from the registry entry `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName`.
369
+
The `req query` command can be used to retrieve the current value.
0 commit comments