Skip to content

Instantly share code, notes, and snippets.

@tiran
Created July 20, 2017 11:33
Show Gist options
  • Save tiran/22514df54239d0e952a54cd8c935fc48 to your computer and use it in GitHub Desktop.
Save tiran/22514df54239d0e952a54cd8c935fc48 to your computer and use it in GitHub Desktop.
Python 3 IDNA
$ ipa dnsrecord-add ipa.example. götter --a-rec=192.168.121.250 --a-create-reverse
Record name: götter
A record: 192.168.121.250
$ host götter.ipa.example
xn--gtter-jua.ipa.example has address 192.168.121.250
$ host 192.168.121.250
250.121.168.192.in-addr.arpa domain name pointer xn--gtter-jua.ipa.example.
$ dig götter.ipa.example
; <<>> DiG 9.11.1-P1-RedHat-9.11.1-1.P1.fc25 <<>> götter.ipa.example
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26506
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 5fabcb75c499e54b9457ad72597094dd42de3dcc9c698af3 (good)
;; QUESTION SECTION:
;xn--gtter-jua.ipa.example. IN A
;; ANSWER SECTION:
xn--gtter-jua.ipa.example. 86400 IN A 192.168.121.250
;; AUTHORITY SECTION:
ipa.example. 86400 IN NS replica1.ipa.example.
ipa.example. 86400 IN NS master.ipa.example.
;; ADDITIONAL SECTION:
master.ipa.example. 1200 IN A 192.168.121.30
replica1.ipa.example. 1200 IN A 192.168.121.23
;; Query time: 0 msec
;; SERVER: 192.168.121.30#53(192.168.121.30)
;; WHEN: Thu Jul 20 11:32:45 UTC 2017
;; MSG SIZE rcvd: 174
$ python3
Python 3.5.3 (default, May 10 2017, 15:05:55)
[GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostbyaddr('192.168.121.250')
('xn--gtter-jua.ipa.example', [], ['192.168.121.250'])
>>> socket.getnameinfo(('192.168.121.250', 443), 0)
('xn--gtter-jua.ipa.example', 'https')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment