• About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy Policy
  • Change the purpose of use

Tnhelearning.edu.vn - Various useful general information portal

  • Photo
  • Bio
  • How To
  • Tech

How to Add or Change Default Gateway on Linux

December 19, 2023 by admin Category: How To

You are viewing the article How to Add or Change Default Gateway on Linux  at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.

X

wikiHow is a “wiki” site, which means that many of the articles here are written by multiple authors. To create this article, 10 people, some of whom are anonymous, have edited and improved the article over time.

This article has been viewed 4,487 times.

The default gateway is the router’s IP address. Normally, the connection port will be automatically found by the operating system during the installation process, but you may need to change it, especially if the computer has many adapters or routers on the network. .

Table of Contents

  • Steps
    • Using Terminal
    • Edit config file

Steps

Using Terminal

Image titled Add or Change the Default Gateway in Linux Step 1

Image titled Add or Change the Default Gateway in Linux Step 1

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/2/2a/Add-or-Change-the-Default-Gateway-in-Linux-Step-1-Version-3.jpg/ v4-728px-Add-or-Change-the-Default-Gateway-in-Linux-Step-1-Version-3.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 2/2a/Add-or-Change-the-Default-Gateway-in-Linux-Step-1-Version-3.jpg/v4-728px-Add-or-Change-the-Default-Gateway-in-Linux- Step-1-Version-3.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=”mw-parser-output “></div>”}
Open the Terminal application. You can open Terminal from the sidebar, or press Ctrl + Alt + T .
Image titled Add or Change the Default Gateway in Linux Step 2

Image titled Add or Change the Default Gateway in Linux Step 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/e/ec/Add-or-Change-the-Default-Gateway-in-Linux-Step-2-Version-2.jpg/ v4-728px-Add-or-Change-the-Default-Gateway-in-Linux-Step-2-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ e/ec/Add-or-Change-the-Default-Gateway-in-Linux-Step-2-Version-2.jpg/v4-728px-Add-or-Change-the-Default-Gateway-in-Linux- Step-2-Version-2.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=”mw-parser-output “></div>”}
View the current default gateway. You can check which default gateway is installed by typing route and then pressing ↵ Enter . The address next to the word “default” is your default gateway and the interface to which it is assigned will be displayed on the right side of the table.
Image titled Add or Change the Default Gateway in Linux Step 3

Image titled Add or Change the Default Gateway in Linux Step 3

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/f9/Add-or-Change-the-Default-Gateway-in-Linux-Step-3-Version-3.jpg/ v4-728px-Add-or-Change-the-Default-Gateway-in-Linux-Step-3-Version-3.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ f/f9/Add-or-Change-the-Default-Gateway-in-Linux-Step-3-Version-3.jpg/v4-728px-Add-or-Change-the-Default-Gateway-in-Linux- Step-3-Version-3.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=”mw-parser-output “></div>”}
Delete the current default gateway. If the computer has multiple default gateways set up, connection conflicts may occur. If you want to change the current IP address of your router, you should delete it first.

  • Enter the command sudo route delete default gw IP Address Adapter . For example, to delete the default gateway 10.0.2.2 on the eth0 router, type sudo route delete default gw 10.0.2.2 eth0 .
READ More:   How to Dye Hair Without Dye
Image titled Add or Change the Default Gateway in Linux Step 4

Image titled Add or Change the Default Gateway in Linux Step 4

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/c/c9/Add-or-Change-the-Default-Gateway-in-Linux-Step-4.jpg/v4-728px- Add-or-Change-the-Default-Gateway-in-Linux-Step-4.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/c/c9/Add-or- Change-the-Default-Gateway-in-Linux-Step-4.jpg/v4-728px-Add-or-Change-the-Default-Gateway-in-Linux-Step-4.jpg”,”smallWidth”:460 ,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=”mw-parser-output”></div>”}
Enter command . sudo route add default gw IP Address Adapter . For example, if you want to change the IP address of your router eth0 to 192.168.1.254, type sudo route add default gw 192.168.1.254 eth0 . You will be asked to enter your user password to complete the command.

Edit config file

Image titled Add or Change the Default Gateway in Linux Step 5

Image titled Add or Change the Default Gateway in Linux Step 5

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/9d/Add-or-Change-the-Default-Gateway-in-Linux-Step-5.jpg/v4-728px- Add-or-Change-the-Default-Gateway-in-Linux-Step-5.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/9/9d/Add-or- Change-the-Default-Gateway-in-Linux-Step-5.jpg/v4-728px-Add-or-Change-the-Default-Gateway-in-Linux-Step-5.jpg”,”smallWidth”:460 ,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=”mw-parser-output”></div>”}
Open the configuration file with an editor. Type the command sudo nano /etc/network/interfaces to open the file in the Nano software. Editing the system files will preserve your changes every time the computer restarts.
Image titled Add or Change the Default Gateway in Linux Step 6

Image titled Add or Change the Default Gateway in Linux Step 6

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/91/Add-or-Change-the-Default-Gateway-in-Linux-Step-6.jpg/v4-728px- Add-or-Change-the-Default-Gateway-in-Linux-Step-6.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/9/91/Add-or- Change-the-Default-Gateway-in-Linux-Step-6.jpg/v4-728px-Add-or-Change-the-Default-Gateway-in-Linux-Step-6.jpg”,”smallWidth”:460 ,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=”mw-parser-output”></div>”}
Navigate to the appropriate section. Find the section about the router for which you want to change the IP address. For a wired connection, the router is usually eth0 .
Image titled Add or Change the Default Gateway in Linux Step 7

Image titled Add or Change the Default Gateway in Linux Step 7

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/d1/Add-or-Change-the-Default-Gateway-in-Linux-Step-7.jpg/v4-728px- Add-or-Change-the-Default-Gateway-in-Linux-Step-7.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/d/d1/Add-or- Change-the-Default-Gateway-in-Linux-Step-7.jpg/v4-728px-Add-or-Change-the-Default-Gateway-in-Linux-Step-7.jpg”,”smallWidth”:460 ,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=”mw-parser-output”></div>”}
Add . gateway IP Address into this section. For example, type gateway 192.168.1.254 to set the default gateway to 192.168.1.254.
Image titled Add or Change the Default Gateway in Linux Step 8

Image titled Add or Change the Default Gateway in Linux Step 8

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/3/38/Add-or-Change-the-Default-Gateway-in-Linux-Step-8.jpg/v4-728px- Add-or-Change-the-Default-Gateway-in-Linux-Step-8.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/3/38/Add-or- Change-the-Default-Gateway-in-Linux-Step-8.jpg/v4-728px-Add-or-Change-the-Default-Gateway-in-Linux-Step-8.jpg”,”smallWidth”:460 ,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=”mw-parser-output”></div>”}
Save your changes and exit. Press Ctrl + X then press Y to save changes and exit.
  • Image titled Add or Change the Default Gateway in Linux Step 9

    Image titled Add or Change the Default Gateway in Linux Step 9

    {“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/9e/Add-or-Change-the-Default-Gateway-in-Linux-Step-9.jpg/v4-728px- Add-or-Change-the-Default-Gateway-in-Linux-Step-9.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/9/9e/Add-or- Change-the-Default-Gateway-in-Linux-Step-9.jpg/v4-728px-Add-or-Change-the-Default-Gateway-in-Linux-Step-9.jpg”,”smallWidth”:460 ,”smallHeight”:344,”bigWidth”:728,”bigHeight”:545,”licensing”:”<div class=”mw-parser-output”></div>”}
    Restart the network. Restart your network by typing the command sudo /etc/init.d/networking restart . [1] X Research Source
  • X

    wikiHow is a “wiki” site, which means that many of the articles here are written by multiple authors. To create this article, 10 people, some of whom are anonymous, have edited and improved the article over time.

    This article has been viewed 4,487 times.

    The default gateway is the router’s IP address. Normally, the connection port will be automatically found by the operating system during the installation process, but you may need to change it, especially if the computer has many adapters or routers on the network. .

    READ More:   How to Date Aries Man

    Thank you for reading this post How to Add or Change Default Gateway on Linux at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.

    Related Search:

    Related Posts

    How to Create Curved Text in Photoshop
    How to fall asleep faster
    How to Install FBReader to Read eBooks

    Category: How To

    Previous Post: « Top 999+ happy birthday brother in law images – Amazing Collection happy birthday brother in law images Full 4K
    Next Post: Top 999+ women’s day special images – Amazing Collection women’s day special images Full 4K »

    Copyright © 2025 · Tnhelearning.edu.vn - Useful Knowledge