How to Add or Change the Default Gateway in Linux
In Linux, the default gateway is the IP address of the router that connects your network to the Internet. It is responsible for forwarding network packets to destinations outside the local network.
To add or change the default gateway in Linux, follow these steps:
1. Open a terminal window. 2. Type the command "ip route show" to display the current routing table. 3. Identify the default gateway address listed under "default via" in the routing table. 4. To add a new default gateway, type the command "sudo ip route add default via <gateway-address>" where <gateway-address> is the IP address of the new default gateway. 5. To change the default gateway, type the command "sudo ip route del default" to delete the existing default route, followed by the command "sudo ip route add default via <gateway-address>" to add the new default gateway.
For example, if the current default gateway is 192.168.1.1 and you want to change it to 192.168.1.2, you would type the following commands:
``` sudo ip route del default sudo ip route add default via 192.168.1.2 ```
Note: These changes will not be permanent and will be lost when the system is restarted. To make the changes permanent, you will need to modify the network configuration file for your Linux distribution. The file location and format may vary depending on your distribution.