DNS Server IP

Hi,

I am using connmanctl to set the IP of the module. If I set the DHCP to auto, connmanctl updates the nameserver field with the local DNS server we have. However if I set the DHCP to manual, I have to set the nameserver manually.

Is there any way that I could grab the DNS ip in Linux when DHCP is set to auto ?

Thanks

Hi

I don’t understand the question. Could you elaborate some more?

Max

Sorry.

In my application, I want the user to be able to set the module IP, Network Mask, Gateway IP, and DNS address. I am able to get current IP Address, Network Mask, Gateway Ip but the DNS address.

How can I get current DNS address and then display it to the user ?

Please let me know if you need any more information.

Hi

From the commandline you could try to parse the connmanctl output for the nameserver address:

root@colibri-imx6:~# connmanctl services
*AO Wired                ethernet_00142d4a4bf7_cable

root@colibri-imx6:~# connmanctl services ethernet_00142d4a4bf7_cable
/net/connman/service/ethernet_00142d4a4bf7_cable
  Type = ethernet
  Security = [  ]
  State = online
  Favorite = True
  Immutable = False
  AutoConnect = True
  Name = Wired
  Ethernet = [ Method=auto, Interface=eth0, Address=00:14:2D:4A:4B:F7, MTU=1500 ]
  IPv4 = [ Method=dhcp, Address=192.168.0.34, Netmask=255.255.255.0, Gateway=192.168.0.32 ]
  IPv4.Configuration = [ Method=dhcp ]
  IPv6 = [  ]
  IPv6.Configuration = [ Method=auto, Privacy=disabled ]
  Nameservers = [ 192.168.0.32 ]
  Nameservers.Configuration = [  ]
  Timeservers = [ 192.168.0.32 ]
  Timeservers.Configuration = [  ]
  Domains = [ fritz.box ]
  Domains.Configuration = [  ]
  Proxy = [ Method=direct ]
  Proxy.Configuration = [  ]
  Provider = [  ]

Or you could try to query connmand over its dbus API:

root@colibri-imx6:~# dbus-send --system --dest=net.connman --print-reply / net.connman.Manager.GetServices

method return time=1499885555.103383 sender=:1.3 -> destination=:1.27 serial=83 reply_serial=2
   array [
      struct {
         object path "/net/connman/service/ethernet_00142d4a4bf7_cable"
         array [
            dict entry(
               string "Type"
               variant                   string "ethernet"
...
            dict entry(
               string "Nameservers.Configuration"
               variant                   array [
                  ]
            )
...
   ]
root@colibri-imx6:~#