Tux

...making Linux just a little more fun!

how to share internet from a linux server

[j.bakshi at icmail.net]
Wed, 10 Jan 2007 03:43:52 -0800

kindly CC to me --------------------------- Dear list,

here is the actual situation which I like to share with you. I have a Suse10 box with 2 lan card. I also have a 10 port HUB. Now I like to dial my ISP with one lan card and another lan will be connected with the HUB. hence the other PCs can share the net connection from the HUB. I like to implement this. Could any one suggest any tutorial or suggest me to do this ??

thanks for your support.


Top    Back


Karl-Heinz Herrmann [kh1 at khherrmann.de]
Thu, 11 Jan 2007 22:44:46 +0100 (MET)

On Wed, 10 Jan 2007 03:43:52 -0800 j.bakshi@icmail.net wrote:

> here is the actual situation which I like to share with you.
> I have a Suse10 box with 2 lan card.  I also have a 10 port
> HUB.
> Now I like to dial my ISP with one lan card and another lan
> will be connected with the HUB. hence the other PCs can
> share the net connection from the HUB.  I like to implement
> this. Could any one suggest any tutorial or suggest me to do
> this ??

Assuming you configured your two interfaces.

In SuSE 9.1 you go yast and security->firewall, reconfigure, next, next and check [x] forward traffic and do masquerading

You should do this on the internal interface I think....

K.-H.


Top    Back


[j.bakshi at icmail.net]
Fri, 12 Jan 2007 01:07:08 -0800

Kindly CC to me ------------------------------

----- Original Message Follows -----

From: Karl-Heinz Herrmann <kh1@khherrmann.de>
To: j.bakshi@icmail.net, The Answer Gang
<tag@lists.linuxgazette.net>
Subject: Re: [TAG] how to share internet from a linux server
Date: Thu, 11 Jan 2007 22:44:46 +0100 (MET)
> On Wed, 10 Jan 2007 03:43:52 -0800
> j.bakshi@icmail.net wrote:
> > here is the actual situation which I like to share with
> > you. I have a Suse10 box with 2 lan card.  I also have a
> > 10 port HUB.
> > Now I like to dial my ISP with one lan card and another
> > lan will be connected with the HUB. hence the other PCs
> > can share the net connection from the HUB.  I like to
> > implement this. Could any one suggest any tutorial or
> > suggest me to do this ??
> 
> Assuming you configured your two interfaces. 
> 
> In SuSE 9.1 you go yast and security->firewall,
> reconfigure, next, next and check [x] forward traffic and
> do masquerading
> 
> You should do this on the internal interface I think....
> 
Dear Karl-Heinz,

I have done this but no positive result yet. let me allow to tell you everything which I have done step by step.

1] the card called eth0 is used to dial up my isp. here is the configuration

             isp 10.10.96.56
             mask 255.0.0.0
             gateway 10.10.0.1
I have no problem to dial up my isp using eth0 by the linc client. and getting the net here. fine..

2] now my 2nd lan called eth1 has the setting

     ip 192.168.0.2
     mask 255.255.255.0
3] I have a linksys RV042 load balancing router which have 2 uplink port. I have configured one uplink with ip 192.168.0.114 and mask 255.255.255.0 and connect this port with eth1

4] now I executed these command

   #Clears if any old iptable rules/ policies are there.
              iptables --flush -t nat

# Now we will do Masquerading ie. we are doing NAT. iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE iptables --append FORWARD --in-interface eth0 -j ACCEPT

# Enabling packet forwarding. echo 1 > /proc/sys/net/ipv4/ip_forward

but not getting any connection from client machine.

even I tried to ping from the linux server like ping 192.168.0.114 ( the uplink of router) but destination was not reacable.

Please suggest how can I solve the problem. pointing out any tutorial is also welcome. thanks


Top    Back


Kapil Hari Paranjape [kapil at imsc.res.in]
Fri, 12 Jan 2007 06:46:33 -0800

Hello,

On Fri, 12 Jan 2007, j.bakshi@icmail.net wrote:

> 3] I have a linksys RV042 load balancing router which have 2
> uplink port.
>      I have configured one uplink with ip 192.168.0.114  and
>  mask 255.255.255.0
>      and connect this port with eth1

What is a load balancing router doing inside the LAN? I think you should be using a HUB/switch. Here is a little diagram

	-----[ eth0: Linux nat box : eth1]----[ Hub/switch ]---[LAN]
Is this not what you want? Perhaps I understood your question wrong.

> Please suggest how can I solve the problem. pointing out any
> tutorial is also welcome.

Have a look at the howtos on the iptables site.

Kapil. --


Top    Back


[j.bakshi at icmail.net]
Fri, 12 Jan 2007 20:03:58 -0800

----- Original Message Follows -----

From: Kapil Hari Paranjape <kapil@imsc.res.in>
To: j.bakshi@icmail.net, The Answer Gang
<tag@lists.linuxgazette.net>
Subject: Re: [TAG] how to share internet from a linux server
Date: Fri, 12 Jan 2007 06:46:33 -0800
> Hello,
> 
> On Fri, 12 Jan 2007, j.bakshi@icmail.net wrote:
> > 3] I have a linksys RV042 load balancing router which
> > have 2 uplink port.
> >      I have configured one uplink with ip 192.168.0.114 
> >  and mask 255.255.255.0
> >      and connect this port with eth1
> 
> What is a load balancing router doing inside the LAN? I
> think you should be using a HUB/switch. Here is a little
> diagram
> 
>     -----[ eth0: Linux nat box : eth1]----[ Hub/switch
> ]---[LAN]
> 
> Is this not what you want? Perhaps I understood your
> question wrong.

OK here is the diagram of my setting

24online isp -------->[ eth0(used to dial isp) linux   eth1]
----->[ wan2 of load balancing router]-------->[hub]------->
clients PC

Top    Back


[j.bakshi at icmail.net]
Sat, 13 Jan 2007 00:25:13 -0800

----- Original Message Follows -----

From: Kapil Hari Paranjape <kapil@imsc.res.in>
To: j.bakshi@icmail.net, The Answer Gang
<tag@lists.linuxgazette.net>
Subject: Re: [TAG] how to share internet from a linux server
Date: Fri, 12 Jan 2007 06:46:33 -0800
> Hello,
> 
> On Fri, 12 Jan 2007, j.bakshi@icmail.net wrote:
> > 3] I have a linksys RV042 load balancing router which
> > have 2 uplink port.
> >      I have configured one uplink with ip 192.168.0.114 
> >  and mask 255.255.255.0
> >      and connect this port with eth1
> 
> What is a load balancing router doing inside the LAN? I
> think you should be using a HUB/switch. Here is a little
> diagram
> 
>     -----[ eth0: Linux nat box : eth1]----[ Hub/switch
> ]---[LAN]
> 
> Is this not what you want? Perhaps I understood your
> question wrong.

may be this provide more clear view

isp 1--->[ eth0(used to dial isp1) linux eth1]---> [wan2
port of router] -----> [hub]--> client PCs
  
now here is the setting of eth1
ip ---> 192.168.0.2
mask --> 255.255.255.0
gateway --> gateway of eth0
dns ----> dns of eth0
  
  
here is the setting of wan2 port of load balancing router
ip ----> 192.168.0.114 mask ----> 255.255.255.0 gateway ----> 192.168.0.2 (ip of the linux lan card) dns ------> 192.168.0.2 Here is the setting of the hub section of the router
ip ----> 192.168.1.2
mask ---> 255.255.255.0
dual wan ----> wan1 wan2
  
wan1 and wan2 has their own setting as I also mentioned the
wan2 above.
  
clients pc settings
DHCP enable. bcoz the load balancing router has DHCP server inbuilt gateway ---> 192.168.1.2 here is the script I use in my suse 10 iptables --flush -t nat iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE iptables --append FORWARD --in-interface eth1 -j ACCEPT echo 1 > /proc/sys/net/ipv4/ip_forward
after executing the script I have tried from the clients pc with out success. Could any one kindly point out my mistake ? please note I am getting the internet from the linux pc which dialup isp1


Top    Back


Kapil Hari Paranjape [kapil at imsc.res.in]
Sat, 13 Jan 2007 07:52:33 -0800

Hello,

On Sat, 13 Jan 2007, j.bakshi@icmail.net wrote:

> isp 1--->[ eth0(used to dial isp1) linux eth1]---> [wan2
> port of router] -----> [hub]--> client PCs

I still think that putting the router in the middle is needless source of confusion in your network. You can use it as a DHCP server even if you link eth1 directly to the hub and use just one port of your router also connected to the hub.

Still, the network layout as you gave it, can work if configured properly.

> now here is the setting of eth1
> -----------------------------------------------------
> ip ---> 192.168.0.2
> mask --> 255.255.255.0
> gateway --> gateway of eth0
> dns ----> dns of eth0
<snipped a lot of stuff>

> clients pc settings
> -----------------------------------
> DHCP enable. bcoz the load balancing router has DHCP server
> inbuilt
> gateway ---> 192.168.1.2
<snipped a lot of stuff>

> Could any one kindly point out my mistake ?

What is the Linux box to do when it has a packet which is destined for 192.168.1.x?

As far as I can make out from your description that packet is destined for eth0!

Thus you need to have a route on your Linux box

	route add -net 192.168.1.0/255.255.255.0 gateway 192.168.0.144
(where 192.168.0.144 is the address of your router port which is connect to the box). Now, if your wan router is configured to do this it will send the packets to the correct machine.

Regards,

Kapil. --


Top    Back


[j.bakshi at icmail.net]
Sun, 14 Jan 2007 21:01:18 -0800

----- Original Message Follows -----

From: Kapil Hari Paranjape <kapil@imsc.res.in>
To: j.bakshi@icmail.net
Cc: The Answer Gang <tag@lists.linuxgazette.net>
Subject: Re: [TAG] how to share internet from a linux server
Date: Sat, 13 Jan 2007 07:52:33 -0800
> Hello,
> 
> On Sat, 13 Jan 2007, j.bakshi@icmail.net wrote:
> > isp 1--->[ eth0(used to dial isp1) linux eth1]---> [wan2
> > port of router] -----> [hub]--> client PCs
> 
> I still think that putting the router in the middle is
> needless source of confusion in your network. You can
> use it as a DHCP server even if you link eth1 directly to
> the hub and use just one port of your router also
> connected to the hub. 
> 
> Still, the network layout as you gave it, can work if
> configured properly.
> 
> > now here is the setting of eth1
> > -----------------------------------------------------
> > ip ---> 192.168.0.2
> > mask --> 255.255.255.0
> > gateway --> gateway of eth0
> > dns ----> dns of eth0
> <snipped a lot of stuff>
> 
> > clients pc settings
> > -----------------------------------
> > DHCP enable. bcoz the load balancing router has DHCP
> > server inbuilt
> > gateway ---> 192.168.1.2
> <snipped a lot of stuff>
> 
> > Could any one kindly point out my mistake ?
> 
> What is the Linux box to do when it has a packet which is
> destined for 192.168.1.x?
> 
> As far as I can make out from your description that packet
> is destined for eth0!
> 
Please note ( as I mentioned in my previous mail) that the only reason using the linux box with 2 lan is eth0 is used to dial up the 24online isp and then eth1 is used to redirect the connection into the wan port of the router. the utility of this router, it is a load balancing router with 2 wan port. one wan port is connected with data one BSNL connection and the other port I am trying to connect with 24online hence I'll get a load balancing setup. but I can't take out the 24online from the linux box due to configuration problem :-(


Top    Back


Ramon van Alteren [ramon at vanalteren.nl]
Mon, 15 Jan 2007 10:01:45 +0100

j.bakshi@icmail.net wrote:

> Please note ( as I mentioned in my previous mail) that  the 
> only reason using the linux box with 2 lan is eth0 is used
> to
> dial up the 24online isp and then eth1 is used to redirect
> the connection 
> into the wan port of the router.
> the utility of this router, it is a load balancing router
> with 2 wan port.
> one wan port is connected with data one BSNL connection
> and the other port I am trying to connect with 24online
> hence 
> I'll get a load balancing setup. but I can't take out the
> 24online from the linux box due to configuration problem :-(
>   
I think most people on this list have politely been trying to point out to you that they don't think that the config of your linux server is causing the problems here. I think that the router which is between your lan and your linux server is causing the problems.

A simple way to test this is:

1. Leave the server as is.

2. Remove the router, plug the cable from the linux server straight into the hub/switch

3. Configure one client with the same ip-address as before but assign it statically (by hand) instead of with dhcp.

4. Test if you can reach your linux-server.

5. Test if you can reach an IPADDRESS on the internet (f.e. ping 194.109.21.51 )

If the above steps work, your router is at fault. If they do not, your router MAY STILL BE the faulty part in the setup, but your linux server isn't setup correctly AS WELL !

After you get the server working correctly, it's much easier to setup the router. Debugging one component at a time works better than debugging two.

Regards,

Ramon


Top    Back


[j.bakshi at icmail.net]
Mon, 15 Jan 2007 01:41:43 -0800

----- Original Message Follows -----

From: Ramon van Alteren <ramon@vanalteren.nl>
To: j.bakshi@icmail.net, The Answer Gang
<tag@lists.linuxgazette.net> Cc: Kapil Hari Paranjape <kapil@imsc.res.in>
Subject: Re: [TAG] how to share internet from a linux server
Date: Mon, 15 Jan 2007 10:01:45 +0100
> j.bakshi@icmail.net wrote:
> > Please note ( as I mentioned in my previous mail) that 
> > the  only reason using the linux box with 2 lan is eth0
> > is used to
> > dial up the 24online isp and then eth1 is used to
> > redirect the connection 
> > into the wan port of the router.
> > the utility of this router, it is a load balancing
> > router with 2 wan port.
> > one wan port is connected with data one BSNL connection
> > and the other port I am trying to connect with 24online
> > hence 
> > I'll get a load balancing setup. but I can't take out
> > the 24online from the linux box due to configuration
> >   problem :-( 
> I think most people on this list have politely been trying
> to point out to you that they don't think that the config
> of your linux server is causing the problems here.
> I think that the router which is between your lan and your
> linux server is causing the problems.
> 
> A simple way to test this is:
> 
> 1. Leave the server as is.
> 
> 2. Remove the router, plug the cable from the linux server
> straight into the hub/switch
> 
> 3. Configure one client with the same ip-address as before
> but assign it statically (by hand) instead of with dhcp.
> 
> 4. Test if you can reach your linux-server.
> 
> 5. Test if you can reach an IPADDRESS on the internet
> (f.e. ping 194.109.21.51 )
> 
> If the above steps work, your router is at fault.
> If they do not, your router MAY STILL BE the faulty part
> in the setup, but your linux server isn't setup correctly
> AS WELL !
> 
Thanks a lot for the approach u have mentioned :-) I have plugged the linux box directly into the hub and setup a client machine accordingly ( with ip , dns and gw) and successfully surfed the net :-) yahoo, so I am sharing the net connection from the linux box :-)

and now I have to confogure the router so that it can be a load balancing one with 2 isp. the wan2 port which is attached with the linux box is

wan2 configuration
----------------------------------
ip ----> 192.168.0.114
mask ----> 255.255.255.0
gateway ----> 192.168.0.2 (ip of the linux lan card)
dns ------> 192.168.0.2
I think here I have to verify.

thanks to all responders to atleast fell some success.


Top    Back


[j.bakshi at icmail.net]
Mon, 15 Jan 2007 02:03:46 -0800

----- Original Message Follows -----

From: Ramon van Alteren <ramon@vanalteren.nl>
To: j.bakshi@icmail.net, The Answer Gang
<tag@lists.linuxgazette.net> Cc: Kapil Hari Paranjape <kapil@imsc.res.in>
Subject: Re: [TAG] how to share internet from a linux server
Date: Mon, 15 Jan 2007 10:01:45 +0100
> j.bakshi@icmail.net wrote:
> > Please note ( as I mentioned in my previous mail) that 
> > the  only reason using the linux box with 2 lan is eth0
> > is used to
> > dial up the 24online isp and then eth1 is used to
> > redirect the connection 
> > into the wan port of the router.
> > the utility of this router, it is a load balancing
> > router with 2 wan port.
> > one wan port is connected with data one BSNL connection
> > and the other port I am trying to connect with 24online
> > hence 
> > I'll get a load balancing setup. but I can't take out
> > the 24online from the linux box due to configuration
> >   problem :-( 
> I think most people on this list have politely been trying
> to point out to you that they don't think that the config
> of your linux server is causing the problems here.
> I think that the router which is between your lan and your
> linux server is causing the problems.
> 
> A simple way to test this is:
> 
> 1. Leave the server as is.
> 
> 2. Remove the router, plug the cable from the linux server
> straight into the hub/switch
> 
> 3. Configure one client with the same ip-address as before
> but assign it statically (by hand) instead of with dhcp.
> 
> 4. Test if you can reach your linux-server.
> 
> 5. Test if you can reach an IPADDRESS on the internet
> (f.e. ping 194.109.21.51 )
> 
> If the above steps work, your router is at fault.
> If they do not, your router MAY STILL BE the faulty part
> in the setup, but your linux server isn't setup correctly
> AS WELL !
> 
> After you get the server working correctly, it's much
> easier to setup the router.
> Debugging one component at a time works better than
> debugging two.
> 
> Regards,
> 
> Ramon

Finally SUCCESS !! I have configured the router wan2 port as [obtain ip automatically] and every thing is working great.

Thanks to the list for its valuable guidance and baring with me with the problem. thanks and honour to the list.


Top    Back


Ramon van Alteren [ramon at vanalteren.nl]
Mon, 15 Jan 2007 14:24:04 +0100

j.bakshi@icmail.net wrote:

> Finally SUCCESS !! I have configured the router wan2 port as
> [obtain ip automatically] and every thing is working great.
>
> Thanks to the list for its valuable guidance and baring with
> me with the problem.
> thanks and honour to the list.
>   
Nice to hear it worked.

Just curious, you are aware that linux can do the routers task without any problems ? You are also aware that in case of a breakage of one of your internet lines will most likely result in some loss of traffic with any load-balancing setup ?

In nearly all cases renewal of the request will succeed afterwards due to the loadbalancing. But if you are building this for a system with a transactional nature this is something you should be aware of.

Best regards,

Ramon


Top    Back