Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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.
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?
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.
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.