LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-11-2003, 04:21 PM   #1
glock19
Member
 
Registered: Aug 2001
Distribution: Debian Etch
Posts: 510

Rep: Reputation: 32
Question Confusion about the "GATEWAY=x.x.x.x" attribute


In Red Hat Linux 9, in the "/etc/sysconfig/network" file, you can have a line "GATEWAY=x.x.x.x". Question, is this the default gateway for the server?

Also, another question about that same file, "/etc/sysconfig/network", what is the purpose of the line "GATEWAYDEV=ethx"? In the case that the server has 2 NICs, there can be a gateway for only 1 of the NICs? Why can't each NIC have it's own gateway?

Also, I noticed that some people (based on a google search) are putting the "GATEWAY=x.x.x.x" statement in their "/etc/sysconfig/network-scripts/ifcfg-ethx" file. Is this a valid setup? I mean, shouldn't the gateway setting be in either one or the other, but not in both? And doesn't it make more sense to put the gateway in the "/etc/sysconfig/network" file?

Also, if it's true that, on a 2 NIC server, that only 1 of the NICs can have a default gateway, then what happens to the other NIC? It just doesn't get a default gateway? That seems wrong...

I hope there are some networking gurus who can help clear this confusion for me (and hopefully for anyone else who is reading this thread who wondered the same thing). Thanks!
 
Old 06-11-2003, 05:11 PM   #2
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
Ok,
there are several ways to implement the default gateway... as you can see...
The /etc/sysconfig/network file is read first.
If an entry is there, it is used.
Gateway dev refers to dynamically allocated numbers where Gateway=x.x.x.x means nothing, but it is always going to use that interface, eg ppp0, eth1 etc.
eg a VPN connection with a dynamic number always through eth2

Putting the gateway number in the interface config file /etc/sysconfig/network-scripts/ifcfg~ means that the gateway number only appears after the interface is up, so if you have many network connections (or settings) possible, the correct one will be used.
My machine has the ability to use 3 different default gateways by selecting which eth~ I bring up. Each has a different gateway number but the same static ip number on the card.
I use this for fallback when an external route is down, a slower one is used as default.

You can have several default gateways in the routing table, but the first one in the list is used.

Separate networks have their own gateways defined by the addresses of the network. Once the routing table knows which network the packet belongs to, it will find the gateway that matches and use that.
The default gateway is the last choice, when nothing else matches.

Last edited by peter_robb; 06-11-2003 at 05:12 PM.
 
Old 06-11-2003, 06:23 PM   #3
glock19
Member
 
Registered: Aug 2001
Distribution: Debian Etch
Posts: 510

Original Poster
Rep: Reputation: 32
Quote:
Originally posted by peter_robb
Ok,
there are several ways to implement the default gateway... as you can see...
The /etc/sysconfig/network file is read first.
If an entry is there, it is used.
Gateway dev refers to dynamically allocated numbers where Gateway=x.x.x.x means nothing, but it is always going to use that interface, eg ppp0, eth1 etc.
eg a VPN connection with a dynamic number always through eth2
Let me see if I understand. I should not put the Gateway=x.x.x.x in the /etc/sysconfig/network file?

And the only point of the Gateway dev is to lock down which interface the gateway will always be using? So this is an optional statement?


Quote:
Originally posted by peter_robb

Putting the gateway number in the interface config file /etc/sysconfig/network-scripts/ifcfg~ means that the gateway number only appears after the interface is up, so if you have many network connections (or settings) possible, the correct one will be used.
My machine has the ability to use 3 different default gateways by selecting which eth~ I bring up. Each has a different gateway number but the same static ip number on the card.
I use this for fallback when an external route is down, a slower one is used as default.

You can have several default gateways in the routing table, but the first one in the list is used.

Separate networks have their own gateways defined by the addresses of the network. Once the routing table knows which network the packet belongs to, it will find the gateway that matches and use that.
The default gateway is the last choice, when nothing else matches.
So if I have interface A, on network 192.168.200.0 and I also have interface B, on network 192.168.168.0, then I can have two default gateways. Let's assume that the default gateway for interface A is first, and then after is the default gateway for interface B. Then, when a packet is destined for somewhere in 192.168.168.0 land, it will pass over the first default gateway since it doesn't match? Or will it just attempt to send out on the first default gateway, even though it's not a matching network?
 
Old 06-12-2003, 04:54 AM   #4
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
Gateway=x.x.x.x in the /etc/sysconfig/network file is the standard way of entering the default Gateway address.
This address is used if packet destinations don't match anything local.

A Gateway is a router that attaches to a distant network

If you have two networks, & both of them have access to the internet, you can have two Gateway settings, but only the first will be used.
Which is first? Look in the routing table... route -n

Again place the number either in /etc/sysconfig/network or in the ifcfg-eth~ files.
It depends on how dynamic your network becomes.
I do a lot of testing so mine is very dynamic and I use the ifcfg-eth~ files.

In your routing tables, you can specify direct routes, so that packets for say a specific smtp server go down eth1 and the rest go down eth2, eg
route add host mx1.hotmail.com gw 192.168.168.x
route add default gw eth2


man route for more examples...

In a lot of ways however, it is better to use iptables DNAT to start splitting hosts or services or ports into different routes.
There are many more filter criteria there.
 
Old 06-12-2003, 12:18 PM   #5
glock19
Member
 
Registered: Aug 2001
Distribution: Debian Etch
Posts: 510

Original Poster
Rep: Reputation: 32
Quote:
Originally posted by peter_robb
If you have two networks, & both of them have access to the internet, you can have two Gateway settings, but only the first will be used.
Which is first? Look in the routing table... route -n
Ok, I guess this is the last part that is confusing me. What is the point of having two gateways, if only the first one is ever used?
 
Old 06-13-2003, 08:18 AM   #6
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
Choice...
I send ftp and email traffic on one, browsing etc on the other.
Anything that can be 'set and forget' I don't put on my fast connection. I leave that free for browsing, chat, ssh, admin etc where I can get high response speeds and low congestion.
The ftp and mail can take their time, no problem to me...
Users doing kazaa etc will always get the slowest link out. Lots of congestion from those services!

Also, it is possible to have a cable connection and a dial-up both working at the same time, so which one do you use?
Which makes your question very appropriate...!

So I have a separate set of iptables rules and routing additions for ppp~ to handle both connections.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 11:26 AM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 03:07 PM
have to ping gateway to "kickstart" net connection and routing bPrompter Linux - Networking 0 01-19-2005 02:56 PM
"Linux Gateway" for Terminal Services andre.morita Linux - Software 7 10-08-2004 11:32 AM
how to "see" windows on linux when using winXP gateway to net shaneblyth Mandriva 16 10-02-2003 09:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration