Journal on 2020-02-20

Posted on Thu 20 February 2020 in Journal

Overview

术业有专工,现在的工程项目动辄上百人,数万行代码, 各种框架和算法,从云平台和各种中间件,更别说业务逻辑上的种种,如何不迷失自己呢? 就如建筑师那样,心怀蓝图,各种建筑材料和构件不必关注细节,目标是什么,关键成功路径是什么,搞清楚哪些需要亲自动手详细设计和实施,哪些需要尽量委托给别人,专家不可能面面俱到,而是精于一点,知道常人不知道的细节和决窍,能从无到有,能创新和发展,不要想着样样精通,没必要也不可能。

DNS SRV for SIP

RFC3263 - "Session Initiation Protocol (SIP): Locating SIP Servers"

  • Check Services Field Protocol as following order:
    • SIP+D2T TCP
    • SIPS+D2T TCP
    • SIP+D2U UDP
    • SIP+D2S SCTP (RFC 2960) (defines D2U for UDP, D2T for TCP, and D2S for SCTP)

For example

dig _sips._tcp.apple.com +nocomments +noquestion +noauthority +noadditional +nostats SRV

; <<>> DiG 9.10.6 <<>> _sips._tcp.apple.com +nocomments +noquestion +noauthority +noadditional +nostats SRV
;; global options: +cmd
_sips._tcp.apple.com. 86352 IN SRV 0 0 5061 nwk-tberg-exp.apple.com.

SRV records are a nameserver record type that returns the port as well as weight and priority information for a request. For example, SRV records are commonly used by SIP clients to discover the IP address and port of the SIP server it should use

A SRV record has the form:

_service._proto.name. TTL class SRV priority weight port target.
  • _service._proto.name. TTL class SRV priority weight port target.
  • service: 服务名称,比如 sip, xmpp, 等等等 the symbolic name of the desired service.
  • proto: 传输层的协议,TCP 或 UDP
  • name: 与之相对应的有效域名, 以 . 结束
  • TTL: 标准的 DNS 生存时间 (Time To Live)
  • class: 标准的 DNS 类别 (这里总是 IN)
  • priority: 目的服务器的优先级, 数值越低代表优先级越高
  • weight: 权重, 相同优先级的一个相对权重值, 数值越大,权重越高
  • port: 该服务所用的 TCP 或 UDP 的端口
  • target: 提供该服务的规范的主机名称, 以 . 结尾

for example,

dig _sip._udp.sip.voice.google.com SRV

; <<>> DiG 9.10.6 <<>> _sip._udp.sip.voice.google.com SRV
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64756
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADDITIONAL: 9

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION: # -- 问题区
;_sip._udp.sip.voice.google.com.    IN  SRV

;; ANSWER SECTION: # -- 回答区
_sip._udp.sip.voice.google.com. 300 IN  SRV 20 1 5060 sip-anycast-2.voice.google.com.
_sip._udp.sip.voice.google.com. 300 IN  SRV 10 1 5060 sip-anycast-1.voice.google.com.

;; AUTHORITY SECTION: # -- 管理机构区
google.com.     61453   IN  NS  ns2.google.com.
google.com.     61453   IN  NS  ns4.google.com.
google.com.     61453   IN  NS  ns3.google.com.
google.com.     61453   IN  NS  ns1.google.com.

;; ADDITIONAL SECTION: # -- 附加信息区
ns1.google.com.     101075  IN  A   216.239.32.10
ns2.google.com.     238524  IN  A   216.239.34.10
ns3.google.com.     101075  IN  A   216.239.36.10
ns4.google.com.     100475  IN  A   216.239.38.10
ns1.google.com.     101075  IN  AAAA    2001:4860:4802:32::a
ns2.google.com.     254294  IN  AAAA    2001:4860:4802:34::a
ns3.google.com.     101075  IN  AAAA    2001:4860:4802:36::a
ns4.google.com.     101075  IN  AAAA    2001:4860:4802:38::a

;; Query time: 569 msec
;; SERVER: 64.104.123.245#53(64.104.123.245)
;; WHEN: Thu Feb 20 13:45:27 CST 2020
;; MSG SIZE  rcvd: 407

又如:

$ dig _sip._tcp.cisco.com SRV +noall +answer

; <<>> DiG 9.10.6 <<>> _sip._tcp.cisco.com SRV +noall +answer
;; global options: +cmd
_sip._tcp.cisco.com.    1728    IN  SRV 1 0 5060 vcsgw101.cisco.com.
_sip._tcp.cisco.com.    1728    IN  SRV 1 0 5060 vcsgw102.cisco.com.
_sip._tcp.cisco.com.    1728    IN  SRV 1 0 5060 vcsgw104.cisco.com.
_sip._tcp.cisco.com.    1728    IN  SRV 1 0 5060 vcsgw103.cisco.com.

# 省略管理机构区和附加信息区
  • 查询 IP address
https://ds.ciscospark.com/v1/region/detailed/173.39.112.101

{
attribution: "This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com",
city: null,
clientAddress: "173.39.112.102",
clientContinent: "AS",
clientRegion: "AP-SOUTHEAST",
countryCode: "SG",
disclaimer: "This service is intended for use by Webex Team only. Unauthorized use is prohibited.",
regionCode: "AP-SOUTHEAST",
timezone: "Asia/Singapore"
}