Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a laptop with debian. Networking is configured with NetworkManager. Now occasionally I want to connect a device to its wired ethernet port and then bridge wireless to it. That all works in so far: I need to terminate NetworkManager first manually to ignore the ethernet port or else it is going to try to configure it which interferes with the static address required. My question now is: how can I, using a dbus command, say to NetworkManager that it should ignore eth0 for a while? And later to manage it again?

share|improve this question
add comment

3 Answers 3

up vote 1 down vote accepted

From the Debian wiki:

As of Debian Squeeze, NetworkManager does not manage any interface defined in /etc/network/interfaces by default.

So you should maybe put the static Ethernet configuration in the interfaces file and prevent NetworkManager from managing it altogether. I think you can also do some interface mapping to automatically switch between using the bridged configuration and the "normal" one as needed.

share|improve this answer
    
as far as i remember, you have to restart network manager after that to take effect. Which is more complicated than simply stopping it. –  BatchyX Apr 28 '13 at 20:25
    
@BatchyX Not really sure what you mean. I'm suggesting that the OP should prevent NetworkManager from managing their eth0 (or equivalent) interface. All it would cost is one restart of NetworkManager. –  Joseph R. Apr 28 '13 at 20:37
    
The OP reads temporarily ignore an interface. It's even in the title! –  BatchyX Apr 29 '13 at 6:59
    
@BatchyX I have seen that. Please read the OP again carefully. Making NetworkManager temporarily ignore an interface, isn't an end in itself. It's the solution the OP found to his problem. I'm suggesting (what I think is) a better approach to his original problem that would allow him to switch between configurations automatically without resorting to a "dbus command". –  Joseph R. Apr 29 '13 at 9:20
add comment

I'm afraid that that is not possible. The D-Bus API allows you to disable all kinds of wireless devices, but not the wired ones. The only way to disable wired connections is to disable all devices, including your wireless device.

Maybe it helps to untick the "Connect automatically" box for your wired device. That way NetworkManager won't automatically connect to it.

share|improve this answer
add comment

This is what I found from nmcli man-pages. I don't know which distributions this applies, but I'm using Ubuntu 12.04 LTS

This will mark device to disconnect state so it's outside network-manager control

nmcli dev disconnect iface eth0 

This is fine as long as I don't disconnect the cable.

You can check device status with:

nmcli dev status

And currently active connections with:

nmcli con status

I created this helper script nm-manual-interface

#!/bin/bash

DEV=${1:-help}
shift

OPER=${1:-manual}
shift


if [ "$DEV" == "help" ]; then
echo -n "$0 "
  cat <<'EOH';
<DEV> [manual|auto]

Change <DEV> to disconnected state for nm.
In short take manual control of <DEV>.

All changes are temporary.

Usage:

Change to manual:
EOH
echo $0 eth0 manual
echo
echo Change back to nm control:
echo $0 eth0 auto
echo
  exit 1
fi
# store last uuid of device here
LASTUUIDFILE="/tmp/.nm-last-uuid-${DEV}"


if [ "$OPER" == "manual" ]; then
  if [ -n "$DEV"  ] ; then
    UUIDNET=$(nmcli con status |grep "$DEV" | perl -anle 'print @F[1]')
    if [ -n "$UUIDNET" ]; then 
      echo "$UUIDNET"  > $LASTUUIDFILE
      nmcli dev disconnect iface "$DEV"
    fi
  fi
fi

if [ "$OPER" == "auto" ]; then
  if [ -f "$LASTUUIDFILE" ]; then
     nmcli con up uuid $(cat "$LASTUUIDFILE") --nowait
     rm "$LASTUUIDFILE"
  else
    echo No last-state uuid file for iface "$DEV"
  fi
fi
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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