LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Problem with internet sharing through a router (https://www.linuxquestions.org/questions/linux-networking-3/problem-with-internet-sharing-through-a-router-482524/)

ssalman 09-11-2006 03:01 PM

Problem with internet sharing through a router
 
I’m trying to setup a firewall/filtering PC for a local network, but I hit a wall being not able to share the internet connection through my router. Here is the setup: I have a PC with Ubuntu installed and 2 NICs. I’m using the below commands to enable NAT, and I have installed and configured dnsmasq to do the DNS and DHCP.

Code:

$sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
$sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Now this setup works great when I directly connect another PC to my firewall/filtering PC using a crossover cable. But when I connect my router instead of the PC I can’t get to the internet, here is what I tried so far:

- Connecting the firewall/filtering PC to the router using a crossover cable to the internet/wan port on the router. This gave me a connected light on the router, but still no internet connection in the router setup screens (http://192.168.2.1) or through the router using other PCs. I could not ping PCs across the router either.

- Connecting the firewall/filtering PC to the router using a regular cable to one of the LAN ports on the router. This did not give me a connection light on the router, however I was able to ping both PC across the router. But still with no connection to the internet.

I know my problem lays between the router and my firewall/filtering PC, what am I doing wrong?

Thanks for all your help in advance.

Caeda 09-11-2006 03:40 PM

*edited after I re-read your post*
Toss out the crossover cable. And throw out the dns and dhcp software.
Plug the second network card, and all the other computers into the router in the normal pc ports, don't even use the one labeled for an internet connection.
Load up some cheap/free proxy software on the firewall/filter pc, and have the other computers connect to the internet through your proxy. The router can handle the dhcp and setting up the net for you this way, and you can keep track of the traffic that is requested of your proxy. :)

ssalman 09-11-2006 10:12 PM

Quote:

Originally Posted by Caeda
Load up some cheap/free proxy software on the firewall/filter pc, and have the other computers connect to the internet through your proxy.

I'll give it a try this week and report back. Thanks for your help Caeda! :)

ssalman 09-18-2006 09:46 AM

Well, it took some time, but I got it to work finally. I still have a small problem, but more on that later…

I installed tinyproxy, and after tinkering with its configuration files, I’m now able to share my filtered internet connection through the router :) I will play with it some more to figure out all what I need, but I think I have got my self a solution, THANKS Caeda!!

Now for the problem: because I have two NICs on my proxy PC, two servers answer DHCP requests: the DSL modem, and my router, and they overwrite each others DNS and routing table info. :( so my internet connection get messed up.

I tried to setup /etc/iftab so that I have the eth1 and eth2 fixed and not switching around every boot (which worked so far) and then setup /etc/network/interfaces so that only my modem facing NIC will use DHCP, while the router facing NIC uses static IP setup, still it didn’t work, I had to disconnect my router and lunch dhclient and reconnect my router when finished in order to fix the internet connection. Another reason I want a static ip on the router facing NIC is that I don't want to change my browser settings everytime the IP address change.

What can I do to fix this issue?


Thanks

ssalman 09-19-2006 09:38 AM

Found the problem... it was the DNS settings being overwritten by the last NIC being brought up, so I switched the eth numbers in iftab where the NIC facing the DSL modem (the one with DHCP) being last, and the one with static IP (the NIC facing the router) being first, and so the modem will dictate the DNS settings… works like a charm.


All times are GMT -5. The time now is 01:00 PM.