1

After running a (probably broken) openvpn script, I have an IP route table where one entry is a URL:

# netstat -r                                        
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         10.0.0.1        0.0.0.0         UG        0 0          0 wlp58s0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 wlp58s0
google.com      10.0.0.1        255.255.255.255 UGH       0 0          0 wlp58s0

How can I delete this last row? The regular way throws an error:

# ip route del google.com
Error: any valid prefix is expected rather than "google.com".

I'm on gentoo linux, if that matters.

2
  • 6
    Adding the -n flag to netstat will remove any confusion.
    – Jeff Schaller
    Jul 28 '18 at 16:58
  • 1
    Oh, so simple, thanks! If you post it as an answer, I'll accept it.
    – Felix
    Jul 28 '18 at 17:15
5

The entry google.com is not a URL; it's a domain name, or possibly a host name. (It could be part of a URL, though.)

If you use netstat -rn you will get IP addresses instead of names in that first column. From there you can delete the route - again by reference to its network and subnet addressing.

netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         server.roaima   0.0.0.0         UG        0 0          0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
google.com      0.0.0.0         255.255.255.255 UH        0 0          0 eth1

netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.2.2     0.0.0.0         UG        0 0          0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
216.58.198.174  0.0.0.0         255.255.255.255 UH        0 0          0 eth1

route delete -host 216.58.198.174

You can also do this with the newer ip route, which lists routes only with IP addresses. Use ip route del to delete the unwanted entry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.