About Linux FAQ

Browse More FAQs:

Red Hat / CentOS Linux Setting a Default Gateway

Posted by Vivek Gite [Last updated: November 19, 2007]

Q. How do I setup up a default Gateway for all interfaces (eth0 and eth1) under CentOS Linux 5?

A.There are different ways to setup TCP/IP hosts so that you can reach to remote destinations. The simplest one is to setup default gateway by modifying the /etc/sysconfig/network

Setup a default Gateway

Open /etc/sysconfig/network file:
# vi /etc/sysconfig/network
Setup GATEWAY={Router-IP}, if router IP is 74.86.49.129, type:
GATEWAY=74.86.49.129
Save and close the file. Here is my complete file:
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=wan.nixcraft.in
GATEWAY=74.86.49.129

You need to restart networking service:
# /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:

Discussion on This FAQ

  1. mastrboy Says:

    could we get a write-up on howto to do this on Debian also?

  2. vivek Says:

    Open /etc/network/interfaces and setup gateway parameter

    gateway=192.168.1.254

    Restart networking.

    /etc/init.d/networking restart
  3. wizkidno Says:

    If you only do the editing in the /etc/network/interfaces file they will be overwritten at boot time.
    Please edit /etc/sysconfig/network as described in the article as well.

    You can allso set the gateway on each device by editing :
    vim /etc/sysconfig/networking/devices/ifcfg-eth0
    vim /etc/sysconfig/networking/devices/ifcfg-eth1
    And changing the gateway declaration.

    Alternativly you could use the util :
    system-config-network (from both command line and X.)

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!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , ,

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.