Partner links

How to change the default route in Linux

add IP route Linux

This is just a short article that shows how to change the default network route in Linux. Before I show how to do it, hoping that it helps somebody, let me tell you how I found myself in a situation where I was forced to change it.

If all you care about is how to change the route and not what led to the decision to change it, you may scroll to the end of the article.

Changing the default route in Linux is something I’ve never had to do on any desktop distribution in ages, but since yesterday afternoon, crazy stuff has been happening in my local network. My ISP is Verizon and I subscribe to their FiOS Internet service. I’ve never had a problem with it until yesterday afternoon when it just stopped working. I couldn’t connect to the Internet.

I spent the better part of an hour trying to figure out what the heck was going on, but nothing I tried worked. I could ping the router from any computer and connect to its web management interface, but that was about it. From the router itself I could ping and run a traceroute to any IP on the Internet, but I could not surf the Web. I gave up after an hour and called tech support. I succeeded in scheduling an appointment with a Verizon technician for Sunday afternoon and resigned to not having Internet access for two days. Not good, but what else can I do?

About six hours later, Internet access started working on its own. I didn’t even touch anything. Afterwards, I noticed that every computer on the network was getting an IP address in the 192.168.1.100 and higher range, something that has never happened in more than the six years I’ve been using Verizon FiOS. I figured that I have to investigate what’s going on, but there are other important matters that I have to attend to. So I shelved it for a later time.

Aside from my VoIP service, Internet access has been working just fine until a few hours ago when I installed Ubuntu 14.04 server in VMPlayer. apt-get update was failing because the system couldn’t connect to the Internet. My main computer running Fedora 20 KDE is working fine, but the Ubuntu server running as a guest OS on it was not. I booted up another computer running Ubuntu 14.10 desktop, but it too could not connect to the Internet.

What in the name of Tux is going on!

Just then I decided to check something I should have checked all along – the routing table. Perhaps it could tell me something. And it did. The default route was not what it’s supposed to be (see Figure 1). IP address 192.168.1.5 does not even belong to any device on the network. Something doesn’t smell right. But the best I can do now is change the default route to point to the correct IP.

So here’s how you change the default route in Linux: sudo ip route change default via IP-address dev eth0 proto static (replace IP-address with the IP of your router).

add IP route Linux

Figure 1: Changing the default route in Ubuntu or any other Linux distribution

That solved an immediate problem, but I think there’s something not quite right in my network. I’ve gotta find out what. More on this later, if I find something that’s worth writing about.

Share:

Facebook
Twitter
Pinterest
LinkedIn

Partner links

Newsletter: Subscribe for updates

Subscribe
Notify of
guest
1 Comment
Inline Feedbacks
View all comments
BSD Nieder
BSD Nieder
3 years ago

Good gravy and excellent missive. I have very similar issues and have spent perhaps thirty hours trying to find a fix.

I am running MX-Linux 19.2; Mint 20; and Manjaro 18 and they all
have the same “can not connect to the Internet” conflict. For some reason, our Internet provider, Century Link, started changing our IP address, from 192 to 175 and all of the OSs would lose connect ability.
Even Dows 7, eventual gave up the ghost.

I knew our IP address well because of a monitoring program which tracked any device on our network.

This is a real bad issue since it can involve numerous items – hardware; installation; Internet provider; software; settings. Why over the past two weeks our IP address changes between these two different numbers I do not know, however, it is a major headache in not only losing Internet service but trying to find a fix.

As I was reading your piece, I was hoping it was identifying a similar issue
which has hounded me. Oh, I should mention my wife’s WIFI experienced no service outage, so it was strictly the Ethernet issue.

Two days since the IP address has remained fixed, with our old IP address,
so I hoping that the problem has fixed itself; if not I will try your suggestion.

BTW, thanks for dating your article; it is all too often not done.

Get the latest

On social media

Security distros

Hacker
Linux distros for hacking and pentesting

Crypto mining OS

Bitcoin
Distros for mining bitcoin and other cryptocurrencies

Crypto hardware

MSI GeForce GTX 1070
Installing Nvidia GTX 1070 GPU drivers on Ubuntu

Disk guide

LVM
Beginner's guide to disks & disk partitions in Linux

Bash guide

Bash shell terminal
How to set the PATH variable in Bash
Categories
Archives
1
0
Hya, what do you think? Please comment.x
()
x