Coder Social home page Coder Social logo

labonte-lucpaul / ifbind Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 403 KB

Bind two network interfaces to simulate a loop back.

License: GNU Affero General Public License v3.0

CMake 0.51% C++ 98.26% Makefile 0.72% Dockerfile 0.31% Shell 0.21%
bridge networks l2tp l2tptunnel tunnel tunnelling loopback

ifbind's Introduction

ifbind

Bind two network interfaces to simulate a loop back.

This program was created as an alternative to bind two L2TP network interfaces. Using brctl didn't work.

Build

sudo make apt-deps
make build
sudo make install

Usage

Help

To print the help for the arguments: ./ifbind --help

Simple bind

sudo ./ifbind --bind tunnel1:tunnel2 --bind tunnel3:tunnel4

or

sudo ./ifbind --bind tunnel1:tunnel2,tunnel3:tunnel4

Debug

To activate the debug level and view each time a packets is being forwarded: use the --debug (or -d) argument.

sudo ./ifbind --debug --bind tunnel1:tunnel2

Interactive Mode

To use the interactive mode use the argument --interactive (or -i).

The interactive mode allow you to connect/disconnect binded interfaces by providing a CLI.
Note that the logs are outputed in the fine ifbind.log located in pwd.

To view a list of commands, in the CLI type help.

ifbind's People

Contributors

labonte-lucpaul avatar luclabonte avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ifbind's Issues

logs show wrong logger name

[2020-06-04 12:07:57.774] [ifbinder] [debug] Sending packet tsw-port6 -> tsw-port5

ifbinder should be ifbind.

Release 2.3.1 requires 'libssl.so.1.0.0' shared library (among other)

Library dependencies of 2.3.1

$ ldd ./tools/ifbind
	linux-vdso.so.1 (0x00007ffdea579000)
	libcurl-gnutls.so.4 => /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 (0x00007f3b05f24000)
	libpcap.so.0.8 => /usr/lib/x86_64-linux-gnu/libpcap.so.0.8 (0x00007f3b05ed9000)
	libssl.so.1.0.0 => not found
	libcrypto.so.1.0.0 => not found
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3b05cf7000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3b05ba8000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f3b05b8b000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3b05b68000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3b05976000)
	libnghttp2.so.14 => /usr/lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007f3b0594d000)
	libidn2.so.0 => /usr/lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f3b0592c000)
	librtmp.so.1 => /usr/lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f3b0590c000)
	libssh.so.4 => /usr/lib/x86_64-linux-gnu/libssh.so.4 (0x00007f3b0589c000)
	libpsl.so.5 => /usr/lib/x86_64-linux-gnu/libpsl.so.5 (0x00007f3b05889000)
	libnettle.so.7 => /usr/lib/x86_64-linux-gnu/libnettle.so.7 (0x00007f3b0584f000)
	libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f3b05679000)
	libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f3b0562c000)
	libldap_r-2.4.so.2 => /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007f3b055d6000)
	liblber-2.4.so.2 => /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f3b055c3000)
	libbrotlidec.so.1 => /usr/lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007f3b055b5000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f3b05599000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f3b05fd5000)
	libunistring.so.2 => /usr/lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f3b05417000)
	libhogweed.so.5 => /usr/lib/x86_64-linux-gnu/libhogweed.so.5 (0x00007f3b053e0000)
	libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f3b0535a000)
	libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f3b05084000)
	libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f3b04f4e000)
	libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f3b04f38000)
	libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f3b04e5b000)
	libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f3b04e28000)
	libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f3b04e21000)
	libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f3b04e12000)
	libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f3b04df6000)
	libsasl2.so.2 => /usr/lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f3b04dd9000)
	libgssapi.so.3 => /usr/lib/x86_64-linux-gnu/libgssapi.so.3 (0x00007f3b04d94000)
	libbrotlicommon.so.1 => /usr/lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007f3b04d6f000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3b04d69000)
	libffi.so.7 => /usr/lib/x86_64-linux-gnu/libffi.so.7 (0x00007f3b04d5d000)
	libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f3b04d56000)
	libheimntlm.so.0 => /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 (0x00007f3b04d4a000)
	libkrb5.so.26 => /usr/lib/x86_64-linux-gnu/libkrb5.so.26 (0x00007f3b04cb5000)
	libasn1.so.8 => /usr/lib/x86_64-linux-gnu/libasn1.so.8 (0x00007f3b04c0e000)
	libhcrypto.so.4 => /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 (0x00007f3b04bd6000)
	libroken.so.18 => /usr/lib/x86_64-linux-gnu/libroken.so.18 (0x00007f3b04bbd000)
	libwind.so.0 => /usr/lib/x86_64-linux-gnu/libwind.so.0 (0x00007f3b04b93000)
	libheimbase.so.1 => /usr/lib/x86_64-linux-gnu/libheimbase.so.1 (0x00007f3b04b7f000)
	libhx509.so.5 => /usr/lib/x86_64-linux-gnu/libhx509.so.5 (0x00007f3b04b31000)
	libsqlite3.so.0 => /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f3b04a08000)
	libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f3b049cd000)

compared with dependencies of the previous version

$ ldd ./tools/ifbind
	linux-vdso.so.1 (0x00007ffebc965000)
	libpcap.so.0.8 => /usr/lib/x86_64-linux-gnu/libpcap.so.0.8 (0x00007f99fa5a0000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f99fa3be000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f99fa26f000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f99fa254000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f99fa231000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f99fa03f000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f99fa934000)

Having less dependencies is preferable, if possible.
One reason is that the host system does not require installation of system libraries, like OpenSSL or SQLite3, for example.

Get latest version

Use URI https://api.github.com/repos/Labonte-LucPaul/ifbind/releases/latest to get the latest version available and display message about new available version.

"tag_name"
Example:

{
  "url": "https://api.github.com/repos/Labonte-LucPaul/ifbind/releases/41592671",
  "assets_url": "https://api.github.com/repos/Labonte-LucPaul/ifbind/releases/41592671/assets",
  "upload_url": "https://uploads.github.com/repos/Labonte-LucPaul/ifbind/releases/41592671/assets{?name,label}",
  "html_url": "https://github.com/Labonte-LucPaul/ifbind/releases/tag/2.2.0",
  "id": 41592671,
  "author": {
    "login": "Labonte-LucPaul",
    "id": 2522843,
    "node_id": "MDQ6VXNlcjI1MjI4NDM=",
    "avatar_url": "https://avatars.githubusercontent.com/u/2522843?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/Labonte-LucPaul",
    "html_url": "https://github.com/Labonte-LucPaul",
    "followers_url": "https://api.github.com/users/Labonte-LucPaul/followers",
    "following_url": "https://api.github.com/users/Labonte-LucPaul/following{/other_user}",
    "gists_url": "https://api.github.com/users/Labonte-LucPaul/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/Labonte-LucPaul/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/Labonte-LucPaul/subscriptions",
    "organizations_url": "https://api.github.com/users/Labonte-LucPaul/orgs",
    "repos_url": "https://api.github.com/users/Labonte-LucPaul/repos",
    "events_url": "https://api.github.com/users/Labonte-LucPaul/events{/privacy}",
    "received_events_url": "https://api.github.com/users/Labonte-LucPaul/received_events",
    "type": "User",
    "site_admin": false
  },
  "node_id": "MDc6UmVsZWFzZTQxNTkyNjcx",
  "tag_name": "2.2.0",
  "target_commitish": "master",
  "name": "ifbind",
  "draft": false,
  "prerelease": false,
  "created_at": "2021-04-17T20:12:59Z",
  "published_at": "2021-04-17T20:16:23Z",
  "assets": [
    {
      "url": "https://api.github.com/repos/Labonte-LucPaul/ifbind/releases/assets/35279226",
      "id": 35279226,
      "node_id": "MDEyOlJlbGVhc2VBc3NldDM1Mjc5MjI2",
      "name": "ifbind",
      "label": null,
      "uploader": {
        "login": "Labonte-LucPaul",
        "id": 2522843,
        "node_id": "MDQ6VXNlcjI1MjI4NDM=",
        "avatar_url": "https://avatars.githubusercontent.com/u/2522843?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/Labonte-LucPaul",
        "html_url": "https://github.com/Labonte-LucPaul",
        "followers_url": "https://api.github.com/users/Labonte-LucPaul/followers",
        "following_url": "https://api.github.com/users/Labonte-LucPaul/following{/other_user}",
        "gists_url": "https://api.github.com/users/Labonte-LucPaul/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/Labonte-LucPaul/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/Labonte-LucPaul/subscriptions",
        "organizations_url": "https://api.github.com/users/Labonte-LucPaul/orgs",
        "repos_url": "https://api.github.com/users/Labonte-LucPaul/repos",
        "events_url": "https://api.github.com/users/Labonte-LucPaul/events{/privacy}",
        "received_events_url": "https://api.github.com/users/Labonte-LucPaul/received_events",
        "type": "User",
        "site_admin": false
      },
      "content_type": "application/octet-stream",
      "state": "uploaded",
      "size": 8028792,
      "download_count": 7,
      "created_at": "2021-04-17T20:16:08Z",
      "updated_at": "2021-04-17T20:16:15Z",
      "browser_download_url": "https://github.com/Labonte-LucPaul/ifbind/releases/download/2.2.0/ifbind"
    }
  ],
  "tarball_url": "https://api.github.com/repos/Labonte-LucPaul/ifbind/tarball/2.2.0",
  "zipball_url": "https://api.github.com/repos/Labonte-LucPaul/ifbind/zipball/2.2.0",
  "body": "* Fix issue when stats didn't display if interface did not received traffic\r\n* Add command to clear stats in interactive mode"
}

Infinite loop

If bind can sometimes fall into an infinite loop.

When closing logs show wrong values

^C[2020-06-04 12:10:29.096] [ifbinder] [info] Caught signal (2). [2020-06-04 12:10:29.096] [ifbinder] [info] Stopping bind tsw-port5 <=> tsw-port6 [2020-06-04 12:10:29.622] [ifbinder] [info] Stopping bind tsw-port5 <=> tsw-port6 [2020-06-04 12:10:29.622] [ifbinder] [info] Stopping bind tsw-port5 <=> tsw-port6

Should be:
^C[2020-06-04 12:10:29.096] [ifbinder] [info] Caught signal (2). [2020-06-04 12:10:29.096] [ifbinder] [info] Stopping bind tsw-port5 <=> tsw-port6 [2020-06-04 12:10:29.622] [ifbinder] [info] Stopping bind thread tsw-port5 -> tsw-port6 [2020-06-04 12:10:29.622] [ifbinder] [info] Stopping bind thread tsw-port6 -> tsw-port5

Crashed after throwing instance of 'Tins::pcap_error'

$ ./ifbind -B t30-1:t31-1,t30-2:t31-2 -I 
logfile: "/home/dumitru/work/noviapp-automation/tools/ifbind.log"
Interactive mode
Type 'help' to list a set of commands

> list
1: t30-1 <=> t31-1 disconnected
2: t30-2 <=> t31-2 disconnected
> start
> terminate called recursively
terminate called after throwing an instance of 'Tins::pcap_error'
Aborted (core dumped)

Unfortunately I don't have the logs..
I think what happened was that 'ifbind' did not have permission to start capture on t30-.. interfaces, but I could be wrong.

Import a config file for binding

Import a config file with pre-defined binding interfaces. If interface, append arguments binding.
TBD format

  • json
  • text file with same as argument
  • bind direction with ->

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.