LAN-Orangutan is a self-hosted network discovery tool. Find every device on your LAN, label and group them, snapshot your network and compare it later, and get flagged when something unexpected shows up. Single binary, no setup, Tailscale built in. Built by 291 Group.
Go clidevice-discoverygolanghomelabinternet-of-thingslannetwork-discoverynetwork-monitoringnetwork-monitoring-toolnetwork-scannernetworkingnmapsecurityself-hostedselfhostedtailscaletailscale-networkweb-dashboard
package network
import (
"net"
"os"
"strings"
"github.com/291-Group/LAN-Orangutan/internal/types"
)
// InContainer reports whether this process is running inside a container.
func InContainer() bool {
if _, err := os.Stat("/.dockerenv"); err == nil {
return true
}
if data, err := os.ReadFile("/proc/1/cgroup"); err == nil {
s := string(data)
if strings.Contains(s, "docker") || strings.Contains(s, "containerd") || strings.Contains(s, "kubepods") {
return true
}
}
return false
}
// dockerPrivateRanges are the address ranges a container is given when it is
// attached to a container runtime's own network rather than the host's. They are
// used only to detect that this process is isolated inside such a network, where
// interface names do not help because the container simply sees "eth0".
//
// The Docker range is the default bridge's 172.17.0.0/16, not the whole
// 172.16.0.0/12. The wider block is legitimate RFC1918 space that real LANs use,
// so matching all of it wrongly flags a real 172.x network as container-only.
var dockerPrivateRanges = []string{
"172.17.0.0/16", // Docker default bridge
"192.168.65.0/24", // Docker Desktop's virtual machine
"10.88.0.0/16", // podman default
}
// isContainerInterface reports whether an interface name belongs to a container
// runtime rather than a real network. Docker's bridge is docker0, its
// user-defined networks are br-<hash>, and the host side of a container's link
// is veth*. Podman uses podman0 or cni-podman*.
//
// A plain br0, bridge0 or similar is deliberately not matched: those are
// ordinary Linux bridges a user may legitimately put a real LAN on. Only the
// br- form (with the hyphen), which Docker generates, is treated as a container
// bridge.
func isContainerInterface(name string) bool {
switch {
case strings.HasPrefix(name, "docker"):
return true
case strings.HasPrefix(name, "br-"):
return true
case strings.HasPrefix(name, "veth"):
return true
case strings.HasPrefix(name, "podman"), strings.HasPrefix(name, "cni-podman"):
return true
default:
return false
}
}
// isDockerPrivate reports whether a CIDR belongs to Docker's own networking
// rather than a real LAN.
func isDockerPrivate(cidr string) bool {
ip, _, err := net.ParseCIDR(cidr)
if err != nil {
return false
}
for _, r := range dockerPrivateRanges {
if _, block, err := net.ParseCIDR(r); err == nil && block.Contains(ip) {
return true
}
}
return false
}
// IsolatedFromLAN reports whether this process can only see container
// networking, with no route onto a real local network.
//
// In that state a scan is not merely empty: the virtual network's gateway
// answers probes on behalf of addresses that do not exist, so results contain
// devices that were never there. That is worse than finding nothing, because
// nothing about the output looks wrong.
func IsolatedFromLAN(detected []types.Network) bool {
if !InContainer() {
return false
}
if len(detected) == 0 {
return true
}
for _, n := range detected {
if !isDockerPrivate(n.CIDR) {
return false
}
}
return true
}
// IsolationWarning describes the problem in a form suitable for showing to a
// user. It returns an empty string when there is nothing wrong.
func IsolationWarning(detected []types.Network) string {
if !IsolatedFromLAN(detected) {
return ""
}
return "This container can only see Docker's own network, not your LAN. " +
"Scans will miss your real devices and may report devices that do not exist. " +
"Use host networking on Linux, or run LAN Orangutan directly on macOS and Windows."
}
// ExcludeContainerNetworks drops container bridge networks (Docker, Podman) from
// a detected list, identifying them by their interface name rather than by
// address range.
//
// A host running Docker has a docker0 bridge, and user-defined networks appear
// as br-<hash>. These are real interfaces, so detection finds them, but they
// hold containers rather than devices on your network. Scanning one sweeps
// thousands of addresses to find nothing of interest, which on a Raspberry Pi
// takes minutes and makes "Scan All" look broken.
//
// The interface name is used deliberately, not the address range. Docker
// allocates from the same RFC1918 blocks (172.16/12, 192.168/16) that real LANs
// use, so an address guess would both hide a real LAN on 172.x and miss a Docker
// bridge on 192.168.x. The interface name is unambiguous. Anyone who genuinely
// wants to scan a container bridge can still name it explicitly through the
// networks setting.
func ExcludeContainerNetworks(detected []types.Network) []types.Network {
out := make([]types.Network, 0, len(detected))
for _, n := range detected {
if isContainerInterface(n.Interface) {
continue
}
out = append(out, n)
}
return out
}