{"id":402149,"date":"2024-06-29T16:19:16","date_gmt":"2024-06-29T16:19:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=402149"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=402149","title":{"rendered":"<span>\u041a\u0430\u043a \u0432 \u0432\u043e\u0441\u0435\u043c\u044c \u0440\u0430\u0437 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 Go<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/390\/435\/a52\/390435a52f3532cfa2568a53336abd48.png\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/390\/435\/a52\/390435a52f3532cfa2568a53336abd48.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0420\u0443\u0441\u0442\u0430\u043c. \u042f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0432 Ozon: \u0430\u0434\u043c\u0438\u043d\u044e Kubernetes \u0438 \u043f\u0438\u0448\u0443 \u043d\u0430 Go.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043d\u0430 Go \u2014 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u044b\u0441\u044f\u0447\u0430\u043c\u0438. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u043d\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432 Kubernetes. \u0410 \u044f \u043f\u043b\u043e\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 Kubernetes \u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u0434\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 Kubernetes \u0434\u043b\u044f \u0440\u0435\u0437\u043e\u043b\u0432\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u0434\u0435\u0441\u044f\u0442\u0438 DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u042d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a Go \u0434\u0435\u043b\u0430\u0435\u0442 DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0434\u043e \u043e\u0434\u043d\u043e\u0433\u043e-\u0434\u0432\u0443\u0445. \u041a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438 \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<h2>Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 vs Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440<\/h2>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u0434\u0430\u043b\u0435\u043a\u0430. \u0411\u0443\u0434\u0435\u0442 \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u0441\u0432\u0435\u0436\u0438\u0442\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a<a href=\"https:\/\/zwischenzugs.com\/2018\/06\/08\/anatomy-of-a-linux-dns-lookup-part-i\/\"><u> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 DNS Lookup \u0432 Linux<\/u><\/a>. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e Go 1.16.<\/p>\n<p>\u0412 Go \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u043e\u0432: Go \u0438 Cgo.<\/p>\n<p>Cgo \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440, \u0430 Go \u2014 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Go. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f. \u0418 \u043a\u0430\u043a\u043e\u0439 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 <a href=\"https:\/\/golang.org\/pkg\/net\/#hdr-Name_Resolution\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/u><\/a> \u0438 <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L123\"><u>\u043a\u043e\u0434<\/u><\/a>.<\/p>\n<p>\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u043e\u0432 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442, \u043a\u0430\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u0442\u043e\u043c \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u041c\u043e\u0435\u0439 \u0446\u0435\u043b\u044c\u044e \u0431\u044b\u043b\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u0432 \u043a\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440, \u0430 \u0432 \u043a\u0430\u043a\u043e\u043c \u2014 \u0434\u0440\u0443\u0433\u043e\u0439, \u0438 \u0441\u0442\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u042d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0440\u0435\u0434\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0445\u043e\u0441\u0442\u0430. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e macOS \u0438 Linux, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445.<\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u0430\u043c\u0438, \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u043c\u0438 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430, \u043a\u0430\u043a CGO_ENABLED \u0438 \u043e\u043f\u0446\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 resolv.conf \u0438 nsswitch.conf. \u041d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<h3>CGO_ENABLED<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p><strong>Tables<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>CGO_ENABLED = 0<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>CGO_ENABLED = 1<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Linux<\/p>\n<\/td>\n<td>\n<p>go<\/p>\n<\/td>\n<td>\n<p>it depends =)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>MacOs<\/p>\n<\/td>\n<td>\n<p>go<\/p>\n<\/td>\n<td>\n<p>cgo<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0415\u0441\u043b\u0438 Cgo \u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d, \u0442\u043e \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u0410 \u0435\u0441\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0451\u043d, \u0442\u043e \u043d\u0430 macOS \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L69-L71\"><u>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440<\/u><\/a>. \u041d\u0430 Linux \u0436\u0435 \u0432\u0441\u0451 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 env-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043e\u043f\u0446\u0438\u0439 \u0432 resolv.conf \u0438 nsswitch.conf.<\/p>\n<h3>resolv.conf<\/h3>\n<p>\u0411\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f Cgo-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0435\u0441\u043b\u0438 \u0432 resolv.conf \u0435\u0441\u0442\u044c \u043e\u043f\u0446\u0438\u0438, \u043a\u0440\u043e\u043c\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445:<\/p>\n<ul>\n<li>\n<p>ndots<\/p>\n<\/li>\n<li>\n<p>timeout<\/p>\n<\/li>\n<li>\n<p>attempts<\/p>\n<\/li>\n<li>\n<p>rotate<\/p>\n<\/li>\n<li>\n<p>single-requests<\/p>\n<\/li>\n<li>\n<p>single-requests-reopen<\/p>\n<\/li>\n<li>\n<p>use-vc, usevc, tcp<\/p>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/dnsconfig_unix.go#L98-L134\"><u>\u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0445 \u043e\u043f\u0446\u0438\u0439<\/u><\/a><\/p>\n<p>\u0422\u0443\u0442 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440:<\/p>\n<pre><code class=\"bash\">$ cat \/etc\/resolv.conf nameserver 127.0.0.53<\/code><\/pre>\n<p>\u0410 \u0442\u0443\u0442 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 (\u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u043d\u043e\u0439 Ubuntu):<\/p>\n<pre><code class=\"bash\">$ cat \/etc\/resolv.conf nameserver 127.0.0.53 options edns0 trust-ad<\/code><\/pre>\n<h3>nsswitch.conf<\/h3>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f nsswitch.conf, \u0442\u043e, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L198-L206\"><u>\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440<\/u><\/a>.<\/p>\n<p>\u0421 \u0442\u0430\u043a\u0438\u043c nsswitch \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 Go (\u044d\u0442\u043e \u0444\u0430\u0439\u043b \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 ubuntu:focal):<\/p>\n<pre><code class=\"xml\">passwd: \u00a0 \u00a0 \u00a0 \u00a0 compat group:\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 compat shadow: \u00a0 \u00a0 \u00a0 \u00a0 compat gshadow:\u00a0 \u00a0 \u00a0 \u00a0 files hosts:\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 files dns networks: \u00a0 \u00a0 \u00a0 files protocols:\u00a0 \u00a0 \u00a0 db files services: \u00a0 \u00a0 \u00a0 db files ethers: \u00a0 \u00a0 \u00a0 \u00a0 db files rpc:\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 db files netgroup: \u00a0 \u00a0 \u00a0 nis<\/code><\/pre>\n<p>\u0423 \u043c\u0435\u043d\u044f \u043d\u0430 \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u043d\u043e\u0439 Ubuntu \u0431\u044b\u043b\u043e \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435: <strong>hosts: files dns mymachines<\/strong>. \u0421 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440.<a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L216-L250\"> <u>\u041a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043e\u043f\u0446\u0438\u0439 \u0432 nsswitch<\/u><\/a>.<\/p>\n<h3>\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e env-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 GODEBUG \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440:<\/p>\n<pre><code>GODEBUG=netdns=cgo GODEBUG=netdns=go<\/code><\/pre>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043c\u043d\u043e\u0433\u043e \u0432\u0435\u0449\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430.\u00a0 \u041d\u043e \u044f \u0432 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L77\"><u>\u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u0434<\/u><\/a>.<\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043a\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f<\/h3>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u0442 GET-\u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"go\">req, err := http.NewRequest(\"GET\", url, nil) if err != nil {   panic(err) }  _, err = http.DefaultClient.Do(req) if err != nil {   panic(err) }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441 \u0434\u0435\u0431\u0430\u0433\u043e\u043c DNS \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0433\u0434\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f Cgo. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043b\u043e\u0433\u0438\u0447\u043d\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f00\/dbd\/b51\/f00dbdb512f68a36c3aee58b770927d4.png\" alt=\"\" title=\"\" width=\"2293\" height=\"871\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f00\/dbd\/b51\/f00dbdb512f68a36c3aee58b770927d4.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0435\u0437\u043e\u043b\u0432 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0435\u043d\u0430: my.local.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/253\/e99\/dda\/253e99dda5b2d25e2ae8aef8548fbf1c.png\" width=\"2279\" height=\"641\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/253\/e99\/dda\/253e99dda5b2d25e2ae8aef8548fbf1c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u041f\u043e\u043a\u0430 \u0435\u0449\u0451 \u043b\u043e\u0433\u0438\u0447\u043d\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/995\/19b\/70c\/99519b70c87201c31f40c90281abce3e.png\" width=\"2291\" height=\"624\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/995\/19b\/70c\/99519b70c87201c31f40c90281abce3e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0433\u0434\u0435 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/925\/4ed\/6fe\/9254ed6fed5dd1231657a71966972eec.png\" alt=\"\" title=\"\" width=\"2194\" height=\"570\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/925\/4ed\/6fe\/9254ed6fed5dd1231657a71966972eec.png\"\/><figcaption><\/figcaption><\/figure>\n<p>WAT?! \u041f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0434\u043b\u044f \u0434\u043e\u043c\u0435\u043d\u0430 my.local \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430, \u0445\u043e\u0442\u044f \u0434\u043b\u044f golang.org \u0432\u044b\u0431\u0440\u0430\u043b\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u0412 \u043a\u043e\u0434\u0435 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430 <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L188-L194\"><u>\u0435\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435<\/u><\/a> \u0434\u043b\u044f \u0434\u043e\u043c\u0435\u043d\u043e\u0432 .local. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0441\u043d\u0438\u0444\u0444\u0430\u0442\u044c DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0447\u0435\u0440\u0435\u0437 <strong>tcpdump -i any -nnn port 53<\/strong>.<\/p>\n<h2>\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438<\/h2>\n<p>\u042f \u043d\u0430\u0448\u0451\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u042d\u0442\u043e IPv6, \u043e\u043f\u0446\u0438\u044f ndots \u0432 resolv.conf \u0438 \u0440\u0435\u0437\u043e\u043b\u0432\u0438\u043d\u0433 localhost.<\/p>\n<h3>IPv6<\/h3>\n<p>\u0412 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0435 <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/dnsclient_unix.go#L586\"><u>\u0432\u0441\u0435\u0433\u0434\u0430<\/u><\/a> \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 DNS: A \u0438 AAAA (\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 IPv6). \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u043e\u043f\u0446\u0438\u0438 single-request \u0432 resolv.conf, \u043e\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u044d\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6bd\/c51\/df8\/6bdc51df86bbccd89b876a8c6b004074.png\" alt=\"Cgo resolver\" title=\"Cgo resolver\" width=\"1818\" height=\"579\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6bd\/c51\/df8\/6bdc51df86bbccd89b876a8c6b004074.png\"\/><figcaption>Cgo resolver<\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b10\/f3e\/e43\/b10f3ee43bd9a4db6bc0e6ba7c3549ac.png\" alt=\"Go resolver\" title=\"Go resolver\" width=\"1807\" height=\"580\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b10\/f3e\/e43\/b10f3ee43bd9a4db6bc0e6ba7c3549ac.png\"\/><figcaption>Go resolver<\/figcaption><\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 DialContext. \u0412\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 http.Transport<a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/http\/transport.go#L1600\"> <u>\u0437\u0430\u0448\u0438\u0442\u043e<\/u><\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 TCP, \u0430 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 tcp4:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bfd\/7d1\/a57\/bfd7d1a57ba06f3138e7f0e9ab7364b7.png\" width=\"1842\" height=\"434\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bfd\/7d1\/a57\/bfd7d1a57ba06f3138e7f0e9ab7364b7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0410\u0410\u0410\u0410-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 DNS. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0435\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/617\/23c\/370\/61723c370edfec2c4ed7fb8babde1dae.png\" width=\"1763\" height=\"485\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/617\/23c\/370\/61723c370edfec2c4ed7fb8babde1dae.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u0430 IPv6:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a01\/05b\/c2d\/a0105bc2d5dcc93c7cdcd55e3f3ab627.png\" width=\"1781\" height=\"630\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a01\/05b\/c2d\/a0105bc2d5dcc93c7cdcd55e3f3ab627.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 Go 1.17 \u044d\u0442\u043e <a href=\"https:\/\/github.com\/golang\/go\/pull\/45016\"><u>\u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438<\/u><\/a>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/646\/372\/422\/6463724228efb1802d71f6d30c70f644.png\" width=\"1745\" height=\"534\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/646\/372\/422\/6463724228efb1802d71f6d30c70f644.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0441 IPv6:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p><strong>resolver<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>1.16<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>1.17<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>cgo<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>go<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>cgo custom transport<\/p>\n<\/td>\n<td>\n<p align=\"center\">1<\/p>\n<\/td>\n<td>\n<p align=\"center\">1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>go custom transport<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<td>\n<p align=\"center\">1<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>ndots<\/h3>\n<p>\u042d\u0442\u0430 \u0442\u0435\u043c\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Kubernetes. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043f\u043e\u0434\u0430\u0445 Kubernetes \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 resolv.conf:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/72e\/db5\/d45\/72edb5d4511a438b8ef7409df5ecbed3.png\" width=\"2151\" height=\"369\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/72e\/db5\/d45\/72edb5d4511a438b8ef7409df5ecbed3.png\"\/><figcaption><\/figcaption><\/figure>\n<blockquote>\n<p><strong>ndots:<\/strong><em>n<\/em>  Sets a threshold for the number of dots which must appear in a name given to <a href=\"https:\/\/man7.org\/linux\/man-pages\/man3\/res_query.3.html\">res_query(3)<\/a> (see <a href=\"https:\/\/man7.org\/linux\/man-pages\/man3\/resolver.3.html\">resolver(3)<\/a>) before an <em>initial absolute query<\/em> will                      be made. The default for <em>n<\/em> is 1, meaning that if there are any dots in a name, the name will be tried first as an absolute name before any <em>search<\/em> <em>list<\/em> elements are appended to it. The value for this option is silently capped to 15.<\/p>\n<\/blockquote>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a32\/bdd\/d8c\/a32bddd8c84570e3cd92060d8888b602.png\" width=\"2043\" height=\"907\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a32\/bdd\/d8c\/a32bddd8c84570e3cd92060d8888b602.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0441\u0435\u043c\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043f\u043e \u0434\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (A \u0438 AAAA) \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u043e\u043c\u0435\u043d\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>golang.org.<strong>ns.svc.cluster.local<\/strong><\/p>\n<\/li>\n<li>\n<p>golang.org.<strong>svc.cluster.local<\/strong><\/p>\n<\/li>\n<li>\n<p>golang.org.<strong>cluster.local<\/strong><\/p>\n<\/li>\n<li>\n<p>golang.org<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434 \u043c\u043e\u0433 \u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 \u0442\u043e\u043c \u0436\u0435 \u043d\u0435\u0439\u043c\u043f\u0435\u0439\u0441\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0431\u0435\u0437 \u043f\u043e\u043b\u043d\u043e\u0433\u043e FQDN. \u041d\u043e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0443\u0441\u0443\u0433\u0443\u0431\u043b\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u0439 \u0441\u0435\u0442\u0438 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0438 \u0432\u0430\u0448\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 search-\u0434\u043e\u043c\u0435\u043d\u044b. \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0430\u043a\u043e\u0439 \u0434\u043e\u043c\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0440\u0435\u0437\u043e\u043b\u0432\u0430 \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n<p>\u041b\u0435\u0447\u0438\u0442\u0441\u044f \u044d\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 FQDN \u0441 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435. \u0410 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0432 \u043f\u043e\u0434\u044b. \u041d\u043e \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0435 \u0434\u043e\u043c\u0435\u043d\u044b \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 Kubernetes.<\/p>\n<pre><code class=\"yaml\">dnsConfig:   options:     - name: ndots       value: \"1\"<\/code><\/pre>\n<h3>localhost<\/h3>\n<p>\u0412 Kubernetes \u043c\u043e\u0433\u0443\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u044b localhost. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0430\u0439\u0434\u043a\u0430\u0440\u044b \u0434\u043b\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u043f\u0440\u043e\u043a\u0441\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0432 \u043f\u043e\u0434\u0435, \u043d\u043e \u0432 \u0442\u043e\u043c \u0436\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u043c \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u0435.<\/p>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \/etc\/nsswitch.conf (\u043f\u0440\u0438\u0432\u0435\u0442, Alpine). \u0417\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f DNS, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0433\u0434\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0434\u043e\u043c\u0435\u043d, \u0438 \u0441\u0440\u0430\u0437\u0443 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/025\/68a\/05f\/02568a05fc3a7e34fd8f9153336fd670.png\" alt=\"\" title=\"\" width=\"2195\" height=\"1013\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/025\/68a\/05f\/02568a05fc3a7e34fd8f9153336fd670.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u0417\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0435\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c34\/80d\/b54\/c3480db54872478c544d23cf23fccad9.png\" width=\"2031\" height=\"822\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c34\/80d\/b54\/c3480db54872478c544d23cf23fccad9.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0433\u0434\u0435 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/327\/446\/2a7\/3274462a748fab9111b9f3f66923cddb.png\" width=\"2172\" height=\"959\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/327\/446\/2a7\/3274462a748fab9111b9f3f66923cddb.png\"\/><figcaption><\/figcaption><\/figure>\n<p>WAT?!<\/p>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 1.16 \u044d\u0442\u043e <a href=\"https:\/\/github.com\/golang\/go\/commit\/c80022204e8fc36ec487888d471de27a5ea47e17\"><u>\u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438<\/u><\/a>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f9a\/9e0\/16d\/f9a9e016da222411ef829c740a162946.png\" width=\"1948\" height=\"771\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f9a\/9e0\/16d\/f9a9e016da222411ef829c740a162946.png\"\/><figcaption><\/figcaption><\/figure>\n<blockquote>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 Go \u0434\u043e 1.16<\/p>\n<p>hostLookupOrder(localhost) = dns,files<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 Go 1.16<\/p>\n<p>hostLookupOrder(localhost) = files,dns<\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0442\u0430\u043a\u043e\u0439, \u0442\u043e \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0432 \/etc\/hosts, \u0434\u0430\u0436\u0435 \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445, \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<pre><code class=\"bash\">$ cat \/etc\/nsswitch.conf hosts: files dns<\/code><\/pre>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439, \u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 DNS:<\/p>\n<pre><code class=\"bash\">$ cat \/etc\/nsswitch.conf hosts: dns files<\/code><\/pre>\n<p>\u0412 \u043c\u043e\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0431\u044b\u043b \u0437\u0430\u0431\u0430\u0432\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0441 localhost: \u043e\u043d \u0440\u0435\u0437\u043e\u043b\u0432\u0438\u043b\u0441\u044f \u0432 \u0430\u0434\u0440\u0435\u0441.<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6d8\/c0c\/7ba\/6d8c0c7ba578031e623a5a577ed7a1e2.png\" width=\"905\" height=\"533\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6d8\/c0c\/7ba\/6d8c0c7ba578031e623a5a577ed7a1e2.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5f1\/325\/85c\/5f132585cd7feee7a0cc968f1da57ee8.png\" width=\"2130\" height=\"639\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5f1\/325\/85c\/5f132585cd7feee7a0cc968f1da57ee8.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, happy debugging, suckers!<\/p>\n<h2>\u0411\u0430\u0433\u0438 \u044f\u0434\u0440\u0430<\/h2>\n<p>\u0415\u0449\u0451 \u044f \u043d\u0430\u0442\u044b\u043a\u0430\u043b\u0441\u044f \u043d\u0430 \u0431\u0430\u0433\u0438 \u0432 \u044f\u0434\u0440\u0435. \u0411\u044b\u043b\u0438 race conditions \u0432 DNAT Conntrack. \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u043e\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0434\u0432\u0430 UDP-\u043f\u0430\u043a\u0435\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u0438\u043d \u0441\u043e\u043a\u0435\u0442 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0440\u0435\u0434\u043e\u0432. \u042d\u0442\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e <a href=\"https:\/\/github.com\/torvalds\/linux\/commit\/ed07d9a021df6da53456663a76999189badc432a\"><u>\u0432 \u0432\u0435\u0440\u0441\u0438\u0438 4.19<\/u><\/a> \u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u2014 <a href=\"https:\/\/github.com\/torvalds\/linux\/commit\/4e35c1cb9460240e983a01745b5f29fe3a4d8e39\"><u>\u0432 5.0<\/u><\/a>.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437 Ubuntu Focal, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440, \u0430 \u0435\u0441\u043b\u0438 Alpine 3.13 \u2014 \u0442\u043e Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u041d\u0430 macOS \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u041a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0441\u0435\u0439\u0447\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0430 Go \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Kubernetes, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 quick win \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 ndots. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432 \u0447\u0435\u0442\u044b\u0440\u0435 \u0440\u0430\u0437\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f IPv6 \u0430\u0434\u0440\u0435\u0441\u043e\u0432, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0451 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0446\u0435\u043b\u044b\u0445 \u0432\u043e\u0441\u0435\u043c\u044c \u0440\u0430\u0437. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 DNS, \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u0440\u0435\u0437 tcpdump.<\/p>\n<p>\u041d\u0443 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435: \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0438\u0448\u043e\u0447\u043a\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0438 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p><strong>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/golang\/go\/pull\/45016\"><u>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f IPv4 only \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0435<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/golang\/go\/commit\/c80022204e8fc36ec487888d471de27a5ea47e17\"><u>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0433\u0430 \u0441\u00a0 localhost \u0432 Go 1.16<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/golang\/go\/blob\/master\/src\/net\/conf.go\"><u>src\/net\/conf.go<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/golang\/go\/blob\/master\/src\/net\/dnsclient_unix.go\"><u>src\/net\/dnsclient_unix.go<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041a\u0430\u043a Linux \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435\u0437\u043e\u043b\u0432:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/man7.org\/linux\/man-pages\/man5\/resolv.conf.5.html\"><u>man resolv.conf<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/zwischenzugs.com\/2018\/06\/08\/anatomy-of-a-linux-dns-lookup-part-i\/\"><u>Anatomy of a Linux DNS Lookup (en)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.kickflop.net\/blog\/2011\/01\/02\/tracing-linux-hostname-resolution\/\"><u>Tracing Linux Hostname Resolution (en)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/352300\/\"><u>Resolve IP addresses in Linux (ru)<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438-\u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/www.weave.works\/blog\/racy-conntrack-and-dns-lookup-timeouts\"><u>Racy conntrack and DNS lookup timeouts (en)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/blog.quentin-machu.fr\/2018\/06\/24\/5-15s-dns-lookups-on-kubernetes\/\"><u>5 \u2013 15s DNS lookups on Kubernetes (en)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/engineering.grab.com\/dns-resolution-in-go-and-cgo\"><u>DNS Resolution in Go and Cgo (en)<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/570936\/\"> https:\/\/habr.com\/ru\/articles\/570936\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0420\u0443\u0441\u0442\u0430\u043c. \u042f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0432 Ozon: \u0430\u0434\u043c\u0438\u043d\u044e Kubernetes \u0438 \u043f\u0438\u0448\u0443 \u043d\u0430 Go.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043d\u0430 Go \u2014 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u044b\u0441\u044f\u0447\u0430\u043c\u0438. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u043d\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432 Kubernetes. \u0410 \u044f \u043f\u043b\u043e\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 Kubernetes \u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u0434\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 Kubernetes \u0434\u043b\u044f \u0440\u0435\u0437\u043e\u043b\u0432\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u0434\u0435\u0441\u044f\u0442\u0438 DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u042d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a Go \u0434\u0435\u043b\u0430\u0435\u0442 DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0434\u043e \u043e\u0434\u043d\u043e\u0433\u043e-\u0434\u0432\u0443\u0445. \u041a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438 \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<h2>Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 vs Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440<\/h2>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u0434\u0430\u043b\u0435\u043a\u0430. \u0411\u0443\u0434\u0435\u0442 \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u0441\u0432\u0435\u0436\u0438\u0442\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a<a href=\"https:\/\/zwischenzugs.com\/2018\/06\/08\/anatomy-of-a-linux-dns-lookup-part-i\/\"><u> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 DNS Lookup \u0432 Linux<\/u><\/a>. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e Go 1.16.<\/p>\n<p>\u0412 Go \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u043e\u0432: Go \u0438 Cgo.<\/p>\n<p>Cgo \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440, \u0430 Go \u2014 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Go. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f. \u0418 \u043a\u0430\u043a\u043e\u0439 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 <a href=\"https:\/\/golang.org\/pkg\/net\/#hdr-Name_Resolution\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/u><\/a> \u0438 <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L123\"><u>\u043a\u043e\u0434<\/u><\/a>.<\/p>\n<p>\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u043e\u0432 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442, \u043a\u0430\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u0442\u043e\u043c \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u041c\u043e\u0435\u0439 \u0446\u0435\u043b\u044c\u044e \u0431\u044b\u043b\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u0432 \u043a\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440, \u0430 \u0432 \u043a\u0430\u043a\u043e\u043c \u2014 \u0434\u0440\u0443\u0433\u043e\u0439, \u0438 \u0441\u0442\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u042d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0440\u0435\u0434\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0445\u043e\u0441\u0442\u0430. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e macOS \u0438 Linux, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445.<\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u0430\u043c\u0438, \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u043c\u0438 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430, \u043a\u0430\u043a CGO_ENABLED \u0438 \u043e\u043f\u0446\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 resolv.conf \u0438 nsswitch.conf. \u041d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<h3>CGO_ENABLED<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p><strong>Tables<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>CGO_ENABLED = 0<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>CGO_ENABLED = 1<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Linux<\/p>\n<\/td>\n<td>\n<p>go<\/p>\n<\/td>\n<td>\n<p>it depends =)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>MacOs<\/p>\n<\/td>\n<td>\n<p>go<\/p>\n<\/td>\n<td>\n<p>cgo<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0415\u0441\u043b\u0438 Cgo \u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d, \u0442\u043e \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u0410 \u0435\u0441\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0451\u043d, \u0442\u043e \u043d\u0430 macOS \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L69-L71\"><u>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440<\/u><\/a>. \u041d\u0430 Linux \u0436\u0435 \u0432\u0441\u0451 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 env-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043e\u043f\u0446\u0438\u0439 \u0432 resolv.conf \u0438 nsswitch.conf.<\/p>\n<h3>resolv.conf<\/h3>\n<p>\u0411\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f Cgo-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0435\u0441\u043b\u0438 \u0432 resolv.conf \u0435\u0441\u0442\u044c \u043e\u043f\u0446\u0438\u0438, \u043a\u0440\u043e\u043c\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445:<\/p>\n<ul>\n<li>\n<p>ndots<\/p>\n<\/li>\n<li>\n<p>timeout<\/p>\n<\/li>\n<li>\n<p>attempts<\/p>\n<\/li>\n<li>\n<p>rotate<\/p>\n<\/li>\n<li>\n<p>single-requests<\/p>\n<\/li>\n<li>\n<p>single-requests-reopen<\/p>\n<\/li>\n<li>\n<p>use-vc, usevc, tcp<\/p>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/dnsconfig_unix.go#L98-L134\"><u>\u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0445 \u043e\u043f\u0446\u0438\u0439<\/u><\/a><\/p>\n<p>\u0422\u0443\u0442 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440:<\/p>\n<pre><code class=\"bash\">$ cat \/etc\/resolv.conf nameserver 127.0.0.53<\/code><\/pre>\n<p>\u0410 \u0442\u0443\u0442 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 (\u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u043d\u043e\u0439 Ubuntu):<\/p>\n<pre><code class=\"bash\">$ cat \/etc\/resolv.conf nameserver 127.0.0.53 options edns0 trust-ad<\/code><\/pre>\n<h3>nsswitch.conf<\/h3>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f nsswitch.conf, \u0442\u043e, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L198-L206\"><u>\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440<\/u><\/a>.<\/p>\n<p>\u0421 \u0442\u0430\u043a\u0438\u043c nsswitch \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 Go (\u044d\u0442\u043e \u0444\u0430\u0439\u043b \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 ubuntu:focal):<\/p>\n<pre><code class=\"xml\">passwd: \u00a0 \u00a0 \u00a0 \u00a0 compat group:\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 compat shadow: \u00a0 \u00a0 \u00a0 \u00a0 compat gshadow:\u00a0 \u00a0 \u00a0 \u00a0 files hosts:\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 files dns networks: \u00a0 \u00a0 \u00a0 files protocols:\u00a0 \u00a0 \u00a0 db files services: \u00a0 \u00a0 \u00a0 db files ethers: \u00a0 \u00a0 \u00a0 \u00a0 db files rpc:\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 db files netgroup: \u00a0 \u00a0 \u00a0 nis<\/code><\/pre>\n<p>\u0423 \u043c\u0435\u043d\u044f \u043d\u0430 \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u043d\u043e\u0439 Ubuntu \u0431\u044b\u043b\u043e \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435: <strong>hosts: files dns mymachines<\/strong>. \u0421 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440.<a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L216-L250\"> <u>\u041a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043e\u043f\u0446\u0438\u0439 \u0432 nsswitch<\/u><\/a>.<\/p>\n<h3>\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e env-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 GODEBUG \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440:<\/p>\n<pre><code>GODEBUG=netdns=cgo GODEBUG=netdns=go<\/code><\/pre>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043c\u043d\u043e\u0433\u043e \u0432\u0435\u0449\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430.\u00a0 \u041d\u043e \u044f \u0432 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L77\"><u>\u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u0434<\/u><\/a>.<\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043a\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f<\/h3>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u0442 GET-\u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"go\">req, err := http.NewRequest(\"GET\", url, nil) if err != nil {   panic(err) }  _, err = http.DefaultClient.Do(req) if err != nil {   panic(err) }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441 \u0434\u0435\u0431\u0430\u0433\u043e\u043c DNS \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0433\u0434\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f Cgo. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043b\u043e\u0433\u0438\u0447\u043d\u043e:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0435\u0437\u043e\u043b\u0432 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0435\u043d\u0430: my.local.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u041f\u043e\u043a\u0430 \u0435\u0449\u0451 \u043b\u043e\u0433\u0438\u0447\u043d\u043e:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0433\u0434\u0435 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>WAT?! \u041f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0434\u043b\u044f \u0434\u043e\u043c\u0435\u043d\u0430 my.local \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430, \u0445\u043e\u0442\u044f \u0434\u043b\u044f golang.org \u0432\u044b\u0431\u0440\u0430\u043b\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u0412 \u043a\u043e\u0434\u0435 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430 <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/conf.go#L188-L194\"><u>\u0435\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435<\/u><\/a> \u0434\u043b\u044f \u0434\u043e\u043c\u0435\u043d\u043e\u0432 .local. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0441\u043d\u0438\u0444\u0444\u0430\u0442\u044c DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0447\u0435\u0440\u0435\u0437 <strong>tcpdump -i any -nnn port 53<\/strong>.<\/p>\n<h2>\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438<\/h2>\n<p>\u042f \u043d\u0430\u0448\u0451\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u042d\u0442\u043e IPv6, \u043e\u043f\u0446\u0438\u044f ndots \u0432 resolv.conf \u0438 \u0440\u0435\u0437\u043e\u043b\u0432\u0438\u043d\u0433 localhost.<\/p>\n<h3>IPv6<\/h3>\n<p>\u0412 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0435 <a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/dnsclient_unix.go#L586\"><u>\u0432\u0441\u0435\u0433\u0434\u0430<\/u><\/a> \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 DNS: A \u0438 AAAA (\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 IPv6). \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u043e\u043f\u0446\u0438\u0438 single-request \u0432 resolv.conf, \u043e\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u044d\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<figure class=\"full-width\"><figcaption>Cgo resolver<\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption>Go resolver<\/figcaption><\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 DialContext. \u0412\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 http.Transport<a href=\"https:\/\/github.com\/golang\/go\/blob\/go1.16.3\/src\/net\/http\/transport.go#L1600\"> <u>\u0437\u0430\u0448\u0438\u0442\u043e<\/u><\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 TCP, \u0430 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 tcp4:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0410\u0410\u0410\u0410-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 DNS. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0435\u0442:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u0430 IPv6:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 Go 1.17 \u044d\u0442\u043e <a href=\"https:\/\/github.com\/golang\/go\/pull\/45016\"><u>\u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438<\/u><\/a>:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0441 IPv6:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p><strong>resolver<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>1.16<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>1.17<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>cgo<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>go<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>cgo custom transport<\/p>\n<\/td>\n<td>\n<p align=\"center\">1<\/p>\n<\/td>\n<td>\n<p align=\"center\">1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>go custom transport<\/p>\n<\/td>\n<td>\n<p align=\"center\">2<\/p>\n<\/td>\n<td>\n<p align=\"center\">1<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>ndots<\/h3>\n<p>\u042d\u0442\u0430 \u0442\u0435\u043c\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Kubernetes. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043f\u043e\u0434\u0430\u0445 Kubernetes \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 resolv.conf:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<blockquote>\n<p><strong>ndots:<\/strong><em>n<\/em>  Sets a threshold for the number of dots which must appear in a name given to <a href=\"https:\/\/man7.org\/linux\/man-pages\/man3\/res_query.3.html\">res_query(3)<\/a> (see <a href=\"https:\/\/man7.org\/linux\/man-pages\/man3\/resolver.3.html\">resolver(3)<\/a>) before an <em>initial absolute query<\/em> will                      be made. The default for <em>n<\/em> is 1, meaning that if there are any dots in a name, the name will be tried first as an absolute name before any <em>search<\/em> <em>list<\/em> elements are appended to it. The value for this option is silently capped to 15.<\/p>\n<\/blockquote>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0441\u0435\u043c\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043f\u043e \u0434\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (A \u0438 AAAA) \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u043e\u043c\u0435\u043d\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>golang.org.<strong>ns.svc.cluster.local<\/strong><\/p>\n<\/li>\n<li>\n<p>golang.org.<strong>svc.cluster.local<\/strong><\/p>\n<\/li>\n<li>\n<p>golang.org.<strong>cluster.local<\/strong><\/p>\n<\/li>\n<li>\n<p>golang.org<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434 \u043c\u043e\u0433 \u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 \u0442\u043e\u043c \u0436\u0435 \u043d\u0435\u0439\u043c\u043f\u0435\u0439\u0441\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0431\u0435\u0437 \u043f\u043e\u043b\u043d\u043e\u0433\u043e FQDN. \u041d\u043e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0443\u0441\u0443\u0433\u0443\u0431\u043b\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u0439 \u0441\u0435\u0442\u0438 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0438 \u0432\u0430\u0448\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 search-\u0434\u043e\u043c\u0435\u043d\u044b. \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0430\u043a\u043e\u0439 \u0434\u043e\u043c\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0440\u0435\u0437\u043e\u043b\u0432\u0430 \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n<p>\u041b\u0435\u0447\u0438\u0442\u0441\u044f \u044d\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 FQDN \u0441 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435. \u0410 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0432 \u043f\u043e\u0434\u044b. \u041d\u043e \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0435 \u0434\u043e\u043c\u0435\u043d\u044b \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 Kubernetes.<\/p>\n<pre><code class=\"yaml\">dnsConfig:   options:     - name: ndots       value: \"1\"<\/code><\/pre>\n<h3>localhost<\/h3>\n<p>\u0412 Kubernetes \u043c\u043e\u0433\u0443\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u044b localhost. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0430\u0439\u0434\u043a\u0430\u0440\u044b \u0434\u043b\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u043f\u0440\u043e\u043a\u0441\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0432 \u043f\u043e\u0434\u0435, \u043d\u043e \u0432 \u0442\u043e\u043c \u0436\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u043c \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u0435.<\/p>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \/etc\/nsswitch.conf (\u043f\u0440\u0438\u0432\u0435\u0442, Alpine). \u0417\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f DNS, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0433\u0434\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0434\u043e\u043c\u0435\u043d, \u0438 \u0441\u0440\u0430\u0437\u0443 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u0417\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0435\u0442:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0433\u0434\u0435 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>WAT?!<\/p>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 1.16 \u044d\u0442\u043e <a href=\"https:\/\/github.com\/golang\/go\/commit\/c80022204e8fc36ec487888d471de27a5ea47e17\"><u>\u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438<\/u><\/a>.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<blockquote>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 Go \u0434\u043e 1.16<\/p>\n<p>hostLookupOrder(localhost) = dns,files<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 Go 1.16<\/p>\n<p>hostLookupOrder(localhost) = files,dns<\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0442\u0430\u043a\u043e\u0439, \u0442\u043e \u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0432 \/etc\/hosts, \u0434\u0430\u0436\u0435 \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445, \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<pre><code class=\"bash\">$ cat \/etc\/nsswitch.conf hosts: files dns<\/code><\/pre>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439, \u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 DNS:<\/p>\n<pre><code class=\"bash\">$ cat \/etc\/nsswitch.conf hosts: dns files<\/code><\/pre>\n<p>\u0412 \u043c\u043e\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0431\u044b\u043b \u0437\u0430\u0431\u0430\u0432\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0441 localhost: \u043e\u043d \u0440\u0435\u0437\u043e\u043b\u0432\u0438\u043b\u0441\u044f \u0432 \u0430\u0434\u0440\u0435\u0441.<\/p>\n<figure class=\"bordered full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, happy debugging, suckers!<\/p>\n<h2>\u0411\u0430\u0433\u0438 \u044f\u0434\u0440\u0430<\/h2>\n<p>\u0415\u0449\u0451 \u044f \u043d\u0430\u0442\u044b\u043a\u0430\u043b\u0441\u044f \u043d\u0430 \u0431\u0430\u0433\u0438 \u0432 \u044f\u0434\u0440\u0435. \u0411\u044b\u043b\u0438 race conditions \u0432 DNAT Conntrack. \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u043e\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0434\u0432\u0430 UDP-\u043f\u0430\u043a\u0435\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u0438\u043d \u0441\u043e\u043a\u0435\u0442 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0440\u0435\u0434\u043e\u0432. \u042d\u0442\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e <a href=\"https:\/\/github.com\/torvalds\/linux\/commit\/ed07d9a021df6da53456663a76999189badc432a\"><u>\u0432 \u0432\u0435\u0440\u0441\u0438\u0438 4.19<\/u><\/a> \u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u2014 <a href=\"https:\/\/github.com\/torvalds\/linux\/commit\/4e35c1cb9460240e983a01745b5f29fe3a4d8e39\"><u>\u0432 5.0<\/u><\/a>.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437 Ubuntu Focal, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440, \u0430 \u0435\u0441\u043b\u0438 Alpine 3.13 \u2014 \u0442\u043e Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u041d\u0430 macOS \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Cgo-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440. \u041a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0441\u0435\u0439\u0447\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0430 Go \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Kubernetes, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 quick win \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 ndots. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432 \u0447\u0435\u0442\u044b\u0440\u0435 \u0440\u0430\u0437\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f IPv6 \u0430\u0434\u0440\u0435\u0441\u043e\u0432, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0451 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0446\u0435\u043b\u044b\u0445 \u0432\u043e\u0441\u0435\u043c\u044c \u0440\u0430\u0437. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 DNS, \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u0440\u0435\u0437 tcpdump.<\/p>\n<p>\u041d\u0443 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435: \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0438\u0448\u043e\u0447\u043a\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0438 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p><strong>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/golang\/go\/pull\/45016\"><u>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f IPv4 only \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 Go-\u0440\u0435\u0437\u043e\u043b\u0432\u0435\u0440\u0435<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/golang\/go\/commit\/c80022204e8fc36ec487888d471de27a5ea47e17\"><u>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0433\u0430 \u0441\u00a0 localhost \u0432 Go 1.16<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/golang\/go\/blob\/master\/src\/net\/conf.go\"><u>src\/net\/conf.go<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/golang\/go\/blob\/master\/src\/net\/dnsclient_unix.go\"><u>src\/net\/dnsclient_unix.go<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041a\u0430\u043a Linux \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435\u0437\u043e\u043b\u0432:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/man7.org\/linux\/man-pages\/man5\/resolv.conf.5.html\"><u>man resolv.conf<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/zwischenzugs.com\/2018\/06\/08\/anatomy-of-a-linux-dns-lookup-part-i\/\"><u>Anatomy of a Linux DNS Lookup (en)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.kickflop.net\/blog\/2011\/01\/02\/tracing-linux-hostname-resolution\/\"><u>Tracing Linux Hostname Resolution (en)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/352300\/\"><u>Resolve IP addresses in Linux (ru)<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438-\u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/www.weave.works\/blog\/racy-conntrack-and-dns-lookup-timeouts\"><u>Racy conntrack and DNS lookup timeouts (en)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/blog.quentin-machu.fr\/2018\/06\/24\/5-15s-dns-lookups-on-kubernetes\/\"><u>5 \u2013 15s DNS lookups on Kubernetes (en)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/engineering.grab.com\/dns-resolution-in-go-and-cgo\"><u>DNS Resolution in Go and Cgo (en)<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/570936\/\"> https:\/\/habr.com\/ru\/articles\/570936\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-402149","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/402149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=402149"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/402149\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=402149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=402149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=402149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}