@@ -17,7 +17,7 @@ import (
1717var (
1818 resolverPath = paths .ResolverDir + "/internal"
1919 globalServer * Server
20- containerDNSIP string
20+ darwinDNSPort = 5533
2121)
2222
2323type DnsRecord struct {
@@ -26,13 +26,11 @@ type DnsRecord struct {
2626}
2727
2828func SetupLocalDNS (subnetID int ) error {
29- containerDNSIP = fmt .Sprintf ("10.200.%d.1" , subnetID )
30-
31- if err := ConfigureClientDNS (containerDNSIP ); err != nil {
29+ if err := ConfigureClientDNS ("127.0.0.1" ); err != nil {
3230 return fmt .Errorf ("failed to configure local DNS: %w" , err )
3331 }
3432
35- globalServer = NewServer (DNSPort , containerDNSIP )
33+ globalServer = NewServer (darwinDNSPort , "127.0.0.1" )
3634 if err := globalServer .Start (context .Background ()); err != nil {
3735 return fmt .Errorf ("failed to start DNS server: %w" , err )
3836 }
@@ -41,15 +39,15 @@ func SetupLocalDNS(subnetID int) error {
4139}
4240
4341func GetContainerDNS () string {
44- return containerDNSIP
42+ return ""
4543}
4644
4745func ConfigureClientDNS (dnsIP string ) error {
4846 if err := os .MkdirAll (paths .ResolverDir , 0o755 ); err != nil {
4947 return fmt .Errorf ("failed to create resolver dir: %w" , err )
5048 }
5149
52- config := fmt .Sprintf ("nameserver %s\n " , dnsIP )
50+ config := fmt .Sprintf ("nameserver %s\n port %d \ n " , dnsIP , darwinDNSPort )
5351
5452 if err := os .WriteFile (resolverPath , []byte (config ), 0o644 ); err != nil {
5553 return fmt .Errorf ("failed to write resolver config: %w" , err )
0 commit comments