Giter Club home page Giter Club logo

trawl's Introduction

trawl

A strong fishing net for dragging along the sea bottom to collect IP addresses and similar flotsam & jetsam.

Prints out network interface information to the console, much like ifconfig/ipconfig/ip/ifdata.

Go Report Card

trawl
eth1   10.62.10.6     255.255.255.252  10.62.10.4/30   1500  00:ff:28:31:d0:72  fe80::d824:2e8d:bf80:69c9/64  2
wifi0  192.168.1.242  255.255.255.0    192.168.1.0/24  1500  10:02:b5:e4:de:8c  fe80::ed51:1db6:b32:ad90/64   2

Flags

Show column names.

trawl -n
Name   IPv4 Address   IPv4 Mask        IPv4 Network    MTU   MAC Address        IPv6 Address                  Address Count
----   ------------   ---------        ------------    ---   -----------        ------------                  -------------
eth1   10.62.10.6     255.255.255.252  10.62.10.4/30   1500  00:ff:28:31:d0:72  fe80::d824:2e8d:bf80:69c9/64  2
wifi0  192.168.1.242  255.255.255.0    192.168.1.0/24  1500  10:02:b5:e4:de:8c  fe80::ed51:1db6:b32:ad90/64   2

Filter interface names using a case insensitive regular expression.

trawl -f wi
wifi0  192.168.1.242  255.255.255.0  192.168.1.0/24  1500  10:02:b5:e4:de:8c  fe80::ed51:1db6:b32:ad90/64  2trawl -n -f eth
Name  IPv4 Address  IPv4 Mask        IPv4 Network   MTU   MAC Address        IPv6 Address                  Address Count
----  ------------  ---------        ------------   ---   -----------        ------------                  -------------
eth1  10.62.10.6    255.255.255.252  10.62.10.4/30  1500  00:ff:28:31:d0:72  fe80::d824:2e8d:bf80:69c9/64  2

Get a list of available interfaces. Without any flags trawl only prints out interfaces which are up.

trawl -i
eth0, eth1, lo, wifi0, wifi1, eth2

The loopback interface is ignored by default, but you can include it if you like.

trawl -l
eth1   10.62.10.6     255.255.255.252  10.62.10.4/30   1500  00:ff:28:31:d0:72  fe80::d824:2e8d:bf80:69c9/64  2
lo     127.0.0.1      255.0.0.0        127.0.0.0/8     1500  -                  ::1/128                       2
wifi0  192.168.1.242  255.255.255.0    192.168.1.0/24  1500  10:02:b5:e4:de:8c  fe80::ed51:1db6:b32:ad90/64   2

Specify the particular interface you want to know about.

trawl wifi0
wifi0  192.168.1.242  255.255.255.0  192.168.1.0/24  1500  10:02:b5:e4:de:8c  fe80::ed51:1db6:b32:ad90/64  2

Show only the specific information you want, requires an interface name be provided.

# IPv4 Addresstrawl -a wifi0
192.168.1.242
# IPv4 Subnet Masktrawl -m wifi0
255.255.255.0
# IPv4 Networktrawl -s wifi0
192.168.1.0/24
# IPv4 MTUtrawl -u wifi0
1500
# MAC Addresstrawl -hw wifi0
10:02:b5:e4:de:8c
# IPv6 Address & Masktrawl -6a wifi0
fe80::ed51:1db6:b32:ad90/64

Print a complete list of addresses for an interface.

trawl -4c wifi0
192.168.0.100/24
10.90.0.18/16trawl -6c wifi0
fe80::defe:3c33:4335:e669/64
fe80::/10

You can also get your public IP address.

trawl -p
104.238.169.73

All the same functionality is available in Windows.

C:\Users\robphoenix>trawl -l -n
Name                         IPv4 Address   IPv4 Mask        IPv4 Network    MTU   MAC Address        IPv6 Address                  Address Count
----                         ------------   ---------        ------------    ---   -----------        ------------                  -------------
Ethernet                     10.62.10.6     255.255.255.252  10.62.10.4/30   1500  00:ff:28:31:d0:72  fe80::d824:2e8d:bf80:69c9/64  2
Wi-Fi                        192.168.1.242  255.255.255.0    192.168.1.0/24  1500  10:02:b5:e4:de:8c  fe80::ed51:1db6:b32:ad90/64   2
Loopback Pseudo-Interface 1  127.0.0.1      255.0.0.0        127.0.0.0/8     -1    -                  ::1/128                       2

Installation

If you don't have the Go programming language installed you can download the appropriate binary for your system from the releases page, rename it as trawl, and put it in your path (howto ubuntu/howto windows).

I have not tried all of the binaries, so if there's a problem with one let me know, thanks.

If you do have Go installed...

go get -u github.com/robphoenix/trawl

Acknowledgements

I totally used the awesome @jessfraz's battery as a starting point and continual touchstone for how to build this. Trawl is far from perfect, but I've learnt from it, which was more the point.

Boat graphic by Freepik from Flaticon is licensed under CC BY 3.0. Made with Logo Maker

trawl's People

Contributors

codesenberg avatar kinabalu avatar robphoenix avatar siebenmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

trawl's Issues

Feature request: report all IP addresses associated with an interface, not just one

On machines with multiple IP address aliases associated with a single interface, it would be quite nice if trawl had an option to report all of them. At least on Linux there is no current convenient, compact way to report this information, and trawl is already reporting so much other useful stuff in one place. As far as I can tell trawl already obtains all of the IP addresses for each interface (cf issue #19), it just doesn't report them (or record them).

Improve error reporting

From #20 (comment) by @siebenmann

trawl -4c or trawl -6c doesn't report an error, although it doesn't work without an interface name. I think it should report an error here rather than effectively ignore the argument.

Also for these flags:

	flag.BoolVar(&v4addr, "a", false, "print only IPv4 address, requires interface name")
	flag.BoolVar(&v4mask, "m", false, "print only IPv4 subnet mask, requires interface name")
	flag.BoolVar(&v4net, "s", false, "print only IPv4 network (subnet), requires interface name")
	flag.BoolVar(&mtu, "u", false, "print only MTU, requires interface name")
	flag.BoolVar(&mac, "hw", false, "print only MAC address (hardware address), requires interface name")
	flag.BoolVar(&v6addr, "6a", false, "print only IPv6 address, requires interface name")
	flag.BoolVar(&v4compl, "4c", false, "print all IPv4 address, requires interface name")
	flag.BoolVar(&v6compl, "6c", false, "print all IPv6 address, requires interface name")

Doesn't work on Windows

I don't know why, yet.

C:\Users\robertph\go\src\github.com\robphoenix\trawl [master ↓]
λ  .\trawl.exe
panic: runtime error: index out of range

goroutine 33 [running]:
panic(0x5f6600, 0xc042004040)
        C:/Go/src/runtime/panic.go:500 +0x1af
main.New(0x27, 0x500, 0xc04208c990, 0x2d, 0xc04203eee0, 0x8, 0x8, 0x18, 0x0, 0x0, ...)
        C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:88 +0x3a8
main.main.func1(0xc04203c300, 0x27, 0x500, 0xc04208c990, 0x2d, 0xc04203eee0, 0x8, 0x8, 0x18)
        C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:50 +0x56
created by main.main
        C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:55 +0x154
C:\Users\robertph\go\src\github.com\robphoenix\trawl [master ↓]
λ  .\trawl.exe
panic: runtime error: index out of range

goroutine 29 [running]:
panic(0x5f6600, 0xc042004040)
        C:/Go/src/runtime/panic.go:500 +0x1af
main.New(0x25, 0x500, 0xc0420c4c40, 0x13, 0xc04203eec0, 0x8, 0x8, 0x18, 0x0, 0x0, ...)
        C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:88 +0x3a8
main.main.func1(0xc04203c300, 0x25, 0x500, 0xc0420c4c40, 0x13, 0xc04203eec0, 0x8, 0x8, 0x18)
        C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:50 +0x56
created by main.main
        C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:55 +0x154
panic: runtime error: index out of range

goroutine 34 [running]:
panic(0x5f6600, 0xc042004040)
        C:/Go/src/runtime/panic.go:500 +0x1af
main.New(0x26, 0x500, 0xc04208c9c0, 0x2d, 0xc04203eee8, 0x8, 0x8, 0x18, 0x0, 0x0, ...)
        C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:88 +0x3a8
main.main.func1(0xc04203c300, 0x26, 0x500, 0xc04208c9c0, 0x2d, 0xc04203eee8, 0x8, 0x8, 0x18)
        C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:50 +0x56
created by main.main
        C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:55 +0x154

fix Windows build

Local Area Connection 4              169.254.17.182   255.255.0.0      169.254.0.0/16      1500   02:00:4c:4f:4f:50  fe80::6cd7:885:5ae5:11b6/64
Wireless Network Connection          10.26.101.28     255.255.255.0    10.26.101.0/24      1500   24:77:03:c1:7e:2c  fe80::48e8:96c3:7457:8a3d/64
VirtualBox Host-Only Network         192.168.56.1     255.255.255.0    192.168.56.0/24     1500   0a:00:27:00:00:1a  fe80::31ac:de12:1d27:fbc9/64
VirtualBox Host-Only Network #2      10.0.0.1         255.255.0.0      10.0.0.0/16         1500   0a:00:27:00:00:1c  fe80::701e:c603:1aee:597e/64
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x40300b]

goroutine 1 [running]:
panic(0x617f80, 0xc04200c080)
        C:/Go/src/runtime/panic.go:500 +0x1af
main.New(0x16, 0x500, 0xc04205ecf0, 0x21, 0xc04200d010, 0x8, 0x8, 0x19, 0xc042034b60, 0x0, ...)
        C:/Users/robertph/MEGA/donaldjudd/code/go/src/github.com/robphoenix/trawl/trawl.go:52 +0x19b
main.main()
        C:/Users/robertph/MEGA/donaldjudd/code/go/src/github.com/robphoenix/trawl/main.go:141 +0x776

fix output formatting

[rob@agnesmartin] ~ 
> trawl
wlp1s0      192.168.1.78     255.255.255.0    192.168.1.0/24      1500   10:02:b5:e4:de:8c  fe80::defe:3c33:4335:e669/64
enx9cebe838355c  10.90.128.6      255.255.0.0      10.90.0.0/16        1500   9c:eb:e8:38:35:5c  fe80::9eeb:e8ff:fe38:355c/64
docker0     172.17.0.1       255.255.0.0      172.17.0.0/16       1500   02:42:d4:0b:98:63  -

List all addresses attached to all interfaces

From #20 (comment) by @siebenmann

My usage case is that I don't necessarily remember or care what a system's interface(s) are called, but I would like to get a list of all of its IP addresses, possibly with some information about which interfaces they're attached to.

  • It would be nice to have some marker in basic 'trawl' output that there are multiple IP addresses attached to an interface (ideally which type). Otherwise you have to know that you have multiple IPs somewhere and guess what interface they're probably on.
  • It would be nice to have an option where the standard 'trawl' output somehow included all IPv4 and IPv6 addresses attached to each interface. Failing that, at least an output mode that was 'give me all IP addresses for all interfaces listed in some way'.

Be able to specify interface

As interface names are not always a simple eth0, (wlp1s0 on linux, Local Area Connection on Windows) it would be good if this used a regex rather than the full interface name. I've always found myself in the past having to list the interface names to then get specific info about them.

$ trawl w*
wlp1s0      192.168.1.78     255.255.255.0    192.168.1.0/24      1500   7d:1a:b5:54:de:8c fe80::defe:3c33:4335:e669/64
% trawl w*
Wireless Network Connection          10.26.101.64     255.255.255.0    10.26.101.0/24      1500  87:77:a3:d1:7e:2c  fe80::48e8:96c3:7457:8a3d/64

I'm not sure how I'd want to deal with multiple interfaces that match the regex, I guess it would be best to list all that match, rather than just the first, or list all matches and asking for a more specific regex.
If nothing matches it would be good to provide a list of available interfaces.

$ trawl y*
Available Interfaces:
    lo
    tun0
    wlp1s0
    docker0

fix panic when interface up but hasn't got dhcp address yet

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x402fd7]

goroutine 1 [running]:
panic(0x624da0, 0xc42000c130)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
main.New(0x7, 0x5dc, 0xc42007cfe0, 0xf, 0xc4200f3014, 0x6, 0x8ec, 0x13, 0xc4200742a0, 0x0, ...)
	/home/rob/code/go/src/github.com/robphoenix/trawl/trawl.go:45 +0x1d7
main.main()
	/home/rob/code/go/src/github.com/robphoenix/trawl/main.go:141 +0x76f

Trawl reports the last IPv4 as the address of an interface, not the first

If you have an interface with multiple IP addresses attached to it, trawl reports the last IPv4 address of the interface (and probably the last IPv6 interface). Traditionally one would report the first IP if you're only going to report one, because that is usually the primary IP address.

$ ip -4 addr list eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    inet 128.100.3.124/24 brd 128.100.3.255 scope global eno1
       valid_lft forever preferred_lft forever
    inet 128.100.3.125/24 brd 128.100.3.255 scope global secondary eno1:1
       valid_lft forever preferred_lft forever
    inet 128.100.3.126/24 brd 128.100.3.255 scope global secondary eno1:2
       valid_lft forever preferred_lft forever
    inet 128.100.3.127/24 brd 128.100.3.255 scope global secondary eno1:3
       valid_lft forever preferred_lft forever
    inet 128.100.3.128/24 brd 128.100.3.255 scope global secondary eno1:4
       valid_lft forever preferred_lft forever
$ trawl -f eno1
eno1  128.100.3.128  255.255.255.0  128.100.3.0/24  1500  d4:ae:52:cb:c2:2c  fe80::d6ae:52ff:fecb:c22c/64

I think that the broad fix for this would be to change extractAddrs() to return a list of IPv4 and IPv6 addresses, instead of trying to return just one of each. The current New() could then use the first one of each.

fix Windows formatting

This is horrible:

C:\Users\robertph\go\src\github.com\robphoenix\trawl [master ≡ +0 ~1 -0 ~]
λ  .\trawl.exe

Local Area Connection 4  169.254.17.182   255.255.0.0      169.254.0.0/16     fe80::6cd7:885:5ae5:11b6/64
Bluetooth Network Connection  169.254.243.224  255.255.0.0      169.254.0.0/16     fe80::7429:19e:27a2:f3e0/64
isatap.{6AF716A3-0351-4525-9F2D-838AFBA61DEC}                                                       fe80::5efe:a9fe:11b6/128
isatap.{11760E69-ADA3-42AD-9DFE-3C0C473A6724}
Wireless Network Connection 2  169.254.152.175  255.255.0.0      169.254.0.0/16     fe80::49a:d5ff:9df5:98af/64
VirtualBox Host-Only Network  192.168.56.1     255.255.255.0    192.168.56.0/24    fe80::31ac:de12:1d27:fbc9/64
Mobile Broadband Connection  169.254.28.122   255.255.0.0      169.254.0.0/16     fe80::8d8d:9814:7174:1c7a/64
Local Area Connection 3  10.30.10.10      255.255.255.252  10.30.10.8/30      fe80::989:e670:8216:5528/64
Loopback Pseudo-Interface 1  127.0.0.1        255.0.0.0        127.0.0.0/8        ::1/128
Wireless Network Connection  10.26.101.68     255.255.255.0    10.26.101.0/24     fe80::48e8:96c3:7457:8a3d/64
isatap.{823CF13A-91C6-481B-8421-4B3E352C77C4}                                                       fe80::5efe:a00:1/128
Teredo Tunneling Pseudo-Interface                                                       fe80::ffff:ffff:fffe/64
isatap.btinet.local                                                       fe80::5efe:a1a:6544/128
isatap.{0ED049DF-0304-4802-A2DF-9F35080406D6}                                                       fe80::5efe:c0a8:3801/128
6TO4 Adapter
isatap.rd.dev                                                       fe80::5efe:a5a:8003/128
VirtualBox Host-Only Network #2  10.0.0.1         255.255.0.0      10.0.0.0/16        fe80::701e:c603:1aee:597e/64
Reusable ISATAP Interface {4012A4B3-5A94-4EE0-A188-831C3634E27F}
Local Area Connection  10.90.128.3      255.255.0.0      10.90.0.0/16       fe80::a4f5:c0bf:b0ca:5551/64
isatap.{BAD582B6-DF90-4A8C-91DC-BFA58D6A2F01}
public      62.239.185.194

Remove goreleaser

I've spent more time trying to get it to work than actually using it. I don't think there's going to be many more releases tbh, that really require using this tool.

Add flags to display specific interface attribute

Once #5 is closed it would be good to add flags similar to ifdata to print out specific attributes, for instance just the IPv4 address or Subnet mask or IPv6 address.

$ trawl -pa w*
192.168.0.11
$ trawl -pn w*
255.255.255.0

The ifdata flags:

> ifdata                                                                                                                                      [2]
Usage: ifdata [options] iface
     -e   Reports interface existence via return code
     -p   Print out the whole config of iface
    -pe   Print out yes or no according to existence
    -pa   Print out the address
    -pn   Print netmask
    -pN   Print network address
    -pb   Print broadcast
    -pm   Print mtu
    -ph   Print out the hardware address
    -pf   Print flags
    -si   Print all statistics on input
   -sip   Print # of in packets
   -sib   Print # of in bytes
   -sie   Print # of in errors
   -sid   Print # of in drops
   -sif   Print # of in fifo overruns
   -sic   Print # of in compress
   -sim   Print # of in multicast
    -so   Print all statistics on output
   -sop   Print # of out packets
   -sob   Print # of out bytes
   -soe   Print # of out errors
   -sod   Print # of out drops
   -sof   Print # of out fifo overruns
   -sox   Print # of out collisions
   -soc   Print # of out carrier loss
   -som   Print # of out multicast
  -bips   Print # of incoming bytes per second
  -bops   Print # of outgoing bytes per second

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.