PDF download Download Article PDF download Download Article

If you need to find or change the IP address of your default gateway or router on Linux, you're in luck—it's super easy to do. This wikiHow article will show you how to use the route command to find the default gateway IP address on Linux, and how to set a new default gateway in your /etc/network/interfaces configuration file.

Part 1
Part 1 of 2:

Using the Terminal

PDF download Download Article
  1. You can open the Terminal from the side bar, or by pressing Ctrl+Alt+T.[1]
  2. You can check what your default gateway is set to by typing route and pressing Enter. The address next to "default" shows your default gateway, and the interface it is assigned to is displayed on the right side of the table.
    Advertisement
  3. If you have more than one default gateway set, you'll run into connection conflicts. Delete your existing default gateway if you intend to change it.
    • Type sudo route delete default gw IP Address Adapter. For example, to delete the default gateway 10.0.2.2 on the eth0 adapter, type sudo route delete default gw 10.0.2.2 eth0.
  4. sudo route add default gw IP Address Adapter. For example, to change the default gateway of the eth0 adapter to 192.168.1.254, you would type sudo route add default gw 192.168.1.254 eth0.[2] You'll be prompted for your user password in order to complete the command.
  5. Advertisement
Part 2
Part 2 of 2:

Editing Your Configuration File

PDF download Download Article
  1. Type sudo nano /etc/network/interfaces to open the file in the nano editor. Editing your configuration file will keep your changes every time the system restarts.[3]
  2. Find the section for the adapter you want to change the default gateway for. For a wired connection, this is usually eth0.
  3. gateway IP Address to the section. For example, type gateway 192.168.1.254 to make the default gateway 192.168.1.254.[4]
  4. Press Ctrl+X and then Y to save your changes and exit.
  5. Restart your network by typing sudo /etc/init.d/networking restart.[5]
  6. Advertisement

Community Q&A

Search
Add New Question
  • Question
    Will the admins know if I change my IP?
    Community Answer
    Community Answer
    Yes, if they chose to check.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement

Video

Tips

Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!

You Might Also Like

Install Java on LinuxInstall Java on Linux
Manage an iPod in LinuxA Complete Guide to Managing an iPod in Linux
Install Google Chrome Using Terminal on Linux
Linux How to Mount Drive Mount Drives on Linux: Command Line & GUI
Can Linux Run ExeCan Linux Run .exe Files? How to Run Windows Software on Linux
Use Wine on Linux Install and Use Wine on Linux
Tar a Directory Tar a Directory and Subdirectories in Linux
Take a Screenshot in LinuxTake a Screenshot in Linux
Become Root in LinuxBecome Root in Linux
Execute INSTALL.sh Files in Linux Using Terminal Run an INSTALL.sh Script on Linux in 4 Easy Steps
Install DebianEasy Debian Linux Installation Tutorial
Run Files in LinuxRun Files in Linux
Execute .RUN Files in LinuxExecute .RUN Files in Linux
Boot Linux from a USB on Windows 10 Run Linus from a USB: Making a Bootable Stick and Installing
Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 14 people, some anonymous, worked to edit and improve it over time. This article has been viewed 1,156,344 times.
How helpful is this?
Co-authors: 14
Updated: July 22, 2023
Views: 1,156,344
Categories: Linux | Networking Hardware
Article SummaryX

1. Open a terminal window.
2. Type "sudo route delete default gw (IP) (Adapter)" and press Enter.
3. Type "sudo route add default gw (IP) (Adapter)" and press Enter.
4. Open /etc/network/interfaces in a text editor.
5. Update the gateway IP address for the adapter.
6. Save your changes and exit the editor.
7. Type "sudo /etc/init.d/networking restart" and press Enter.

Did this summary help you?

Thanks to all authors for creating a page that has been read 1,156,344 times.

Is this article up to date?

Advertisement