The "default gateway" of a network connection is the IP address of the router. Normally this parameter is automatically detected by the operating system when configuring the connection, but in some cases it may be necessary to intervene manually. The latter scenario often occurs when there are multiple routers within the LAN.
Steps
Part 1 of 2: Using the Terminal Window
Step 1. Open a "Terminal" window
You can use the Linux Tool Sidebar or you can use the key combination Ctrl + Alt + T.
Step 2. View the IP address of the current network default gateway
You can find this information by entering the route command and pressing the Enter button. The address that appears next to the entry "default" represents the IP address of the default gateway and on the right side of the table is also the name of the network interface to which it has been assigned.
Step 3. Delete the default gateway currently in use
If multiple network gateway addresses are configured you will run into connection problems generated by IP address conflicts. If you need to change the default gateway address, the first step is to delete the current one.
Run the command sudo route delete default gw ip_address network_card. For example, to delete the default gateway 10.0.2.2 from the eth0 network interface, you will need to run the following command sudo route delete default gw 10.0.2.2 eth0
Step 4. Run the command
sudo route add default gw IP_address network_card. For example, to set the eth0 interface network gateway with the IP address 192.168.1.254 you will need to run the following command sudo route add default gw 192.168.1.254 eth0. You will be asked to enter your user account password in order to complete this step.
Part 2 of 2: Edit the Configuration File
Step 1. Open the configuration file using a text editor
Type the command sudo nano / etc / network / interfaces inside the "Terminal" window to perform this step. By modifying the network connection configuration file, the default settings contained within will be used automatically each time the system is restarted.
Step 2. Review the correct data section
You need to locate the section for the network interface whose gateway you want to change. In the case of an Ethernet network card, the interface name is usually eth0.
Step 3. Add the following line
gateway IP_address to the section of the file in question.
For example, if your router's IP address is 192.168.1.254 you will need to enter the following line of gateway text 192.168.1.254 in the file.
Step 4. Save the new changes and close the editor
Press the key combination Ctrl + X then press the Y key on your keyboard to save the file and close the editor.