Where should I configure the default gateway, "ifcfg-eth0" or "network"?

User Name

Remember Me?

Password

Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Where should I configure the default gateway, "ifcfg-eth0" or "network"?

Got a (maybe) silly question here...

It seems that you can configure default gateway by putting a line "GATEWAY=X.X.X.X" in both /etc/sysconfig/network-scripts/ifcfg-eth0 and /etc/sysconfig/network files. What is the difference between these two types of setups (in case there are more than 1 ethernet cards)? Do they have to be both configured? Thanks!

One possible difference that I see is that when you have this in the /etc/sysconfig/network it is not tied to an interface. but it is when you do it in the file /etc/sysconfig/network-scripts/ifcfg-eth0

When you have multiple interface and traffic is routed though a different gateway for that very interface, the GATEWAY=x.x.x.x entry enables that. We can have different gateway for different interface this way.

GATEWAY=x.x.x.x entry in the /etc/sysconfig/network file configures the 'default' gateway. 'default gateway' is used route traffic though it, when it is not defined to go through a particular interface.

When you have multiple interface and traffic is routed though a different gateway for that very interface, the GATEWAY=x.x.x.x entry enables that. We can have different gateway for different interface this way.

GATEWAY=x.x.x.x entry in the /etc/sysconfig/network file configures the 'default' gateway. 'default gateway' is used route traffic though it, when it is not defined to go through a particular interface.

Thank you avijitp for your reply! But if it has multiple interfaces, how can the server know which one to use to route the packets? If I use the server as a proxy server and all internal networks are connected to one interface and another interface is connected to the Internet, should I just configure the default gateway under the ifcfg-eth0? Thanks!

It depends upon your configuration in the network side. How the cabling has been done. If you know that your traffic toward internet will be passing through the default gateway , then configuring the 'default gateway' in /etc/sysconfig/network will do. There is no need to configure gateway though the ifcfg-ethX files.

If traffic will be going through a different gateway which is connected to a particular ethX (say.. eth1), then you should set that Gateway in that interface ifcfg-eth1 file. The Internal packet routing is then handled by kernel. In this case other interface (say eth0) can be connected to internal network(s).