≡ Menu

Ubuntu Linux Configure Gateway / Default Routing IP Address

Q. How do I configure default router or gateway IP address under Ubuntu Linux / Debian Linux? How do I change default router / gateway IP under Ubuntu Linux?

A. You can easily configure default router or gateway IP address under Debian / Ubuntu Linux by editing /etc/network/interfaces network configuration file. This file defines how you configure and how your system is connected to the network.

Ubuntu Linux Configure Default Gateway

Open /etc/network/interfaces file:
$ sudo vi /etc/network/interfaces
Set gateway using following syntax:
gateway {router-ip}
For example, set gateway to 192.168.1.254, enter:
gateway 192.168.1.254
At the end it should look like as follows:
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254

Save and close the file. Restart networking:
$ sudo /etc/init.d/networking restart
Verify new routing is working, enter:
$ ping 192.168.1.254
$ route -n
$ host google.com

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 2 comments… add one }
  • john August 4, 2009, 5:05 am

    Dear all,

    i am using ubanto 9.04 on virtual box,i have usb internet connection,is it possible to use it with ubanto.please reply

    Regards
    john

  • dawit August 11, 2011, 5:37 am

    this site really to answer the need of me

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , , , , , , , , , , , , , , , ,