The default gateway (default gateway) is the IP address of your router. It is usually automatically detected by the operating system during installation, but you may need to change it. This is especially true if there are multiple network adapters or routers on the network.
Steps
Part 1 of 2: Using the Terminal

Step 1. Start the terminal
Click on it in the sidebar or press Ctrl + Alt + T.

Step 2. Find the address of the active default gateway
To do this, enter route and press ↵ Enter. The default line will display the default gateway address, and the interface assigned to it can be found on the right side of the table.

Step 3. Remove the active default gateway
If multiple default gateways are installed, they may conflict. Remove the active default gateway if you intend to change it.
Enter sudo route delete default gw IP address of the Adapter. For example, to remove the default gateway 10.0.2.2 of the eth0 adapter, enter sudo route delete default gw 10.0.2.2 eth0

Step 4. Enter sudo route add default gw IP address of the Adapter
For example, to change the default gateway of the eth0 adapter to 192.168.1.254, enter sudo route add default gw 192.168.1.254 eth0. You will be prompted for a user password to execute the command.
Part 2 of 2: Edit the config file

Step 1. Open the configuration file in an editor
Enter sudo nano / etc / network / interfaces to open the file in the nano editor. The changes made will be stored until the next reboot of the system.

Step 2. Go to the required section
Find the section of the adapter whose default gateway you want to change. The wired adapter is called eth0.

Step 3. Add the line gateway IP address to the section
For example, enter gateway 192.168.1.254 to assign the default gateway 192.168.1.254.

Step 4. Save your changes
Press Ctrl + X and then press Y to save your changes and exit the text editor.

Step 5. Reboot the network
To do this, enter sudo /tc/init.d/networking restart.