Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Default gateway's default gateway.

0 views
Skip to first unread message

Steve B.

unread,
Dec 18, 2002, 2:01:15 AM12/18/02
to
Rookie question. Setting up a dual homed box and one of the NICs will
be the default gateway for its subnet. So what is this NIC's default
gateway. Is it the NIC's own IP address?

Steve B.


Paul Lutus

unread,
Dec 18, 2002, 2:59:46 AM12/18/02
to

Yes. All the machines that need to share a particular gateway, must use
as gateway the address of the machine that has this responsibility.

--
Paul Lutus
http://www.arachnoid.com

Steve Wolfe

unread,
Dec 18, 2002, 3:04:39 AM12/18/02
to
> Rookie question. Setting up a dual homed box and one of the NICs will
> be the default gateway for its subnet. So what is this NIC's default
> gateway. Is it the NIC's own IP address?

Generally, the machine in general has a default gateway, not a NIC.
Think of the default gateway as the "route of last resort", to borrow from
Cisco's terminology. The default gateway will be your upstream router,
and has to exist in one of the subnets in which your machine has an
interface.

So, when the machine can't find any other entry in its routing table
(meaning that it's not bound to a machine in any of the directly attached
subnets), it will send it to the default gateway. Since that gateway is
in one of the directly attached subnets, the machine can examine its
routing table and figure out which interface to send the packets out.

steve

Wayne Pollock

unread,
Dec 18, 2002, 1:56:21 PM12/18/02
to

I don't think the system uses the default gateway if it doesn't
have to. When you assign an IP address to a NIC, the system will
assume all packets going to that subnet should go out that NIC.
I think the default gateway is only used for packets when there
is no match with the subnets of your NICs (and no explicit route
in the routing table). Normally there is a single default gateway
for the whole system.

Also note this is a change from older Linux kernels to the newer
ones (using iproute2). With the older systems you had to manually
enter all routes, including for the subnets for all interfaces.
This is normally done by the boot time and "ifup" scripts that
come with your system.

(When posting these sorts of questions, indeed any questions, it
often helps to mention your distro and version.)

Hope this helps!

-Wayne

Noah Roberts

unread,
Dec 18, 2002, 2:25:33 PM12/18/02
to
On 18 Dec 2002 07:01:15 GMT, "Steve B." <ad...@bsdfan.cncdsl.com>
wrote:

>Rookie question. Setting up a dual homed box and one of the NICs will
>be the default gateway for its subnet. So what is this NIC's default
>gateway. Is it the NIC's own IP address?

As someone already said, the default gateway is the IP address of the
outgoing router.

To be more specific though, when you bring up your nic's interface
with ifconfig then the network that the nic is bound to (which is
figured out by the netmask you provide or a default depending on the
class of IP you are using) will be added to the routing table. When
you send a packet to an ip address the routing mechanism checks the
routing table to see where it should go. This mechanism always sends
the packet to the most specific destination possible, meaning that it
will first check all small subnets it knows about to see if it is
destined for one of them - if so it gets broadcasted through that
interface - if not it looks at the bigger ones.

The default route is net 0.0.0.0 meaning *everywhere*. If nothing
else matches then this is where the packet is sent to, if there is a
route to that destination - if there isn't you get an error like "no
route to host". In all cases I know about you want this assigned to a
gateway machine - this causes the routing mechanism to wrap the packet
and give it another address: that of the gateway machine....this "new"
packet is then broadcasted to the appropriate interface to contact the
gateway machine - if the packet is just broadcasted and not given the
ip of the gateway machine then the gateway machine will ignore it in
99% of the cases. The gateway machine must be on one of the subnets
you are connected to. Packets are wrapped and unwrapped as they pass
through gateways until finally the origional is broadcasted to the
destination subnet and the machine with that IP says, "Hey, that's
me!"

That is it for crash coures in networking 101 - hope it helps...you
will need to read the networking-howto and Linux Networking Guide for
more detail.

NR

Bit Twister

unread,
Dec 18, 2002, 2:59:29 PM12/18/02
to

Maybe this will help

24.x.x.xx is your ISP assigned address.
24.ggg.ggg.1 is your ISP gateway/router.
I borrowed hysterion's (on MindSpring Enterprises) drawing

192.168.1.1 pc1 node's gateway
192.168.1.14 pc1 node's ip
|
v
x pc1 printer 24.x.x.xx
x \ / |
x \ / v
x Hub---------eth1_FW_eth0---cablemodem-----ISPgateway---Internet
x / ^ ^
x / | |
x pc2 192.168.1.1 24.ggg.ggg.1
^ lan gateway
|
192.168.1.12 pc2 node's ip
192.168.1.1 pc2 node's gateway

The Firewall Node's (FW) default gateway device is eth0
with a gateway ip of 24.ggg.ggg.1
FW's eth0 ip address is 24.x.x.xx

eth1 is just another nic, happens to connect to a hub.
The gateway ip for pc's hooked to hub is the ip address
assigned to eth1 in FW

James Knott

unread,
Dec 18, 2002, 6:42:07 PM12/18/02
to
Steve B. wrote:

The default gateways point to the next step on the way to the internet. So
your internal systems would point to your own gateway. It's default would
point to your ISP.

--

Fundamentalism is fundamentally wrong.

To reply to this message, replace everything to the left of "@" with
james.knott.

Wild Wizard

unread,
Dec 18, 2002, 11:50:02 PM12/18/02
to
Steve B. wrote:

error in your thinking

interface's don't have default routes

when you configure a network device you configure 2 differant things
1. the interface
2. the routing table

for the interface you just run ifconfig and give it an ip address and
netmask
for the routing table you do nothing (once apon a time you used to add the
interface into the routing table but that is automatic now)

now if you have a link that goes somewhere else other than the network it is
directly connected to than you can add an extra route

so if you eth0 is on 192.168.0.0/24 and 192.168.1.0/24 is beyond that
network on a router that has an ip of 192.168.0.200 than you would add a
route to the network 192.168.1.0 with a gateway address of 192.168.0.200

now a default gateway is a special catch all address that is the destination
of all packets with no route specified

root@server:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.31.16.24 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 172.31.16.24 0.0.0.0 UG 0 0 0 ppp0

this is my servers config
we have the network 192.168.0.0 attached to eth0 (this rule is automatic)
we have the network 10.0.0.0 attached to eth1 (this rule is automatic)
we have a ppp link with the other end as 172.31.16.24
and we have the default route pointed at the other end of the ppp link

--
Twenty Percent of Zero is Better than Nothing.
-- Walt Kelly

Steve B.

unread,
Dec 19, 2002, 12:29:11 AM12/19/02
to

"Wayne Pollock" <PAolM...@acm.org> wrote in message
news:3E00C4D5...@acm.org...

This is Red Hat 8 on server and workstation.

Okay here's what my setup looks like. Problem I can't get to
the internet from wkstn1.

-----------------
( Internet ) +-------------+
( ISP assigned IP ) | Wkstn1 |
( 64.n.n.5 ) | 10.n.n.5 |
( GW 64.n.n.1 ) | GW 10.n.n.1 |
-------------+--- +-------+-----+
| |
| |
| |
+--+------------------+-------+
| Server |
| eth0 eth1 |
| 64.n.n.5 10.n.n.1 |
| GW 64.n.n.1 GW ?.?.?.? |
| |
| IP forewarding on |
+-----------------------------+


What I can do...
Server can get to the internet.
Server can ping to 64.n.n.1
Server can ping to wkstn1
Wkstn1 can ping 64.n.n.5
Wkstn1 can ping 64.n.n.1

What I can not do
Wkstn1 can not get to internet

So what do I do next. Do I do a route add on server so wkstn1
can get to internet via eth0 Or do I need to setup ip_table
to route between eth1 and eth0?

TIA
Steve B.


Noah Roberts

unread,
Dec 19, 2002, 12:24:11 PM12/19/02
to
On 19 Dec 2002 05:29:11 GMT, "Steve B." <ad...@bsdfan.cncdsl.com>
wrote:

>

That is because Wkstn1 has a private IP address and is not allowed on
the internet. You need to either get another IP address from your ISP
or set up Masquerading on Server.

The default GW is not tied to the interface - this has been explained
before. The default gateway is a route to "all places I don't know
about". There can be other gateways, for instance if you had a
network on the other side of Wkstn1 then for Server to get to that
network it would have to use Wkstn1 as a gateway for that net - but
not default!!!

You need to read more on IP networking, this is basic stuff that needs
to be understood fully to build a network. I am not saying you are
stupid for not knowing, but you will not be able to continue
networking without a firm grasp of these concepts - which you
obviously don't have or you would not be asking the question.
http://www.tldp.org has several guides, among them is the Linux
Networking Guide where these concepts are discussed in one of the
first chapters. You need to go read this book.

Then after you understand about gataways and sub-nets you can read
about IP-Masquerading. http://www.tldp.org has a How-to on this
subject which can be followed with great success. You will not be
able to make sence of this howto until you understand gateways and
subnets.

>
>So what do I do next. Do I do a route add on server so wkstn1
>can get to internet via eth0 Or do I need to setup ip_table
>to route between eth1 and eth0?

You need to masquerade your private subnet. Read the howto, but
remember I already said this would be difficult without knowing how IP
networks work.

NR

0 new messages