The default gateway is the IP address of the router you are using. When a router is installed, the operating system usually detects it automatically. However, sometimes you have to change the default gateway, especially if you are using more than one network adapter or router on the network.
Step
Part 1 of 2: Using Terminal
Step 1. Open Terminal
From the sidebar, open Terminal or press Ctrl+Alt+T.
Step 2. View your current default gateway
You can find out which default gateway is assigned to which interface by typing route and pressing Enter. The address next to "default" is the default gateway, while the interface using it appears to the right of the table.
Step 3. Delete the current default gateway
Network conflicts will arise if more than one default gateway is installed. Remove the existing default gateway if you are going to replace it.
Type sudo route delete my default Adapter IP_address. 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
Step 4. Type
sudo route add default gw Adapter IP_address.
For example, to change the eth0 adapter's default gateway to 192.168.1.254, type sudo route add default gw 192.168.1.254 eth0. You will be prompted for a password before you can run this command.
Part 2 of 2: Editing Configuration Files
Step 1. Open the configuration file from the editor application
Type sudo nano /etc/network/interfaces to create a file in Nano. The purpose of editing the configuration file is to save the changes each time the system is restarted.
Step 2. Find the appropriate section
Locate the section on the adapter for which you want to change the default gateway. For wired connections, this section is usually eth0.
Step 3. Add
gateway IP_address to the section. For example, type gateway 192.168.1.254 to make the default gateway 192.168.1.254.
Step 4. Save changes, then exit
Press Ctrl+X then Y to save it and exit.
Step 5. Re-enable the network
Re-enable it by typing sudo /etc/init.d/networking restart.