Debian / Ubuntu Linux Setting a Default Gateway
Q. How do I setup a default gateway on Debian or Ubuntu Linux? My router IP is 192.168.1.254 and I'd like to setup this as a default gateway for Debian Linux.
A. You can use command line tool such as
a] ip command - show / manipulate routing, devices, policy routing and tunnels
b] route command - show / manipulate the IP routing table
c] Save routing information to a configuration file so that after reboot you get same default gateway.
ip command to set a default router to 192.168.1.254
Login as the root and type:
# ip route add default via 192.168.1.254
OR
$ sudo ip route add default via 192.168.1.254
route command to set a default router to 192.168.1.254
Login as the root and type:
# route add default gw 192.168.1.254
OR
$ sudo route add default gw 192.168.1.254
Save routing information to a configuration file /etc/network/interfaces
Open /etc/network/interfaces file
# vi /etc/network/interfaces
OR
$ sudo vi /etc/network/interfaces
Find eth0 or desired network interface and add following option
gateway 192.168.1.254
Save and close the file. Restart networking:
# /etc/init.d/networking restart
OR
$ sudo /etc/init.d/networking restart
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Ubuntu Linux Configure Gateway / Default Routing IP Address
- Red Hat / CentOS Linux Setting a Default Gateway
- How to determine or retrieve visitor’s IP address using PHP
- Openbsd change, add or display default gateway
- How do I find out my Linux gateway / router IP address?
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: /etc/network/interfaces, configuration file, debian default gateway, debian default router, default gateway, default router, etc network, ip command, ip routing table, network interface, network interfaces, Networking, route command, router command, sudo, ubuntu default gateway, ubuntu default router



February 28th, 2008 at 5:31 pm
I also want to set my defualt DNS server and proxy settings, just like in windows. How do I do that ??