could anyone list the complete structure of the configuration files, which network manager stores for known networks in /etc/NetworkManager/system-connections for known networks?

Sample (filename askUbuntu):

[connection]
id=askUbuntu
uuid=81255b2e-bdf1-4bdb-b6f5-b94ef16550cd
type=802-11-wireless

[802-11-wireless]
ssid=askUbuntu
mode=infrastructure
mac-address=00:08:CA:E6:76:D8

[ipv6]
method=auto

[ipv4]
method=auto

I would like to create some of them by my own using a script. However, before doing so I would like to know every possible option.

Furthermore, this structure seems somehow to resemble the information you can get using the dbus for active connections.

dbus-send --system --print-reply \
    --dest=org.freedesktop.NetworkManager \
    "$active_setting_path" \ # /org/freedesktop/NetworkManager/Settings/2
    org.freedesktop.NetworkManager.Settings.Connection.GetSettings 

Will tell you:

array [
  dict entry(
     string "802-11-wireless"
     array [
        dict entry(
           string "ssid"
           variant                   array of bytes "askUbuntu"
        )
        dict entry(
           string "mode"
           variant                   string "infrastructure"
        )
        dict entry(
           string "mac-address"
           variant                   array of bytes [
                 00 08 ca e6 76 d8
              ]
        )
        dict entry(
           string "seen-bssids"
           variant                   array [
                 string "02:1A:11:F8:C5:64"
                 string "02:1A:11:FD:1F:EA"
              ]
        )
     ]
  )
  dict entry(
     string "connection"
     array [
        dict entry(
           string "id"
           variant                   string "askUbuntu"
        )
        dict entry(
           string "uuid"
           variant                   string "81255b2e-bdf1-4bdb-b6f5-b94ef16550cd"
        )
        dict entry(
           string "timestamp"
           variant                   uint64 1383146668
        )
        dict entry(
           string "type"
           variant                   string "802-11-wireless"
        )
     ]
  )
  dict entry(
     string "ipv4"
     array [
        dict entry(
           string "addresses"
           variant                   array [
              ]
        )
        dict entry(
           string "dns"
           variant                   array [
              ]
        )
        dict entry(
           string "method"
           variant                   string "auto"
        )
        dict entry(
           string "routes"
           variant                   array [
              ]
        )
     ]
  )
  dict entry(
     string "ipv6"
     array [
        dict entry(
           string "addresses"
           variant                   array [
              ]
        )
        dict entry(
           string "dns"
           variant                   array [
              ]
        )
        dict entry(
           string "method"
           variant                   string "auto"
        )
        dict entry(
           string "routes"
           variant                   array [
              ]
        )
     ]
  )
]

I can create new setting files using the dbus (AddSettings() in /org/freedesktop/NetworkManager/Settings) passing this type of input, so explaining me this structure and telling me all possible options will also help. Afaik, this is a Dictionary{String, Dictionary{String, Variant}}.

Will there be any difference creating config files directly or using the dbus?

That file isn't meant to be edited by the user, but by the Network Manager tools. You can read the manual using:

man nm-settings

FILES

  /etc/NetworkManager/system-connections

  or distro plugin-specific location

The list is too long/extensive and could change any moment, so using the manual page is recommended since it is synchronized with your NM version.

Adding to Braiam's answer (it would be too long for a comment), some potentially useful details to avoid address/identifier collision in your keyfile named /etc/NetworkManager/system-connections/askUbuntu above:

1) for not colliding with an already existing UUID in your system, you can create a random UUID running uuidgen at terminal and pasting its output in the key uuid= in the section [connection] in the file /etc/NetworkManager/system-connections/askUbuntu.

2) for not colliding with another IPv4 already in use (let's say) in your domestic home network (safe and sound within you gateway), you can choose an address in the range from 192.168.0.0 through 192.168.255.255 and then, in the section [ipv4], you change the key method= to manual and create the key address1= with your choice of address.

2.1) in case you are out of ideas for an address, you can run shuf -i 1:255 -n 2 in the terminal to get the last to position -- one chance in 65k of collision

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.