# Miraculously assigned ip



## wiesel (Jun 4, 2019)

I'm about to configure a small jails setup with pf. Therefore, I cloned my network interface (see rc.conf below).
If I ping the cloned interfaces (and the physical) by their IPs, everything works as expected. However, when pinging the interfaces themselves, they return some strange IP address:


`root@myserver:~ # ping em0
PING em0.net (192.64.119.246): 56 data bytes
64 bytes from 192.64.119.246: icmp_seq=0 ttl=50 time=159.379 ms`

`root@myserver:~ # ping l01
PING l01.net (23.82.25.203): 56 data bytes
64 bytes from 23.82.25.203: icmp_seq=0 ttl=114 time=142.402 ms`

`root@myserver:~ #ping l02
PING l02.net (158.69.184.138): 56 data bytes
64 bytes from 158.69.184.138: icmp_seq=0 ttl=58 time=81.481 ms`

How are these IPs assigned and what to they mean?

/etc/rc.conf:
zfs_enable="YES"


```
# Network configuration (IPv4)
ifconfig_em0="inet 37.xxx.xx.xx netmask 255.255.255.0 broadcast 37.xxx.xx.255"
defaultrouter="37.xxx.xx.254"

cloned_interfaces="lo1 lo2"

ifconfig_lo1="inet 192.168.1.2 netmask 255.255.255.0"
ifconfig_lo2="inet 192.168.1.3 netmask 255.255.255.0"
gateway_enable="YES"

ezjail_enable="YES"
syslogd_flags="-s -s"

# Various options
dumpdev="AUTO"
clear_tmp_enable="YES"
accounting_enable="YES"

# Daemons
ntpd_enable="YES"
sshd_enable="YES"
local_unbound_enable="YES"

hostname="myhostname.net"
```


----------



## SirDice (Jun 4, 2019)

You're not pinging interfaces, you're pinging host names. Short names that get resolved based on the domain or search in /etc/resolv.conf.


```
% drill em0.net
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 37593
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;; em0.net.     IN      A

;; ANSWER SECTION:
em0.net.        1800    IN      A       192.64.119.246

;; AUTHORITY SECTION:
em0.net.        1800    IN      NS      dns2.registrar-servers.com.
em0.net.        1800    IN      NS      dns1.registrar-servers.com.

;; ADDITIONAL SECTION:
dns1.registrar-servers.com.     109261  IN      A       216.87.155.33
dns2.registrar-servers.com.     103004  IN      A       216.87.152.33

;; Query time: 96 msec
;; SERVER: 2001:470:1f15:bcd::1
;; WHEN: Tue Jun  4 16:41:36 2019
;; MSG SIZE  rcvd: 132
```


----------



## wiesel (Jun 4, 2019)

OMG  that was spectacularly stupid of me. Thank's for clarification.


----------



## SirDice (Jun 4, 2019)

No worries, you just happened to stumble into something that actually resolved. I was somewhat surprised by that too.


----------



## malavon (Jun 4, 2019)

Something tells me that the DNS server you're using does something strange. If you look at the output, your interface names are resolved to em0.net etc.
I tried the same here on my end and don't get any response, nor any automatic resolution from em0 to em0.net. I need to explicitly `ping em0.net`.

If you're using your provider's DNS server, so be it I guess. If it's your own, you might want to look into this.


----------



## SirDice (Jun 4, 2019)

malavon said:


> If you look at the output, your interface names are resolved to em0.net etc.


They're not interface names. The argument to ping(8) is a hostname, not an interface. It's just a big coincidence em0.net, lo1.net and lo0.net are actual existing domains that resolve to real IP addresses.



malavon said:


> I need to explicitly  ping em0.net.


Your hostname is in a different TLD. Which is why you need to explicitly had to add .net. If you look closely at the OP's hostname you'll see his ends in .net. Basic DNS search algorithms did the rest (short name + domain of host).


----------



## malavon (Jun 4, 2019)

SirDice said:


> They're not interface names. The argument to ping(8) is a hostname, not an interface. It's just a big coincidence em0.net, lo1.net and lo0.net are actual existing domains that resolve to real IP addresses.


It's basically what I was trying to say, I should have added quotes around "interface names"


SirDice said:


> Your hostname is in a different TLD. Which is why you need to explicitly had to add .net. If you look closely at the OP's hostname you'll see his ends in .net. Basic DNS search algorithms did the rest (short name + domain of host).


Yes of course, I completely missed that. One line, with big consequences.


----------

