The Routing Vector
When configuring a static IP address on an Ubuntu Linux server, or diagnosing why a machine cannot reach the outside internet, you must know the exact IP address of your Default Gateway. The Gateway is the physical router that sits between your local network and the wider internet; it is the absolute final destination for any data packet that does not know where else to go. Without a correctly configured Gateway, your server is effectively trapped inside its local subnet.
How to Find Your Default Gateway IP
You must query the Linux kernel’s internal routing table to determine exactly where it is sending outbound traffic.
1. Open your terminal application or connect to your server via SSH.
2. The modern, standard command for interrogating the routing table is the ip route command. Execute the following:
ip route show
3. The terminal will output a few lines of highly technical networking data. You must isolate the single line that begins with the word default.
4. The output will look something like this: default via 192.168.1.254 dev eth0 proto dhcp metric 100.
5. The numerical sequence immediately following the word via (in this example, 192.168.1.254) is the exact IP address of your Default Gateway.
If you prefer a slightly older, but visually cleaner command, you can also execute route -n. Look for the row where the Destination is 0.0.0.0; the IP address listed under the Gateway column on that specific row is your target.