Reverse DNS and PTR records on Cloudflare - pointers

I have server with a mail service running at domain o1.danilocarneiro.com. I use Cloudflare as DNS, so I have configured an A record on cloud flare to 152.67.52.238. This is actually the IP of the server.
The problem is because while running mail-tester.com check it warns about Reverse DNS and recommends to add PTR record. My first question is where should I add this record, I guess it's in Cloudflare but I'm really not an expert on DNS and network subjects.
Cloudflare PTR record
I'd like to know how to create this record, I have tried a record with: Name: o1.danilocarneiro.com. Domain name: 238.52.67.152-in-addr-arpa. It doesn't work.
I also tried. Name: 152.67.52.238. Domain name: o1.danilocarneiro.com. It also doesn't work. Mail-teser and other checkers like mxtoolbox.com keeps saying PTR record not found.
Could anyone please explain to me or demonstrate how to create a valid PTR record for my mail server (o1.danilocarneiro.com -> 152.67.52.238)
Thank you so much!

At Cloudflare in your DNS zone for danilocarneiro.com
Go to create a PTR record as following:
Type Name Domain Name TTL
PTR o1 238.52.67.152.in-addr.arpa auto(suggested)
By doing this you should see.
; <<>> DiG 9.10.6 <<>> PTR 238.52.67.152.in-addr.arpa
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62521
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;238.52.67.152.in-addr.arpa IN PTR
;; ANSWER SECTION:
238.52.67.152.in-addr.arpa 85728 IN PTR o1.danilocarneiro.com.
;; Query time: 29 msec
;; SERVER: XXX.XXX.XXX.XXX#53(XXX.XXX.XXX.XXX)
;; WHEN: Tue Aug 25 10:11:51 2020
;; MSG SIZE rcvd: 90
Remember allow up yo 72 hrs in order for dns to propagate, but with cloudflare can be almost instantly.

Related

Sending Bittorrent HTTP request to Ubuntu tracker

I downloaded the torrent file of ubuntu 17.10 from here:
https://www.ubuntu.com/download/alternative-downloads
Here is what inside:
TorrentInfo{Created By: null
Main tracker: http://torrent.ubuntu.com:6969/announce
Comment: Ubuntu CD releases.ubuntu.com
Info_hash: f07e0b0584745b7bcb35e98097488d34e68623d0
Name: ubuntu-17.10.1-desktop-amd64.iso
Piece Length: 524288
Pieces: 2866
Total Size: 1502576640
Is Single File Torrent: true
File List:
Tracker List:
http://torrent.ubuntu.com:6969/announce
http://ipv6.torrent.ubuntu.com:6969/announce
What I have tried:
I sent: (Only torrent info-hash)
http://torrent.ubuntu.com:6969/announce?info_hash=%f0%7e%0b%05%84%74%5b%7b%cb%35%e9%80%97%48%8d%34%e6%86%23%d0
and received:
you sent me garbage - id not of length 20
I sent: (torrent info-hash and my peer-id)
http://torrent.ubuntu.com:6969/announce?info_hash=%f0%7e%0b%05%84%74%5b%7b%cb%35%e9%80%97%48%8d%34%e6%86%23%d0&peer_id=%2D%41%5A%35%37%35%30%2D%54%70%6B%58%74%74%5A%4C%66%70%53%48
and received:
you sent me garbage - invalid literal for long() with base 10: ''
What am I missing? The spec doesn't specify any example.
Spec:
https://wiki.theory.org/index.php/BitTorrentSpecification#Tracker_HTTP.2FHTTPS_Protocol
The announce misses the obligatory keys port, uploaded, downloaded and left.
These keys plus info_hash and peer_id, MUST be in every announce.
Further, while the event key isn't obligatory in every announce,
the first announce to the tracker MUST include 'event=started'.
Trying:
http://torrent.ubuntu.com:6969/announce?info_hash=%f0%7e%0b%05%84%74%5b%7b%cb%35%e9%80%97%48%8d%34%e6%86%23%d0&peer_id=%2D%41%5A%35%37%35%30%2D%54%70%6B%58%74%74%5A%4C%66%70%53%48&port=6881&uploaded=0&downloaded=0&left=1502576640&event=started
and the tracker responses with:
your client is outdated, please upgrade
oh well, more to fix...
From my answer here: Why does tracker server NOT understand my request? (Bittorrent protocol)
It is because the request string don't have compact=1 in it.
Most tracker require that nowadays. The legacy way is too ineffective.
So, adding compact=1 to the announce:
http://torrent.ubuntu.com:6969/announce?info_hash=%f0%7e%0b%05%84%74%5b%7b%cb%35%e9%80%97%48%8d%34%e6%86%23%d0&peer_id=%2D%41%5A%35%37%35%30%2D%54%70%6B%58%74%74%5A%4C%66%70%53%48&port=6881&uploaded=0&downloaded=0&left=1502576640&event=started&compact=1
and the tracker responses with:
d8:completei2134e10:incompletei100e8:intervali1800e5:peers300:[ binary data ... ]e
Success!

How to found where DNS name is expected to resolve?

Does it possible to check which DNS server used for resolving domain name (in intraned network)? We have many steps: proxy, BigIP, domain controllers, etc.
I have a complicated networks with many DNS server. Sometimes when in browser I use:
http://mysitedomainalias.mydomain.com
I receive web page,
sometime after near 15 minutes I receive error about timeout.
But when I use IP address instead of domain alias I always reach my web page.
So I have decided that it could be a problem with DNS server. I would like to know common way how to resolve similar problems.
On *NIX systems, dig is a standard tool to test and debug DNS servers:
deceze$ dig google.com
...
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 5 IN A 173.194.35.168
google.com. 5 IN A 173.194.35.161
google.com. 5 IN A 173.194.35.169
...
;; Query time: 84 msec
;; SERVER: 192.168.10.1#53(192.168.10.1)
;; WHEN: Mon Jul 14 15:59:05 2014
;; MSG SIZE rcvd: 204
In the last part, SERVER signifies which DNS server answered our request.
Some more things you can then do with dig:
query a specific DNS server instead of the system's default:
$ dig #mydns.example.com google.com
trace each step of the resolution chain to see any problems in the canonical name servers:
$ dig google.com +trace
query specific record types:
$ dig google.com NS
$ dig google.com MX
$ dig google.com ANY
See the manual: http://linux.die.net/man/1/dig

Isolation from the internet - subnetting

I'm covering a little bit of networking and I'm onto the topic of subnetting. One of the end of chapter exercises has me stumped. It looks easy but I've got nothing. The exercise is as follows:
Explain how subnet 2 can be isolated from the internet (i.e. unable to
send/recive packets to/from the internet but able to exchange packets
with the other subnets (fill in the corresponding part of the routing
tables of the appropriate routers in the format shown below)
Any assistance would be greatly appreciated!
The subnet (simplified):
********* *********
* SUB 1 * * SUB 2 *
********* *********
\ /
\ /
\ /
######### *********
#ROUTER1# * SUB 3 *
######### *********
| /
| /
######### /
#ROUTER2#_/
#########
|
|
To/From Internet
The Table:
Source NetID | Destination NetID | Action
---------------------------------------------------
| |
| |
Note, I was going to post this on serverexchange but apprently SO is the place to ask high level questions networking like this?
SUB 1: 1.0.0.0/8
SUB 2: 2.0.0.0/8
SUB 3: 3.0.0.0/8
Router1:
1.0.0.0 -> 2.0.0.0: Send to 2.0.0.0
1.0.0.0 -> 0.0.0.0: Send to Router2's IP address
2.0.0.0 -> 1.0.0.0: Send to 1.0.0.0
2.0.0.0 -> 3.0.0.0: Send to Router2's IP address
Router2:
1.0.0.0 -> 3.0.0.0: Send to 3.0.0.0
1.0.0.0 -> 0.0.0.0: Send to Internet
2.0.0.0 -> 3.0.0.0: Send to 3.0.0.0
3.0.0.0 -> 1.0.0.0: Send to Router1's IP address
3.0.0.0 -> 2.0.0.0: Send to Router1's IP address
3.0.0.0 -> 0.0.0.0: Send to Internet
The trick is the absence of a default route for anything originating from 2.0.0.0/8 on both routers.

how to find host name from IP with out login to the host

i need to find the host name of a UNIX host whose IP is known with out login to that UNIX host
Use nslookup
nslookup 208.77.188.166
...
Non-authoritative answer:
166.188.77.208.in-addr.arpa name = www.example.com.
You can do a reverse DNS lookup with host, too. Just give it the IP address as an argument:
$ host 192.168.0.10
server10 has address 192.168.0.10
Another NS lookup utility that can be used for reversed lookup is dig with the -x option:
$ dig -x 72.51.34.34
; <<>> DiG 9.9.2-P1 <<>> -x 72.51.34.34
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12770
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1460
;; QUESTION SECTION:
;34.34.51.72.in-addr.arpa. IN PTR
;; ANSWER SECTION:
34.34.51.72.in-addr.arpa. 42652 IN PTR sb.lwn.net.
;; Query time: 4 msec
;; SERVER: 192.168.178.1#53(192.168.178.1)
;; WHEN: Fri Jan 25 21:23:40 2013
;; MSG SIZE rcvd: 77
or
$ dig -x 127.0.0.1
; <<>> DiG 9.9.2-P1 <<>> -x 127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11689
;; flags: qr aa ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;1.0.0.127.in-addr.arpa. IN PTR
;; ANSWER SECTION:
1.0.0.127.in-addr.arpa. 10 IN PTR localhost.
;; Query time: 2 msec
;; SERVER: 192.168.178.1#53(192.168.178.1)
;; WHEN: Fri Jan 25 21:23:49 2013
;; MSG SIZE rcvd: 63
Quoting from the dig manpage:
Reverse lookups -- mapping addresses to names -- are simplified by the
-x option. addr is an IPv4 address in dotted-decimal notation, or a colon-delimited IPv6 address. When this option is used, there is no
need to provide the name, class and type arguments. dig automatically
performs a lookup for a name like 11.12.13.10.in-addr.arpa and sets
the query type and class to PTR and IN respectively.
For Windows ping -a 10.10.10.10
For Windows, try:
NBTSTAT -A 10.100.3.104
or
ping -a 10.100.3.104
For Linux, try:
nmblookup -A 10.100.3.104
They are almost same.
It depends on the context. I think you're referring to the operating system's hostname (returned by hostname when you're logged in). This command is for internal names only, so to query for a machine's name requires different naming systems. There are multiple systems which use names to identify hosts including DNS, DHCP, LDAP (DN's), hostname, etc. and many systems use zeroconf to synchronize names between multiple naming systems. For this reason, results from hostname will sometimes match results from dig (see below) or other naming systems, but often times they will not match.
DNS is by far the most common and is used both on the internet (like google.com. A 216.58.218.142) and at home (mDNS/LLMNR), so here's how to perform a reverse DNS lookup: dig -x <address> (nslookup and host are simpler, provide less detail, and may even return different results; however, dig is not included in Windows).
Note that hostnames within a CDN will not resolve to the canonical domain name (e.g. "google.com"), but rather the hostname of the host IP you queried (e.g. "dfw25s08-in-f142.1e100.net"; interesting tidbit: 1e100 is 1 googol).
Also note that DNS hosts can have more than one name. This is common for hosts with more than one webserver (virtual hosting), although this is becoming less common thanks to the proliferation of virtualization technologies. These hosts have multiple PTR DNS records.
Finally, note that DNS host records can be overridden by the local machine via /etc/hosts. If you're not getting the hostname you expect, be sure you check this file.
DHCP hostnames are queried differently depending on which DHCP server software is used, because (as far as I know) the protocol does not define a method for querying; however, most servers provide some way of doing this (usually with a privileged account).
Note DHCP names are usually synchronized with DNS server(s), so it's common to see the same hostnames in a DHCP client least table and in the DNS server's A (or AAAA for IPv6) records. Again, this is usually done as part of zeroconf.
Also note that just because a DHCP lease exists for a client, doesn't mean it's still being used.
NetBIOS for TCP/IP (NBT) was used for decades to perform name resolution, but has since been replaced by LLMNR for name resolution (part of zeroconf on Windows). This legacy system can still be queried with the nbtstat (Windows) or nmblookup (Linux).
python -c "import socket;print(socket.gethostbyaddr('127.0.0.1'))"
if you just need the name, no additional info, add [0] at the end:
python -c "import socket;print(socket.gethostbyaddr('8.8.8.8'))[0]"
The other answers here are correct - use reverse DNS lookups.
If you want to do it via a scripting language (Python, Perl) you could use the gethostbyaddr API.
If you are specifically looking for a Windows machine, try below command:
nbtstat -a 10.228.42.57
You can use traceroute command as well.
http://linux.die.net/man/8/traceroute
just use the traceroute it will show you the routing path with host names (IPs resolved)
In most cases, traceroute command works fine. nslookup and host commands may fail.

How to multicast using gen_udp in Erlang?

How do you use gen_udp in Erlang to do multicasting? I know its in the code, there is just no documentation behind it. Sending out data is obvious and simple. I was wondering on how to add memberships. Not only adding memberships at start-up, but adding memberships while running would be useful too.
Here is example code on how to listen in on Bonjour / Zeroconf traffic.
-module(zcclient).
-export([open/2,start/0]).
-export([stop/1,receiver/0]).
open(Addr,Port) ->
{ok,S} = gen_udp:open(Port,[{reuseaddr,true}, {ip,Addr}, {multicast_ttl,4}, {multicast_loop,false}, binary]),
inet:setopts(S,[{add_membership,{Addr,{0,0,0,0}}}]),
S.
close(S) -> gen_udp:close(S).
start() ->
S=open({224,0,0,251},5353),
Pid=spawn(?MODULE,receiver,[]),
gen_udp:controlling_process(S,Pid),
{S,Pid}.
stop({S,Pid}) ->
close(S),
Pid ! stop.
receiver() ->
receive
{udp, _Socket, IP, InPortNo, Packet} ->
io:format("~n~nFrom: ~p~nPort: ~p~nData: ~p~n",[IP,InPortNo,inet_dns:decode(Packet)]),
receiver();
stop -> true;
AnythingElse -> io:format("RECEIVED: ~p~n",[AnythingElse]),
receiver()
end.
Multicast sending has been answered, receipt requires subscription to the multicast group.
It (still) seems undocumented, but has been covered on the erlang-questions mailing list before. http://www.erlang.org/pipermail/erlang-questions/2003-March/008071.html
{ok, Socket} = gen_udp:open(Port, [binary, {active, false},
{reuseaddr, true},{ip, Addr},
{add_membership, {Addr, LAddr}}]).
where the Addr is the multicast group, and LAddr is a local interface. (code courtesy of mog)
The same options used above can be passed to inet:setopts including {drop_membership, {Addr, LAddr}} to stop listening to the group.
I try to get this example running on my PC. What could happen, if I get always the message {error,eaddrnotavail} by opening the receive socket?
Example 1: This works:
{ok, Socket} = gen_udp:open(?PORT, [{reuseaddr,true}, {ip,?SERVER_IP},
{multicast_ttl,4}, {multicast_loop,false}, binary]),
Example 2: Getting an runtime Error:
{ok, Socket} = gen_udp:open(?PORT, [{reuseaddr,true}, {ip,?MULTICAST_IP},
{multicast_ttl,4}, {multicast_loop,false}, binary]),
% --> {error,eaddrnotavail}
-define(SERVER_IP, {10,31,123,123}). % The IP of the current computer
-define(PORT, 5353).
-define(MULTICAST_IP, {224,0,0,251}).
Multicast is specified by IP Address
It's the same in erlang as for all languages. The IP addresses 224.0.0.0 through 239.255.255.255 are multicast addresses.
Pick an address in that range, check that you're not overlapping an already assigned address, and you are good to go.
http://www.iana.org/assignments/multicast-addresses

Resources