# nmcli errors when adding more than one DNS server

**URL:** <https://forum.ansible.com/t/nmcli-errors-when-adding-more-than-one-dns-server/19837>\
**Category:** Ansible Project\
**Created:** [November 24, 2015, 3:35am UTC](https://forum.ansible.com/t/nmcli-errors-when-adding-more-than-one-dns-server/19837 "2015-11-24T03:35:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 24, 2015, 3:35am UTC](https://forum.ansible.com/t/nmcli-errors-when-adding-more-than-one-dns-server/19837/1 "2015-11-24T03:35:25Z")

</div>

The documentation states that multiple DNS entries should be formatted like so:

> |   
> A list of upto 3 dns servers, ipv4 format e.g. To add two IPv4 DNS server addresses: [“8.8.8.8 8.8.4.4”]  
>   
> Following that example, I get the error: “Error: failed to modify ipv4.dns: invalid IPv4 address ‘["216.xxx.xxx.xxx’.\n”  
>   
>   
> |
> 
> - | - |

The documentation provides examples that include:

```auto
# To add two IPv4 DNS server addresses:
-nmcli: conn_name=my-eth1 dns4=["8.8.8.8", "8.8.4.4"] state=present

When I follow that example, I end up with an extra params error and template expressions erro:
ERROR! this task 'nmcli' has extra params, which is only allowed in the following modules...
Always quote template expression brackets when they start a value...

---
- hosts: redacted
  user: redacted
  sudo: yes
  pre_tasks:
  - nmcli: 'conn_name="{{ ansible_interfaces[1] }}" 
              state=present 
              type=ethernet 
              ip4=redacted 
              gw4=redacted 
              dns4=["redacted", "8.8.8.8", "redacted"]'

I've tried swapping the quotes around, with singles inside and doubles outside, and got the same extra params error. I haven't cracked the syntax just right yet. 

I'd love a pointer for what to try next.

```

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 24, 2015, 4:19am UTC](https://forum.ansible.com/t/nmcli-errors-when-adding-more-than-one-dns-server/19837/2 "2015-11-24T04:19:41Z")

</div>

This error appears to be related to the other issue I was having, since the error spits out the same odd jibberish. I suspect line 505 of the code is related, meaning the dictionary is not reading/parsing cleanly:

|
| |
| 

dstr+=“%s: %s\n” % ( key, str\_val)

 |
| |

Anyway, for the DNS entries, it seemed to be happy with dns4="8.8.8.8, 216.125.253.131, 8.8.4.4" which is a hybrid of the two examples in the documentation.

However, I have lost my connection to the machine until I am on campus tomorrow or Wednesday, so I am going to be working on something else for now.
