How To Add or Change Default Route or Default Gateway in Ubuntu, Lnux?


I have installed Ubuntu in to my laptop. I am happy with Ubuntu. But have a little problem. I want to change my default route. Here is the solution. By the way all Linux systems are same for this solution. I mean CentOS, Fedora, Kali, Debian can be use this settings

List Routing Table

Let’s list existing routing table to get information about default gateway

Our default gateway line is

  • default means this line is default gateway
  • via specifies next hop which is default gateway ip address
  • dev ens3 is the interface we want use to access default gateway

Remove Existing Default Gateway

Removing default gateway is easy if we list routing table because routing table line is used with del command like below. But keep in mind if you are connecting system remotely from different network which means if you are using default route you connection will be lost.

  • ip route del is our key line which deletes specified default gateway
  • default via dev ens3 is the same as routing table
LEARN MORE  How To Monitor Network Traffic and Statistics with ntop Tool?

Add New Default Gateway

We can add new default gateway with the following command.

  • ip route add will add provided default gateway
  • default means target network is all which is default
  • via is our default gateway network address
  • dev ens3 is network interface for default gateway


List routing table again and ping some of remote networks will give the status of default gateway

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)