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

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/add-change-default-route-default-gateway-ubuntu-lnux/
PINTEREST
PINTEREST
INSTAGRAM

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 192.168.122.1 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 192.168.122.1 dev ens3 is the same as routing table
LEARN MORE  Brute Force With Hydra Tutorial

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 192.168.1.1 is our default gateway network address
  • dev ens3 is network interface for default gateway

Check

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

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/add-change-default-route-default-gateway-ubuntu-lnux/
PINTEREST
PINTEREST
INSTAGRAM

Leave a Reply

Your email address will not be published.