The gateway address (also known as the "default gateway") is a crucial address configured on your computer, without which you wouldn't be able to get much done. This address acts as a sort of bridge between your local network and the internet. Although the gateway address is capable of much more than bridging the internal with the external, we'll stick with that definition, as it's how the majority of people need it to function.
Also: The first 5 Linux commands every new user should learn
Let's imagine your local area network (LAN -- the network within your home or business) is a castle, and around that castle is a moat filled with acid. If you dive into that moat... you're dead. Since Amazon doesn't deliver to your castle (thanks to that flesh-melting moat), you need a way to get to the outside world, where things happen.
To solve the problem, you build a bridge that gives your castle access to the world beyond your moat. That bridge is the default gateway.
The ISP you use most likely sent you a modem/router. Once that device is plugged in and ready, it'll start assigning addresses via DHCP. Included with an IP address, your computer will also automatically be assigned DNS addresses and a default gateway.
Also: How to set up a print server on your home network with Linux
Most often, this happens seamlessly and without problems. I have, on occasion, run into an issue with a piece of software (be it something for a server or a desktop) where the application decided to assign a default gateway and guessed wrong. With an incorrect gateway address, the app in question wasn't able to access the internet, so it wouldn't function.
Why does this happen?
It's actually fairly simple.
Most ISPs set the default gateway address for DHCP assignment to 192.168.1.1. That address is then handed out and configured by all networkable devices on the LAN. That 192.168.1.1 address is fairly common, but it's not the only one in use. For example, when I was with Comcast, the default gateway was 192.168.1.1. However, when I switched to AT&T fiber, the gateway address was 192.168.1.254.
Also: 5 ways to get the best Linux support, no matter your skill level
I've had some applications that assumed the gateway was 192.168.1.1, and I had to reconfigure them to use the proper address. I've also installed a Linux distribution or two (as a virtual machine) and found that they also decided to use the wrong address.
Fortunately, with Linux, setting the default gateway address can be done via a GUI or the command line.
I'm going to show you how to change the default gateway via a GUI (demonstrating with Pop!_OS) and then via the command line.
Let's get to work.
What you'll need: The only things you'll need for this are a running instance of Linux and a user with sudo privileges. As I mentioned, I'll demonstrate this on Pop!_OS (which is currently still based on GNOME). If you use a different desktop environment, the process should be similar.
The first thing to do is open the Settings app. This can be accessed from either the desktop menu or by clicking the System Tray and then selecting Settings.
Navigate to the Network section of Settings and then click the gear icon associated with either the wired or wireless connection in use.
Depending on the desktop environment you use, the name of Network settings might be different.
Open a terminal window and find out your current IP address with the command:
ip a
In the resulting pop-up, click the IPv4 tab and make sure Manual is selected (as that is the only way to configure the gateway via the GUI). Type the IP address you found above, type your netmask (probably 255.255.255.0), and then add the gateway address you need. You can also scroll down and manually configure a DNS address (you might want to use Cloudflare's DNS servers, which are 1.1.1.1 and 1.0.0.1). Click Apply when you're finished.
Also: 6 features I wish Linux would borrow from MacOS
Make sure to scroll down and set your DNS addresses as well.
To apply the settings, go back to Network (in Settings) and click on the Network On/Off slider until it's in the Off position, and then click it again so it's back in the On position. Your correct gateway address should now be working.
This method is actually easier than the one above and will work with any Linux distribution. Let's say the correct default gateway address is 192.168.1.254. How do we configure this?
Also: The best Linux laptops
First, you must locate the name of your ethernet device. This is done with the command:
ip a
You should see a listing that is something like wlp15s0. Whatever is associated with your desktop's IP address is the name of the device to be used.
Let's use the above example as the device name to configure the proper 192.168.1.254 gateway address. This is done with the command:
sudo ip route | grep defaultchange default via 192.168.1.254 dev wlp15s0
The above command will change the default gateway on device wlp15s0 to 192.168.1.254. You can test it by running the command:
ip route | grep default
You should see 192.168.1.254 listed.
Also: How to use Linux without ever touching the terminal
Congratulations, you've just changed your default gateway on Linux.