Giter Club home page Giter Club logo

nsdo's Introduction

nsdo

nsdo (network namespace do) is a simple C program that runs a command inside a given Linux network namespace.

Effectively, it simplifies:

$ sudo ip netns exec myns sudo -u $USER myprogram

to

$ nsdo myns myprogram

Thanks to magic of the setuid bit, it initially has root privileges, which allows it to change its own network namespace, setuid() to the user who ran the command, and then exec() the requested command.

installation

If you're on Arch, you can build my AUR package.

Otherwise:

$ make
# make install

To change the default installation directory of /usr/local, set PREFIX to something else when you call make install.

openvpn example

I wrote this program because I run some applications under a VPN (e.g., clients for peer-to-peer protocols) and leave others untouched (like a game client).

For more details, see my blog post on the subject.

license

MIT/X11.

manpage

nsdo(1)               General Commands Manual              nsdo(1)

NAME
       nsdo - run a command in a network namespace

SYNOPSIS
       nsdo namespace command [args ...]

       nsdo { --version | -V }

DESCRIPTION
       Execute  command  as the current user/group in namespace, a
       Linux network namespace  set  up  with  iproute2  (see  ip-
       netns(8)).

       By   default,   iproute2   places   network  namespaces  in
       /var/run/netns/,  so  nsdo  searces  for  namespaces  there
       (including  namespace).   To  prevent  command  from easily
       escaping the namespace 'jail,' nsdo will exit if  the  cur‐
       rent namespace exists in that directory.  Consequently, you
       can not nest instances of nsdo.

OPTIONS
       --version, -V
              Instead of running a command, print  nsdo's  version
              and exit.

SEE ALSO
       ip(8), ip-netns(8), namespaces(7), nsenter(1)

                            2016-01-23                     nsdo(1)

nsdo's People

Contributors

ausbin avatar mbaynton avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.