You are not logged in.

#1 2012-03-18 13:55:40

shadyabhi
Member
From: Bangalore
Registered: 2010-05-23
Posts: 262
Website

[SOLVED] Change the state of iface from disconnected to connected

I am using conky and to display up/down rate using

${if_up wlan0} wlan0: ${downspeed wlan0}/s | ${goto 810} ${upspeed wlan0}/s ${goto 875}${endif} ${if_up eth0} eth0: ${downspeed eth0}/s ${goto 800} |

I have configured conky such that conditions like ${if_up wlan0} are satisfied only when an interface has an address using

#Strictnes of eth0
if_up_strictness address

in the conkyrc.

Which causes conky to display interface like this. (Only one at a time, never both eth0 and wlan0).
FluxBB bbcode test

Now, lets suppose I am using eth0 and wlan0 is disabled. I enable wireless and connect to an access point, I have a dispatcher script that changes the state of eth0 to disconnected.

if [ $INTERFACE = "wlan0" ] && [ $STATUS = "up" ];then
        nmcli dev disconnect iface eth0
fi

I do this so that IP address of eth0 is released and ${if_up eth0} causes the eth0 part to not being displayed as I only want only the interface I am using to be displayed in conky.

QUESTION: Now, when I disconnect wlan0, I want to make the state of eth0 to be connected again. I have tried looking at the options in nmcli, there is an option under dev to disconnect but no option to revert the effect of disconnect.

Last edited by shadyabhi (2012-03-18 19:55:22)

Offline

#2 2012-03-18 16:46:09

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: [SOLVED] Change the state of iface from disconnected to connected

ip link set eth0 up

Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2012-03-18 16:59:47

shadyabhi
Member
From: Bangalore
Registered: 2010-05-23
Posts: 262
Website

Re: [SOLVED] Change the state of iface from disconnected to connected

ewaller wrote:
ip link set eth0 up

Please not that by disconnecting, it doesn't mean that eth0 goes down. Just the ip is released.

shadyabhi@MBP-archlinux ~ $ ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 10.100.98.79  netmask 255.255.255.0  broadcast 10.100.98.255
        inet6 fe80::cabc:c8ff:fe9b:c43c  prefixlen 64  scopeid 0x20<link>
        ether c8:bc:c8:9b:c4:3c  txqueuelen 1000  (Ethernet)
        RX packets 8923  bytes 2653832 (2.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1388  bytes 201186 (196.4 KiB)
        TX errors 1  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 21  

shadyabhi@MBP-archlinux ~ $ nmcli dev disconnect iface eth0
Device state: 30 (disconnected)
shadyabhi@MBP-archlinux ~ $ ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet6 fe80::cabc:c8ff:fe9b:c43c  prefixlen 64  scopeid 0x20<link>
        ether c8:bc:c8:9b:c4:3c  txqueuelen 1000  (Ethernet)
        RX packets 9097  bytes 2741613 (2.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1394  bytes 201596 (196.8 KiB)
        TX errors 1  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 21  

shadyabhi@MBP-archlinux ~ $ 

Offline

#4 2012-03-18 17:09:33

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: [SOLVED] Change the state of iface from disconnected to connected

Sorry, I misunderstood what you meant by "disabled", and admittedly, did not read your command.

How about:

ip addr flush dev eth0

Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2012-03-18 18:04:40

shadyabhi
Member
From: Bangalore
Registered: 2010-05-23
Posts: 262
Website

Re: [SOLVED] Change the state of iface from disconnected to connected

ewaller wrote:

Sorry, I misunderstood what you meant by "disabled", and admittedly, did not read your command.

How about:

ip addr flush dev eth0

No, actually the thing is that the act of assigning the ip address is done using networkmanager (dhclient actually) so I have to instruct networkmanager to do that & I can't seem to find a way to do that. There is an option to disconnect but no option to connect.

Last edited by shadyabhi (2012-03-18 18:14:41)

Offline

#6 2012-03-18 18:39:58

Gcool
Member
Registered: 2011-08-16
Posts: 1,456

Re: [SOLVED] Change the state of iface from disconnected to connected

So if I understand correctly, you just want eth0 to request an ip again from the dhcp server? You can just run "dhclient eth0" in that case.


Burninate!

Offline

#7 2012-03-18 18:49:59

shadyabhi
Member
From: Bangalore
Registered: 2010-05-23
Posts: 262
Website

Re: [SOLVED] Change the state of iface from disconnected to connected

Gcool wrote:

So if I understand correctly, you just want eth0 to request an ip again from the dhcp server? You can just run "dhclient eth0" in that case.

No, if I execute the above command, networkmanager will not be the one to do the work & networkmanager will show that's it's not using eth0.

Basically, I want networkmanager to change the state to connected.

Offline

#8 2012-03-18 19:13:36

Gcool
Member
Registered: 2011-08-16
Posts: 1,456

Re: [SOLVED] Change the state of iface from disconnected to connected

Ok, I understand now. Perhaps try creating a profile for your eth0 interface and then running:

# nmcli con up id <profilename> iface eth0

Not 100% if this will do exactly what you want there (don't use networkmanager myself), but it's worth a shot.


Burninate!

Offline

#9 2012-03-18 19:55:09

shadyabhi
Member
From: Bangalore
Registered: 2010-05-23
Posts: 262
Website

Re: [SOLVED] Change the state of iface from disconnected to connected

Gcool wrote:
# nmcli con up id <profilename> iface eth0

This works. Thanks.

Offline

#10 2014-04-03 12:33:00

burninggramma
Member
Registered: 2012-11-11
Posts: 8

Re: [SOLVED] Change the state of iface from disconnected to connected

shadyabhi wrote:
Gcool wrote:
# nmcli con up id <profilename> iface eth0

This works. Thanks.

Sorry for necro, but what to do if I got no existing profile with eth0 connection? Should I just mock one up by creating a file into?

/etc/NetworkManager/system-connections

By doing that networkmanager does not interpret it as a profile. Even when I modify an existing one, networkmanager skips and removes it from the existing connections.

Last edited by burninggramma (2014-04-03 12:38:57)

Offline

#11 2014-04-03 16:22:03

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Change the state of iface from disconnected to connected

This is a pretty old thread and I think you should open a new one and link to this one, if you think it's relevant.

Systemd v197 happened in the meantime and introduced persistent net naming rules https://projects.archlinux.org/svntogit … 0f8bef7edb

I've never used NM, but I think you should read https://wiki.archlinux.org/index.php/Ne … vice_names and https://wiki.archlinux.org/index.php/Ne … i_examples

Offline

#12 2014-04-03 16:47:51

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: [SOLVED] Change the state of iface from disconnected to connected

I was on the fence about this one, but I agree with Karol.  Please go ahead and start a new thread and link back to this one if you feel this thread is relevant. 
I am going to go ahead and close this thead.

https://wiki.archlinux.org/index.php/Fo … Bumping.22


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB