Skip to main content
94 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 ...
erwin's user avatar
  • 2,153
37 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 ...
igal's user avatar
  • 10k
28 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/...
Christopher's user avatar
28 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 (...
JigglyNaga's user avatar
  • 7,966
18 votes
Accepted

What's the meaning of `linkdown` and `onlink' 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 ...
user1794469's user avatar
  • 4,127
15 votes

Command route not found

You need install package net-tools.
metallic's user avatar
  • 356
14 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 [...
WoJ's user avatar
  • 1,605
11 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 ...
Stephen Kitt's user avatar
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, ...
aldem's 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 ...
tifssoft's user avatar
  • 591
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 ...
dirkt's user avatar
  • 32.7k
10 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/...
telcoM's user avatar
  • 102k
9 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 ...
phemmer's user avatar
  • 72.5k
9 votes

How to understand the output of route

A quick example may help. Presume this route table entry (from 'route -an' command output under Linux, and not all columns shown, only the ones we need - and this is the 'winning' entry, other entries ...
Art Swri's user avatar
  • 191
7 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 ...
eri's user avatar
  • 905
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 ...
Rui F Ribeiro's 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 | ...
user4556274's user avatar
  • 9,065
7 votes

Command route not found

The /sbin isn't in your PATH, use: $ /sbin/route or : $ export PATH=$PATH:/sbin $ route You can add the above command to your .bashrc: echo "export PATH=$PATH:/sbin" >> .bashrc source ....
GAD3R's user avatar
  • 67.7k
7 votes

What is the difference between '0.0.0.0/1' and 'default'?

0.0.0.0/1 via 10.z.0.1 dev tun0 128.0.0.0/1 via 10.z.0.1 dev tun0 Those two rules, together span the whole of 0.0.0.0/0 (the first one IP addresses from 0.0.0.0 to 127.255.255.255 and the second IP ...
Stéphane Chazelas's user avatar
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' &...
intika's user avatar
  • 14.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 ...
A.B's user avatar
  • 37.5k
6 votes
Accepted

`ip route add` does not allow duplicate entries, can I depend on that?

You can use ip route replace instead of add. This takes the same parameters as add but does not fail, when the route currently exists. As man ip-route tells us ip route replace change or ...
guntbert's user avatar
  • 1,677
5 votes
Accepted

How to create/setup vpn using only SSH?

Source address of packets should be replaced by one of local machine's address so that answers could be received by local machine, otherwise there is no (good) reason for sending these packets to next ...
reith's user avatar
  • 404
5 votes
Accepted

equivalent command `route -n` in BSD

You can use netstat -rn for this purpose. See the FreeBSD man page on netstat for more details. Incidentally, that also works in Linux, so in a way it's a more portable command than route -n to ...
filbranden's user avatar
  • 22.1k
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 ...
Stephen Kitt's user avatar
5 votes

Ifup interface failing with answers: file exists

This issue can have multiple sources: First you can not have the same IP on multiple interfaces /etc/network/interfaces.d/* config file can contain only one single gateway because this determine the ...
intika's user avatar
  • 14.7k
4 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 ...
heemayl's user avatar
  • 56.8k
4 votes
Accepted

Enabling an Internet route through ppp0

To achieve what I wanted to achieve I had to do the following things: Step 1: Install the PPTP Client Program for Debian Project Step 2: Setup the PPTP connection Step 3: Testing the connection ...
Philipp's user avatar
  • 191

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