Releases/0.2/NetmCli

Network Manager Command Line

Since we still don't have a graphical interface for the Network Manager, you need to use netm-cli if you want to connect to a wireless network.

netm-cli is based on  network-manager-cli, but with lots of modifications.

If you want to see the code, see the  git repository.

Using netm-cli

Software usage:

$ netm-cli -h
Usage: netm-cli [options]

Command Line interface for Network Manager

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit

  Common Options:
    -c, --connect       connect to a network
    -d DEVICE, --device=DEVICE
                        which device to use
    -e ESSID, --essid=ESSID
                        connect to the network named essid
    -k HEXKEY, --hex-key=HEXKEY
                        hex key used to connect to a network (WEP and WPA)
    -l, --list-devices  list device(s) info
    -n, --list-networks
                        list networks
    -m, --monitor-signals
                        monitor DBUS signals
    -S, --nm-status     shows current NM status
    -t CONTYPE, --connection_type=CONTYPE
                        connection type to connect (OPEN, WEP, WPA, WPA2)
    -s, --sleep         put NetworkManager to sleep
    -w, --wake-up       wake NetworkManager up
    -v, --verbose       verbose info

  WEP Options:
    --wep-auth=WEP_ALG  WEP authentication method (open or shared)

  WPA Options:
    --wpa-pairwise=WPA_PAIRWISE
                        WPA pairwise cipher (CCMP or TKIP)

  Config Options:
    --save-config       save the options to the config file

Report bugs to <rsalveti@gmail.com>.

Listing Devices and Networks

You can list the devices info with -l and the networks (for wireless devices) with -n.

Example:

$ netm-cli -ln
  wlan0*   HW Address:        00:1C:B3:C5:35:73
          Status:            Unknown
          Type:              802.11 Wireless
          IP Address:        10.0.1.165
          Netmask:           0.0.0.0
          Broadcast:         0.0.0.0
          Gateway:           0.0.0.0
          Primary DNS:       0.0.0.0
          Secondary DNS:     0.0.0.0
          Networks:
           mamonaairport   chan 11  freq 2.462 Ghz  strength 35%  rate 62 Mb/s  type WEP
         HCC001A92D92499   chan 11  freq 2.462 Ghz  strength 52%  rate 62 Mb/s  type WEP
               oxentenet   chan  9  freq 2.452 Ghz  strength 51%  rate 62 Mb/s  type WPA2
              OSMTCAPN01   chan  1  freq 2.412 Ghz  strength 21%  rate 62 Mb/s  type WPA2
                demoroom   chan  6  freq 2.437 Ghz  strength 51%  rate 54 Mb/s  type WPA2
                     ef1   chan  1  freq 2.412 Ghz  strength 20%  rate 62 Mb/s  type WPA
           5put1n1kr6250   chan  6  freq 2.437 Ghz  strength 17%  rate 54 Mb/s  type WEP
                LiteShow   chan 11  freq 2.462 Ghz  strength 31%  rate 54 Mb/s  type OPEN
              ASUS_OSMTC   chan 11  freq 2.462 Ghz  strength 65%  rate 62 Mb/s  type WPA2
                XXacbvXX   chan  5  freq 2.432 Ghz  strength 14%  rate 54 Mb/s  type OPEN
       linksys_SES_39848   chan  6  freq 2.437 Ghz  strength 12%  rate 62 Mb/s  type WPA
               XXacbv2XX   chan  3  freq 2.422 Ghz  strength 11%  rate 54 Mb/s  type OPEN
                     TSI   chan  6  freq 2.437 Ghz  strength  7%  rate 62 Mb/s  type WPA
            chenca-wifi2   chan  6  freq 2.437 Ghz  strength 31%  rate 62 Mb/s  type WPA2
           Brasil.Net_03   chan  1  freq 2.412 Ghz  strength 10%  rate 62 Mb/s  type OPEN
           5put1n1ka5251   chan  7  freq 2.442 Ghz  strength  8%  rate 54 Mb/s  type OPEN
               XXderbyXX   chan 10  freq 2.457 Ghz  strength  7%  rate 54 Mb/s  type OPEN
       Ed. Sobrado Shopping   chan  6  freq 2.437 Ghz  strength 11%  rate 54 Mb/s  type OPEN
                 wntista   chan 10  freq 2.457 Ghz  strength  8%  rate 54 Mb/s  type OPEN

  eth0*   HW Address:        00:1B:63:A8:61:88
          Status:            Activated
          Type:              Wired
          IP Address:        192.168.3.58
          Netmask:           255.255.252.0
          Broadcast:         192.168.3.255
          Gateway:           192.168.1.1
          Primary DNS:       192.168.1.2
          Secondary DNS:     192.168.1.8

Connecting to a OPEN network

To connect to a OPEN network you just need to give the device, the ESSID and the connection type as OPEN:

$ netm-cli -c -d wlan0 -e mamonawifi -t OPEN

Connecting to a WEP network

To connect to a WEP network you need to give the device, the ESSID, the connection type as WEP, the WEP authentication method and the hex key:

$ netm-cli -c -d wlan0 -e mamonawifi -t WEP --wep-auth=open -k 5555555555

Just remember that the key is already in hexadecimal. netm-cli will only accept wep keys of 10 or 26 hex digits long.

Connecting to a WPA1 - TKIP network

To connect to a WPA1 - TKIP network you need to give the device, the ESSID, the connection type as WPA, WPA pairwise cipher and the hex key:

$ netm-cli -c -d wlan0 -e mamonawifi -t WPA --wpa-pairwise=TKIP -k 5bf2cbdccb0b13b2625ee92968ec538501612f22c7884315b6939e1eebfd7 

Just remember that the key is already in hexadecimal, use wpa_passphrase if you need to generate the hex key with the plain text password.

Connecting to a WPA2 - CCMP/AES network

To connect to a WPA2 - CCMP/AES network you need to give the device, the ESSID, the connection type as WPA2, WPA pairwise cipher and the hex key:

$ netm-cli -c -d wlan0 -e mamonawifi -t WPA2 --wpa-pairwise=CCMP -k 5bf2cbdccb0b13b2625ee92968ec538501612f22c7884315b6939e1eebfd7

Just remember that the key is already in hexadecimal, use wpa_passphrase if you need to generate the hex key with the plain text password.

Connecting to a WPA2 - TKIP + AES network

To connect to a WPA2 - TKIP + AES network you need to give the device, the ESSID, the connection type as WPA2, WPA pairwise cipher and the hex key:

$ netm-cli -c -d wlan0 -e mamonawifi -t WPA2 --wpa-pairwise=TKIP -k 5bf2cbdccb0b13b2625ee92968ec538501612f22c7884315b6939e1eebfd7

Just remember that the key is already in hexadecimal, use wpa_passphrase if you need to generate the hex key with the plain text password.

Using monitor mode

If you want to see what's happening to the Network Manager while you connect, or just to see the current status, you can use the option -m, --monitor-signals to enter at the monitor mode:

$ netm-cli -c -d wlan0 -e mamonawifi -t WPA2 --wpa-pairwise=TKIP -k 5bf2cbdccb0b13b2625ee92968ec538501612f22c7884315b6939e1eebfd7 -m
Signals successfully added.
/org/freedesktop/NetworkManager/Devices/wlan0 is about to become active
/org/freedesktop/NetworkManager/Devices/wlan0/Networks/HCC001A92D92499 strength changed to 52
/org/freedesktop/NetworkManager/Devices/wlan0/Networks/mamonaairport strength changed to 35
/org/freedesktop/NetworkManager/Devices/wlan0/Networks/oxentenet strength changed to 54
/org/freedesktop/NetworkManager/Devices/wlan0/Networks/mamonawifi strength changed to 10
/org/freedesktop/NetworkManager/Devices/wlan0/Networks/Walker strength changed to 14
/org/freedesktop/NetworkManager/Devices/wlan0 strength changed to 98
...

You can use the monitor mode with any other option you want.

Saving and using netm-cli config

If you like, you can ask netm-cli to save your connection options with --save-config. netm-cli will save your options at ~/.netm-cli, so you can connect to a wireless network without giving all options all the time.

Saving the config:

$ netm-cli -c -d wlan0 -e mamonawifi -t WPA2 --wpa-pairwise=TKIP -k 5bf2cbdccb0b13b2625ee92968ec538501612f22c7884315b6939e1eebfd7 --save-config

Config:

$ cat ~/.netm-cli
[wlan0]
hexkey = 5bf2cbdccb0b13b2625ee92968ec538501612f22c7884315b6939e1eebfd7
contype = WPA2
essid = mamonawifi
wpa_pairwise = TKIP

Connecting using the config:

$ netm-cli -c -d wlan0