Networking Forums

Networking Forums > Computer Networking > Linux Networking > Setting up a simple gateway

Reply
Thread Tools Display Modes

Setting up a simple gateway

 
 
Captain Beefheart
Guest
Posts: n/a

 
      07-22-2004, 06:34 PM
A day or two ago I asked for help setting up what I hoped would become a
PPTP VPN machine. It became clear that my knowledge was seriously lacking
for this venture, so I've been away studying. I think I now understand
subnetting and simple routing c/o the routing table, which is more than I
did before. I'll list my study sources at the bottom of this message for
anybody who's in the same boat as me.

However, I'd like to ask if somebody can check the following abbreviated
routing table, which I think will cause the PC in queston to act as an
Internet gateway (eth1 is connected to a private subnet, eth0 to the WAN).

Destination Gateway Genmask Iface
192.168.1.0 0.0.0.0 255.255.255.0 eth1
193.100.100.0 0.0.0.0 255.255.255.0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 lo
0.0.0.0 193.100.100.1 0,0,0,0 eth0

To take this line by line:

1) Any packets matching this subnet mask and IP are local and therefore sent
out onto the Ethernet plugged into eth1
2) Any packets matching this subnet mask and IP are local and therefore sent
out on the Ethernet plugged into eth0
3) loopback (I understand the purpose of this and won't explain it here)
4) default route - anything not matching the IPs and subnet masks above
should be forwarded to this router

A PC on the private subnet considers the machine above its gateway. It sends
this gateway PC a particular data packet because, according to its own
subnet mask, it isn't for the local network. It arrives at the gateway and
is processed by the gateway's routing table. The gateway realises that it's
not local so it is then forwarded to its own default gateway, where the
packet can then be routed on to its destination.

Have I got this right?


____
Sources I've read to get this far:

Net How-To from the Linux Documentation Project:
http://www.tldp.org/HOWTO/Net-HOWTO/

Daryl's TCP/IP Primer:
http://www.ipprimer.com/overview.cfm

TCP/IP Introduction (from Rutgers University):
ftp://athos.rutgers.edu/runet/tcp-ip-intro.doc

 
Reply With Quote
 
 
 
 
paul@atom.sbrk.co.uk
Guest
Posts: n/a

 
      07-22-2004, 07:02 PM
In article <cdp1av$3no$(E-Mail Removed)>, Captain Beefheart wrote:
> Destination Gateway Genmask Iface
> 192.168.1.0 0.0.0.0 255.255.255.0 eth1
> 0.0.0.0 193.100.100.1 0,0,0,0 eth0


> A PC on the private subnet considers the machine above its gateway. It sends
> this gateway PC a particular data packet because, according to its own
> subnet mask, it isn't for the local network. It arrives at the gateway and
> is processed by the gateway's routing table. The gateway realises that it's
> not local so it is then forwarded to its own default gateway, where the
> packet can then be routed on to its destination.


That's right. But you won't get any packets back. You're using
private IP addresses on the local network so they must be NATted
on the gateway.

Paul
 
Reply With Quote
 
jack
Guest
Posts: n/a

 
      07-22-2004, 08:31 PM
Captain Beefheart wrote:

> However, I'd like to ask if somebody can check the following abbreviated
> routing table, which I think will cause the PC in queston to act as an
> Internet gateway (eth1 is connected to a private subnet, eth0 to the WAN).
>
> Destination Gateway Genmask Iface
> 192.168.1.0 0.0.0.0 255.255.255.0 eth1
> 193.100.100.0 0.0.0.0 255.255.255.0 eth0
> 127.0.0.0 0.0.0.0 255.0.0.0 lo
> 0.0.0.0 193.100.100.1 0,0,0,0 eth0
>
> To take this line by line:
>
> 1) Any packets matching this subnet mask and IP are local and therefore sent
> out onto the Ethernet plugged into eth1
> 2) Any packets matching this subnet mask and IP are local and therefore sent
> out on the Ethernet plugged into eth0
> 3) loopback (I understand the purpose of this and won't explain it here)
> 4) default route - anything not matching the IPs and subnet masks above
> should be forwarded to this router
>
> A PC on the private subnet considers the machine above its gateway. It sends
> this gateway PC a particular data packet because, according to its own
> subnet mask, it isn't for the local network. It arrives at the gateway and
> is processed by the gateway's routing table. The gateway realises that it's
> not local so it is then forwarded to its own default gateway, where the
> packet can then be routed on to its destination.
>
> Have I got this right?


Basically, Yes, Sir, You have.

A bit more in-depth: The output of "route -n" would be really helpful
here. What You sent above is some made-up replica. - Plus, any
"abbreviated" routing table is just not worth discussing.

To the point: Your explaination of things is correct. But You must
distinguish between the local machine (of which You sent the routing
table), and the gateway for it.

Since all "local" routing seems to be ok, the routing table for the
gateway, in Your case 193.100.100.1, would be fairly the same. With
some exceptions: As a router, IP forwarding must be enabled. Then,
this router will have a specific route to the private subnet, 192.\
168.1/24.

As others have already said, and the Networking-HowTo tells You, and
the Masquerading-HowTo explains just brilliantly, You're not quite
done here. - Since "private" IP addresses must not be routed over the
internet, You need to consider how to fill the source and destination
fields of the IP headers of any packet that You want to send out.

If You are addressing a valid server by its IP address from the in-
side client, You will eventually force that server to send its reply
back to one address within 192.168.1/24. This reply will not be routed
and hence, never make it back to the requesting machine.

That's what masquerading (or NAT, Network Address Translation) is good
for. - You will tell Your gateway to act as a maquerading gateway. It
will then stamp its own public IP address into the sender address field
of every packet that it forwards to the internet. This way, the remote
server can send its reply back to a valid address. Then, the masq'ing
router will recognize that this reply came in for a masqueraded request
and de-masquerade it to send it back to the requesting internal client.

Nowadays, You can achieve all this via the "iptables" command. - The
mechanics behind all this is referred to as "Connection Tracking", so
the respective module or functionality is "ip_conntrack.o".


> Sources I've read to get this far:
>
> Net How-To from the Linux Documentation Project:
> http://www.tldp.org/HOWTO/Net-HOWTO/
>
> Daryl's TCP/IP Primer:
> http://www.ipprimer.com/overview.cfm
>
> TCP/IP Introduction (from Rutgers University):
> ftp://athos.rutgers.edu/runet/tcp-ip-intro.doc


And that is why I provided this answer: You're doing Your homework all
right. - There's lots to explore. But You're on the right track for now,
I think. - Hope this helps!


Cheers, Jack.

--
----------------------------------------------------------------------
My personal reading of the string "MicroSoft" expands to "NanoWeak"...
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up a simple network at a data center Chris Windows Networking 4 04-07-2008 09:49 PM
Simple gateway routing and VPN? Enta Linux Networking 0 11-24-2004 09:56 AM
Buying and setting up a simple wireless network Trace Wireless Networks 3 11-14-2004 03:06 PM
Trouble setting up simple network Trevor Appleton Home Networking 7 12-27-2003 07:57 PM
Setup Simple Linux Gateway Warren Linux Networking 2 09-04-2003 01:05 PM



1 2 3 4 5 6 7 8 9 10 11