Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Do packets go via gateway when that route isnt shortest?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
sirlark
Guru
Guru


Joined: 25 Oct 2004
Posts: 306
Location: Limerick, Ireland

PostPosted: Tue Jul 01, 2008 3:05 pm    Post subject: Do packets go via gateway when that route isnt shortest? Reply with quote

Hi all,

I have an ADSL wireless router, which is presently acting as DHCP server. Obviously it supplies it's own IP as the default gateway.

What I would like to do is install a server that acts as firewall/proxy/cache. I'm intending to install dnsmasq on it, but was wondering how it would interact with machines connecting wirelessly. I would want squid to act as a transparent proxy, See diagram below ...

Code:

INTERNET <--> ADSL wireless router <--> Server <--> Switch <--> Wired PC
                        |
                        |
                Wireless Laptops


If I set up dnsmasq to deliver deliver the server's ip as the default gateway, will traffic from the wireless laptops destined for the internet actually be routed through the server and hence be cached by squid, and more importantly, be measurable by bandwidth monitoring tools.

Cheers
_________________
Adopt an unanswered post today
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Tue Jul 01, 2008 3:39 pm    Post subject: Reply with quote

I think you then need this kind of picture

Code:

INTERNET <--> ADSL  <--> Server <--> Switch <--> Wired PC
                           |
                    Wireless AP (box or NIC)
                           ^
                           |
                           v
                    Wireless laptops

_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
eyoung100
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1428

PostPosted: Tue Jul 01, 2008 3:40 pm    Post subject: Reply with quote

What type of ADSL Router is it :?: Most routers are firewalls by default as the addresses they give out are private class Addresses. See RFC 1918

RFC 1918 wrote:

To contain growth of routing overhead, an Internet Provider obtains a
block of address space from an address registry, and then assigns to
its customers addresses from within that block based on each customer
requirement.


The above has been outgrown for many years, continuing:
RFC 1918 wrote:
3. Private Address Space

The Internet Assigned Numbers Authority (IANA) has reserved the
following three blocks of the IP address space for private internets:

10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)

We will refer to the first block as "24-bit block", the second as
"20-bit block", and to the third as "16-bit" block. Note that (in
pre-CIDR notation) the first block is nothing but a single class A
network number, while the second block is a set of 16 contiguous
class B network numbers, and third block is a set of 256 contiguous
class C network numbers.



Most ADSL router/modems hand out the class C type. Trading your server IP, which is a Class C private address as described above, with the default gateway of the ADSL router, which is also a Class C private address described above, has no bearing on what your ISP sees. All they see is an increase in packet traffic for the IP Address that has been given to you that is stored in yor ADSL modem/router. Your server can never be the gateway, unless it was the first device in the chain you drew, which can never happen or you would have no connectivity..
_________________
The Birth and Growth of Science is the Death and Atrophy of Art -- Unknown
Registerd Linux User #363735
Adopt a Post | Strip Comments| Emerge Wrapper


Last edited by eyoung100 on Tue Jul 01, 2008 3:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
eyoung100
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1428

PostPosted: Tue Jul 01, 2008 3:45 pm    Post subject: Reply with quote

UberLord wrote:
I think you then need this kind of picture

Code:

INTERNET <--> ADSL  <--> Server <--> Switch <--> Wired PC
                           |
                    Wireless AP (box or NIC)
                           ^
                           |
                           v
                    Wireless laptops


Unless your ADSL modem has an access point built in, which is the only reason I would think you drew the diagram the way you did the first time.
_________________
The Birth and Growth of Science is the Death and Atrophy of Art -- Unknown
Registerd Linux User #363735
Adopt a Post | Strip Comments| Emerge Wrapper
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Tue Jul 01, 2008 3:56 pm    Post subject: Reply with quote

All SoHo ADSL wireless routers I know of throw a wobbly when back-looping the traffic, which is what will happen here. Here's the flow

wireless laptop ->> AP/router ->> server ->> AP/router ->> INTERNET
So traffic back will be
INTERNET ->> AP/router ->> server ->> AP/router ->> wireless laptop

Good luck doing that :)
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
eyoung100
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1428

PostPosted: Tue Jul 01, 2008 4:40 pm    Post subject: Reply with quote

As Uberlord said, all mass produced ADSL modem routers will not allow back-looping, because it requires 2 levels of swapping private IP Addresses. This is more practical when exchanging a Class C private address for a private address of another Class Type. i.e. 192.168.0.0 for 10.0.0.0. A Class C cannot be exchanged for another Class C of the same subnet, because to a router, all packets look identical. A better solution would be to go to the configuration page of your ADSL modem and enable the firewall there, along with port forwarding. See Guide to Port Forwarding.
_________________
The Birth and Growth of Science is the Death and Atrophy of Art -- Unknown
Registerd Linux User #363735
Adopt a Post | Strip Comments| Emerge Wrapper
Back to top
View user's profile Send private message
sirlark
Guru
Guru


Joined: 25 Oct 2004
Posts: 306
Location: Limerick, Ireland

PostPosted: Wed Jul 02, 2008 9:00 am    Post subject: Reply with quote

So it looks like getting a the wireless machines connected means buying a new wireless access point then?

It's a bog standard netgear (RangeMax) ADSL wireless router, configurable to hand out whatever IP addresses I see fit, but currently handing out class C. It has four 'internal' ethernet ports.

My plan is to disable the DHCP server on the router, and have that task taken over by the server using dnsmasq. This would mean that all the workstations and laptops now have their default gateway set to be the servers IP, also a class C address. My question is, what happens to a packet, generated by a user's browser for example, that has a destination outside the class C network range.

My understanding of routing (limited, I confess) is that the user's PC checks through it's routing table and and sends the packet off to the appropriate machine, in this case the gateway, i.e. the server. Logically, this is a single hop, as the ip of the ADSL router isn't anywhere in the equation. Physically, the packet must go through the ADSL router if it originates on a wirelessly connected machine.

But, does the ADSL router's routing logic kick in at this point and analyse the packet sending it to it's ultimate destination outside the network, or does the physical layer just do it's thing, and send the wireless packet to the gateway/server silently translating from wireless protocol to ethernet protocol.

I would test all this stuff myself, but it's a live environment, and I can't risk messing things up during work hours...
_________________
Adopt an unanswered post today
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Wed Jul 02, 2008 7:13 pm    Post subject: Re: Do packets go via gateway when that route isnt shortest? Reply with quote

What should work is to have dhcpd (not 100% sure if dnsmasq can do that) installed on 'server' and have it providing two different dhcp ranges.
To get this flying the server needs to have two NICs or at least have two different networks configured. Both networks can be handled via one physical NIC but it doesn't hurt to use a second NIC.
a) for wired clients (right of the switch in the picture), e.g. 192.168.1.0/24
b) for wireless clients e.g. 192.168.2.0/24

wireless clients will get a DHCP-Lease 192.168.2.x with default GW 'Router' and (if needed) a dedicated route 'LAN -> via Server'
wired clients will get a DHCP-Lease 192.168.1.x with default GW 'Server'

Some of those cheap routers are not able to handle traffic correct when incoming traffic from LAN side is not originating from an IP within the range the router itself has an IP in.
With the above you circumvent this issue. Additionally you've (more or less) some kind of DMZ where your wireless clients are connected to.
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
eyoung100
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1428

PostPosted: Wed Jul 02, 2008 11:20 pm    Post subject: Reply with quote

You may have over complicated your issue. If I understand you correctly from your last post you want to segregate the traffic so you can tell what traffic is coming from what segment, i.e. wireless and wired without disrupting internet traffic for the employees. I would do it as follows:

1. Keep DHCP active on you Modem, but reset the DHCP Server to a Class A address, i.e. 10.0.0.0
2. Connect a seperate wired router to port 1 of the modem, and set the DHCP Server to a class C Address, i.e. 192.168.0.0.
3. Connect a hub to port 1 of the router in step 2 and you have as many wired pc's as you need.
4. Connect your server, with 2 NIC's to port 2 of the modem and port 2 of the router, and use packet filtering software to monitor the traffic of both networks.
5. If traffic monitoring presents a problem, log into the physical router, of either network and configure the Router(s) to block the traffic that's offensive.

By segregating the networks at the hardware level, you cut your job in half. Notice step 2 is a bit of a trick. Your server sees a class C address swapped for a class A address, so all traffic looks like it came from the wireless network, but you will continue to see the class C address while monitoring.
_________________
The Birth and Growth of Science is the Death and Atrophy of Art -- Unknown
Registerd Linux User #363735
Adopt a Post | Strip Comments| Emerge Wrapper
Back to top
View user's profile Send private message
sirlark
Guru
Guru


Joined: 25 Oct 2004
Posts: 306
Location: Limerick, Ireland

PostPosted: Sat Jul 05, 2008 10:22 am    Post subject: Reply with quote

What I want ultimately is a per machine breakdown of bandwidth usage, to find out who is using our bandwidth. I'm doing a favour for a small non-profit organisation and they don't have a lot of money. They also don't have a need for lots of bandwidth, email and basic surfing is all they need. But they're burning through 12Gb a month, and there are only 5 people in the office. I suspected a virus, but I've checked and double checked the machines, and they are to all appearances clean. Hence the desire to determine at least the machine causing the increased bandwidth usage, and hopefully the destination/source of the traffic.
_________________
Adopt an unanswered post today
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum