Hot answers tagged

32 votes
Accepted

proper syntax to delete default route for a particular interface?

According to the routing table you have included in your question, you do not have a default route pointing to ppp0, so that's why you can't delete it. ("No such process" here means "No such route"). ...
user avatar
  • 41.1k
29 votes
Accepted

Which order is the route table analyzed in?

The routing table is used in order of most specific to least specific. However on linux it's a bit more complicated than you might expect. Firstly there is more than one routing table, and when which ...
user avatar
  • 15.1k
25 votes

How to delete an IP route?

You haven't included which system you're on or which tool-set you're using, but the two most common commands for managing the routing tables are the route and ip commands. Here is how you might ...
user avatar
  • 9,039
22 votes
Accepted

How to add ipv6 default route

You need to add the route to the gateway first: ip -6 route add 2004::3 dev eth0
user avatar
22 votes
Accepted

What is the best way to add a permanent route?

You mentioned /etc/network/interfaces, so it's a Debian system... Create a named routing table. As an example, I have used the name, "mgmt," below. echo '200 mgmt' >> /etc/iproute2/...
user avatar
  • 14.9k
19 votes
Accepted

Where is routing table stored internally in the Linux kernel?

The route or the ip utility get their information from a pseudo filesystem called procfs. It is normally mounted under /proc. There is a file called /proc/net/route, where you can see the kernel's IP ...
user avatar
  • 45.6k
17 votes
Accepted

Command route not found

The "command not found" error means you don't have the command installed. Using Debian's "search the contents of packages" page brings up: ... /sbin/route net-tools [not powerpc] .... So (...
user avatar
  • 7,161
16 votes
Accepted

netplan generate: `gateway4` has been deprecated, use default routes instead

The current syntax to replace gateway4 is routes with to and via. For the netplan above based on the 192.168.10.0/24 network, it would be: routes: - to: default ...
user avatar
  • 811
12 votes

Command route not found

You need install package net-tools.
user avatar
  • 326
11 votes
Accepted

What's the meaning of `linkdown` and `online' in Linux Route?

linkdown is the status that will show for a route that is in the table and configured to go out through an interface that is in the DOWN state. You can see this by running: ip a and looking for the ...
user avatar
  • 3,664
10 votes
Accepted

List *all* IP routes to a destination in the Linux routing table

There is an easy way to list all routes matchig prefix on linux : ip -6 route list match 2607:f8b0:4005:804::200e table all This will list all possible routes to specified target (including default, ...
user avatar
  • 116
10 votes
Accepted

How To Make All Traffic To Go Through One Interface In Linux

So in your configuration, all the packets you try to send to the network initially originating from 10.0.0.1 (because they are going through tun0 interface and its local address is 10.0.0.1). You ...
user avatar
  • 561
10 votes

How to set a static IPv6 default route with dhcpcd?

You cannot use DHCPv4 to give out default IPv6 routes. You cannot even use DHCPv6 to give out default IPv6 routes. The reason is that IPv6 is different from IPv4 in many respects, and one of them is ...
user avatar
  • 29.1k
10 votes
Accepted

How to add a static route in systemd-networkd?

This is a bug in systemd, still present on version 240. Per the thread above, a workaround (or solution, I am not sure about the status since the bug is still open) is to add GatewayOnlink=yes in the ...
user avatar
  • 1,268
8 votes

CentOS 7 persistent routing issue?

What you found on Google is correct. You need to create a route-(ifname) file. The content needs to be like the "ip" command but only the last part. Like this: 192.168.1.0/24 via 192.168.2.1 More ...
user avatar
8 votes
Accepted

Is there no routing entry for loopback addresses?

The routing table isn’t the first thing taken into account when the kernel processes a packet; there’s a rule table which comes first, which you can see with ip rule list. ip route list (and the ...
user avatar
7 votes

How to add ipv6 default route

To add a default gateway, and not one specific to an Ethernet interface (dev), use: route add default gw <GW IP Address> # For IPv4 route add -A inet6 default gw <GW IP Address> # For ...
user avatar
7 votes
Accepted

Routing to the localhost, how does it work?

(Copied from https://serverfault.com/a/683542/68920) The route command is deprecated, and should not be used anymore. The new way is to use the iproute set of commands, which are all invoked with ip ...
user avatar
  • 67.6k
7 votes

What is the portable way to get the default route source address?

For showing your default route source address: ip route get 8.8.8.8 | awk ' /^[0-9]/ { print $7 }' The { print $7 } is selecting the 7th field of the ip... output; The ^[0-9] is selecting lines ...
user avatar
7 votes

What is the portable way to get the default route source address?

You could choose an arbitrary address which you believe will always be accessed via the default route, for example google DNS, and then print the source address for that route: ip route get 8.8.8.8 | ...
user avatar
  • 7,878
7 votes
Accepted

Adding static routes to debian 10 in /network/interfaces

The up ... lines are not stand-alone, but they are extensions of an iface ... line before them. Before Debian 9, the actual network interface used to pretty much always be the last entry in /etc/...
user avatar
  • 68.5k
6 votes

How to use a defined local IP instead of external one

If you have this problem with every program you run, you should check your server firewall rule. Make sure that it only use NAT for external destination. Your route table make no sense if you have a ...
user avatar
  • 144k
6 votes
Accepted

route on specific interface based on port

I solved and documented it here: http://aftermanict.blogspot.it/2015/11/bash-iptables-iproute2-and-multiple.html This will make the kernel permanently route packets, enables multiple routes and even ...
user avatar
  • 121
6 votes
Accepted

Restoring lost network routes after loss of network

A routing table will make your route permanent (to avoid adding it again/manually after a switch failover); First, create a named routing table. As an example, we could use "mgmt". echo '200 mgmt' &...
user avatar
  • 12.7k
6 votes
Accepted

Problem when resetting the default-gw at flushed routing-table

On Linux, by default (when an address is not added with the flag noprefixroute), adding an address to an interface implicitly adds a route to the LAN with scope link. You have a route to your gateway ...
user avatar
  • 25.1k
5 votes

Which order is the route table analyzed in?

The routing table is usually applied in order from "most specific" to "least specific". A destination of 0.0.0.0 with a netmask of 0.0.0.0, i.e. your default route, is the least specific possible and ...
user avatar
  • 90.4k
5 votes
Accepted

Adding permanent routing

Add the route entry to your /etc/rc.local file (before exit 0): /sbin/route add -net xxx.xxx.xxx.xxx netmask 255.255.240.0 gw xxx.xxx.xx.xxx or add it to your crontab: @reboot /sbin/route add -net ...
user avatar
  • 50.9k
5 votes
Accepted

default route with linkdown

In new kernel we have new defaults. Solution is echo 1 > /proc/sys/net/ipv4/conf/enp0s10/ignore_routes_with_linkdown echo 1 > /proc/sys/net/ipv4/conf/enp0s18/ignore_routes_with_linkdown And ...
user avatar
  • 775
5 votes
Accepted

Why does a routing rule directing to a local network interface accept more than one destination IP addreses?

You’re forgetting that the interface provides access to a network, which (if it’s an IP network) is defined by a base IP address and a netmask (or prefix length in IPv6). 192.168.122.0 0.0.0.0 ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible