jackpal / gateway

A golang library for discovering the address of a LAN gateway.
BSD 3-Clause "New" or "Revised" License
227 stars 69 forks source link

support "ip route get" as fallback on linux systems #17

Closed tmm1 closed 6 years ago

tmm1 commented 6 years ago

this fixes gateway lookups on android, where neither netstat -rn nor ip route show display the gateway.

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.1.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0

$ ip route show
10.0.1.0/24 dev eth0  proto kernel  scope link  src 10.0.1.36

$ ip route get 8.8.8.8
8.8.8.8 via 10.0.1.1 dev eth0  src 10.0.1.36  uid 2000
    cache
jackpal commented 6 years ago

Thanks!