RE: How to generate "Auto eth0" from command line ?



On Tue, 2012-01-17 at 14:58 +0000, ning ji wrote:
> Hi Mathieu,
> 
> Thanks for the "uuidgen".
> 
> Regarding no "Auto eth0" initially,
> my task is to make it work in embedded board, so there's no GUI.
> 
> step 1: I tried from scratch, no "Auto eth0", it's in DHCP mode, it
> works.
> Then from GUI i set it to static ip. It generates "auto eth0". I keep
> this file in another place call it "mycfg.static".
> Then move back to DHCP from GUI, then remove
> the /etc/NetworkManager/Auto eth0.
> 
> step 2: After reboot, the system is in a fresh new state, no "Auto
> eth0".
> copy "mycfg.static" to /etc/NetworkManager/Auto eth0.
> 
> step 3: from "network configurations" i saw 2 interfaces, somehow it
> takes a default somewhere again.
> 
> 
> So my question is, can i switch from dhcp to static without GUI, as
> this is our requirement ?

There are some Python examples in NetworkManager git if you want to use
the D-Bus control interface.  Alternatively, it's certainly possible to
simply generate connection files and move them around as you see fit.
When you move a connection file out
of /etc/NetworkManager/system-connections NM should tear down the
connection, and dropping a new file in there should make NM connect it
as long as autoconnect=true in that file in the [connection] section.

For the dbus interface, you'd grab the connection settings (I'd just
store the UUID and request the connection via its UUID), make the
changes to the settings, call the connection's Update method with the
new settings, and (optionally) tell NM to activate the connection again
to apply the new settings you just wrote.

http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python
http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/C/glib

If can describe in a bit more detail what you'd like to do I can point
you more closely in the right direction.

Dan

> 
> Thanks very much !
> 
> 
> 
> 
> 
> > Date: Mon, 16 Jan 2012 23:28:58 +0100
> > Subject: Re: How to generate "Auto eth0" from command line ?
> > From: mathieu tl gmail com
> > To: ningji hotmail com
> > 
> > On Sat, Jan 14, 2012 at 11:16 PM, ning ji <ningji hotmail com>
> wrote:
> > > Hi i'm new to NetworkManager.
> > >
> > > In ubuntu 10.4, if i remember this correctly, by default,
> > > there's NO "Auto Eth0" under /etc/NetworkManager/...
> > >
> > > If in the menu i edit eth0 to use static ip, there'll be a "Auto
> Eth0“ file.
> > >
> > > 1. My question is how to generate this file from command line ?
> > >
> > > 2. How to generate uuid for eth0, heard there's a "blkid" command,
> > > but /dev/eth0 is not available in linux ?
> > 
> > There already should be one -- but it won't show in
> > /etc/NetworkManager, because it's automatically created by NM when
> > used. In other words, make sure nm-applet is running, then plug in a
> > cable and things should just work.
> > 
> > In 10.04, you might be able to use cnetworkmanager (from the
> > cnetworkmanager package) to do this.
> > 
> > As for your question about UUIDs, try 'uuidgen -r'.
> > 
> > Mathieu Trudel-Lapierre <mathieu tl gmail com>
> > Freenode: cyphermox, Jabber: mathieu tl gmail com
> > 4096R/EE018C93 1967 8F7D 03A1 8F38 732E FF82 C126 33E1 EE01 8C93
> 
> _______________________________________________
> networkmanager-list mailing list
> networkmanager-list gnome org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]