Set Linux Gateway

One can say that it is rather trivial task to set Linux gateway (or in other words to set up/change default gateway in Linux operating system) but I noticed that this question is one of the most popular among linux newbies so I decided to post a quick tip here on Linux Screw.

There are two most used ways to set up default gateway using Linux console. Of course modern linux distributions comes with graphical tools and programs for this purpose but old school CLI commands will live forever as are very simple and allow to do the job very quickly:

route add default gw 10.0.0.1
where 10.0.0.1 is IPv4 IP address of default gatway you would like to set up in your Linux.

ip route add default via 10.0.0.1

According to general networking recommendation it is a good practice to have gateway’s IP as the last IP from selected pool so very often default gateway’s IP will end with .254 e.g. 10.0.0.254. Anyway using above mentioned commands you can apply ANY default gateway. By the way, if you’d like to delete current default gateway, here is corresponding command:

route del default

Hope it helps!

P.S. Don’t forget that these commands require root previleges.

 
 
» You might also be interested in the following articles:
Phone call as Nagios notification
Fedora Core remote installation howto
BSD Packet Filter (pf) resources
Change MAC address of network interface in Linux
Linux + 532Mhz CPU + 128Mb RAM + audio/video + Wi-Fi = Photoframe! Huh?



» Want to stay up to date? Subscribe to our E-MAIL or RSS feed!

0 Responses to “Set Linux Gateway”


  1. No Comments

Leave a Reply




Friendly Sites:Who is behind Linux Screw?
GeekyBits³ | Bash Cures Cancer | OMG! Ubuntu!
My SysAd Blog | Web Upd8
ZEPY | Linux config Wiki | Planet Sysadmin
a non-geek's linux notes | Linux Today
TuxArena: The arena of Tux | LinuxAlt.Com
My name is Artem N. (artiomix AT gmail DOT com) and I'm Linux/Unix, Cisco systems engineer. The main idea of Linux Screw is to share relevant knowledge, skills and observations over The Web. Here you can find a lot of information related to different Linux distributions, FreeBSD, IOS as well as a other Open Source around staff. Read more ››