Giter Site home page Giter Site logo

njail's Introduction

Njail

Simple wrapper to manage network namespaces ip netns, useful to run certain programs through a vpn or completly disallow any network access.

Example

Drop all traffic

------------------------------------------------------------
~/workspaces/bash/njail(master) » sudo ./njail.sh -i enp+ -n test -q
------------------------------------------------------------
~/workspaces/bash/njail(master) » sudo ip netns exec test pin 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=43 time=34.2 ms
^C
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 34.232/34.232/34.232/0.000 ms
------------------------------------------------------------
~/workspaces/bash/njail(master) » sudo ip netns exec test curl -I google.com 
HTTP/1.1 302 Found
Cache-Control: private
[...]
------------------------------------------------------------
~/workspaces/bash/njail(master) » sudo ./dropall.sh test
------------------------------------------------------------
~/workspaces/bash/njail(master) » sudo ip netns exec test ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
ping: sendmsg: Operation not permitted
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1011ms
------------------------------------------------------------
~/workspaces/bash/njail(master) » sudo ip netns exec test curl -I google.com 
curl: (6) Could not resolve host: google.com
------------------------------------------------------------
~/workspaces/bash/njail(master) » sudo ./njail.sh -i enp+ -n test -c -q 

Route traffic through VPN

~/workspaces/bash/njail(master) » sudo ./njail.sh -i enp+ -n vpn -q
------------------------------------------------------------
~/workspaces/bash/njail(master) » sudo ./vpn.sh -n vpn -a "185.100.84.135/32,185.100.84.244/32,185.100.84.245/32,185.100.84.247/32,185.100.84.246/32" -c "/etc/openvpn/client/romania_bucharest-aes256-udp.conf" -d 8.8.8.8
Sun May 28 12:26:30 2017 OpenVPN 2.4.2 x86_64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on May 11 2017
Sun May 28 12:26:30 2017 library versions: OpenSSL 1.1.0e  16 Feb 2017, LZO 2.10
Sun May 28 12:26:30 2017 Outgoing Control Channel Authentication: Using 512 bit message hash 'SHA512' for HMAC authentication
Sun May 28 12:26:30 2017 Incoming Control Channel Authentication: Using 512 bit message hash 'SHA512' for HMAC authentication
Sun May 28 12:26:30 2017 TCP/UDP: Preserving recently used remote address: [AF_INET]185.100.84.244:50000
Sun May 28 12:26:30 2017 Socket Buffers: R=[212992->212992] S=[212992->212992]
Sun May 28 12:26:30 2017 UDP link local: (not bound)
[...]
------------------------------------------------------------
~/workspaces/bash/njail(master) » curl ifconfig.co/country
Austria
------------------------------------------------------------
~/workspaces/bash/njail(master) » sudo ip netns exec vpn curl ifconfig.co/country
Romania

njail's People

Contributors

dav1dde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.