Skip to content

Instantly share code, notes, and snippets.

$ ./netstat -tan
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 192.168.178.31:44372 69.171.246.16:443 ESTABLISHED
tcp 0 0 192.168.178.31:40658 192.30.252.97:443 ESTABLISHED
tcp 0 0 192.168.178.31:40662 192.30.252.97:443 ESTABLISHED
tcp 0 0 192.168.178.31:40657 192.30.252.97:443 ESTABLISHED
tcp 0 0 192.168.178.31:49462 132.176.114.185:993 ESTABLISHED
tcp 0 0 192.168.178.31:48935 62.159.74.127:443 ESTABLISHED
@florianl
florianl / netstat with multi-line flag
Created July 5, 2013 20:47
This Gist shows a output of netstat without and with the multi-line flag
$ ./netstat -tun
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.178.23:56102 194.25.94.139:443 ESTABLISHED
tcp 0 0 192.168.178.23:59773 173.252.102.241:443 ESTABLISHED
tcp 0 0 192.168.178.23:40603 204.232.175.90:443 ESTABLISHED
tcp 0 0 192.168.178.23:54462 54.242.11.189:443 ESTABLISHED
tcp 0 0 192.168.178.23:52386 192.30.252.140:443 ESTABLISHED
tcp 0 0 192.168.178.23:52388 192.30.252.140:443 ESTABLISHED
tcp 0 0 192.168.178.23:56103 194.25.94.139:443 ESTABLISHED
@florianl
florianl / gist:8269072
Created January 5, 2014 14:48
Output of route -6
How it is now:
$ ./route -6
Kernel IPv6 routing table
Destination Next Hop Flag Met Ref Use If
::1/128 :: U 256 0 0 lo
2001:590:3401::3f8d:c211/128 fe80::200:24ff:fece:8965 UG 1 0 0 em1
2001:668:108:9::4d43:60d8/128 fe80::200:24ff:fece:8965 UG 1 0 0 em1
2001:67c:26f4:224::229/128 fe80::200:24ff:fece:8965 UG 1 3 3 em1
2001:67c:26f4:224::231/128 fe80::200:24ff:fece:8965 UG 1 0 0 em1
@florianl
florianl / netlink-attribute-unwrap.go
Created August 14, 2019 18:20
inspect netlink attributes
package main
import (
"fmt"
"net"
"os"
"time"
bpf "github.com/iovisor/gobpf/bcc"
"github.com/florianl/go-tc"
@florianl
florianl / flow.bt
Created September 14, 2019 12:32
simple bpftrace script to print out forwarding traffic
#!/bin/bpftrace
#include <linux/skbuff.h>
#include <linux/ip.h>
BEGIN
{
printf("follow the white rabbit\n");
}
@florianl
florianl / dlopen.bt
Last active February 5, 2020 20:12
Tracing potential dlopen() usage
#!/usr/bin/env bpftrace
/*
* dlopen.bt reports potential usage of dlopen() usage which is a combination
* of a open syscall followed by mmap syscall
*/
BEGIN
{
printf("Tracing potential dlopen() usage... Hit Ctrl-C to end.\n");
@florianl
florianl / fibonacci.go
Created February 24, 2020 19:20
Calculate the fibonacci number in three different ways
package main
import (
"math/rand"
"time"
)
//go:noinline
func fibonacciRecursive(n uint32) uint32 {
if n < 2 {
@florianl
florianl / xdp-example.go
Created November 11, 2021 20:21
xdp ebpf example
package main
import (
"fmt"
"log"
"net"
"github.com/cilium/ebpf"
"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/rlimit"
@florianl
florianl / main.go
Created January 24, 2022 20:10
eBPF program on perf event in Go
package main
import (
"errors"
"log"
"os"
"os/signal"
"strconv"
"syscall"