How to Add or Change the Default Gateway in Linux

Part 1 of 2:

Using the Terminal

  1. How to Add or Change the Default Gateway in Linux Picture 1
    Open the Terminal. You can open the Terminal from the side bar, or by pressing Ctrl+Alt+T.
  2. How to Add or Change the Default Gateway in Linux Picture 2
    View your current default gateway. 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.
  3. How to Add or Change the Default Gateway in Linux Picture 3
    Delete your current default gateway. 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.
    1. 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. How to Add or Change the Default Gateway in Linux Picture 4
    Type .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. You'll be prompted for your user password in order to complete the command.
Part 2 of 2:

Editing Your Configuration File

  1. How to Add or Change the Default Gateway in Linux Picture 5
    Open the configuration file in an editor. 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.
  2. How to Add or Change the Default Gateway in Linux Picture 6
    Navigate to the correct section. Find the section for the adapter you want to change the default gateway for. For a wired connection, this is usually eth0.
  3. How to Add or Change the Default Gateway in Linux Picture 7
    Add .gateway IP Address to the section. For example, type gateway 192.168.1.254 to make the default gateway 192.168.1.254.
  4. How to Add or Change the Default Gateway in Linux Picture 8
    Save your changes and exit. Press Ctrl+X and then Y to save your changes and exit.
  5. How to Add or Change the Default Gateway in Linux Picture 9
    Restart your network. Restart your network by typing sudo /etc/init.d/networking restart.[1]
4.5 ★ | 4 Vote

May be interested

  • Duo laptop entertainment GatewayDuo laptop entertainment Gateway
    the difference is that the gateway mc7803u has a strong graphics card, a black cover and the mc7801u is equipped with an integrated chip, the red back surface, both are powerful entertainment laptops.
  • Gateway 'ultraportable' laptop pairGateway 'ultraportable' laptop pair
    both gateway id49c and ec 19c were present in vietnam with a respectable weight, thinness, sleekness and high configuration that cost less than vnd15 million.
  • How to change Google DNS on LinuxHow to change Google DNS on Linux
    in the previous article, tipsmake.com showed you how to change google dns on a mac. today, let's find out how to change dns on linux and its distributions.
  • Gateway to add two Core laptops iGateway to add two Core laptops i
    the new id line of gateway with two screen sizes (14 and 15.6 inches) is equipped with core i3 and core i5 chips along with 4gb of ram
  • How to change the default browser on AndroidHow to change the default browser on Android
    browsers on smartphones in general and on android in particular are usually quite simple and do not have many useful features like google chrome, firefox or dolphin, ... instead of using the default browser available in your computer completely can change as you like to enhance your experience when using.
  • 3 ways to change the default browser in Windows 103 ways to change the default browser in Windows 10
    in windows 10, the default web browser will be microsoft edge, the latest browser developed by microsoft. however, even if edge has many new and improved features compared to the previous browser, internet explorer, you may still want to change your favorite default browser. so how to change the default browser here? please follow the tutorial below of network administrator.
  • How to change desktop theme on Linux MintHow to change desktop theme on Linux Mint
    linux mint is a great linux distribution for anyone getting started with linux. it comes in 3 different versions: cinnamon, mate and xfce, each catering to a different audience.
  • Instructions for fixing 502 Bad Gateway errorInstructions for fixing 502 Bad Gateway error
    502 bad gateway error is an http status code error (http status code), which means that a server (server) receives an invalid response from another server (server).
  • How to change the default shell in Windows TerminalHow to change the default shell in Windows Terminal
    normally, when you open windows terminal, powershell will launch as the default shell. however, if you want, you can optionally change this default shell to something of your liking, such as command prompt or ubuntu (linux).
  • How to set and change a user password in LinuxHow to set and change a user password in Linux
    both linux and unix operating systems use the passwd command to change the user password. the password used to update the user's authentication token (password) is stored in the / etc / shadow file.