LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   shared internet connection w/out router (https://www.linuxquestions.org/questions/linux-networking-3/shared-internet-connection-w-out-router-215424/)

4of11 08-09-2004 12:29 PM

shared internet connection w/out router
 
I'm thinking of getting a cheap computer, installing Freevo and using it is a PVR. I would like to be able to connect it to the internet, but I already have my PC hooked up to the ethernet port. I live in a college dorm, and they don't allow routers, so I am wondering if there is a way to connect the PVR to my PC (via USB, maybe?) and have my PC forward the connection to the internet. I am fairly experienced with linux, but not so much with networking. I am running Gentoo on my PC, and would probably do the same on the PVR.

superbondbond 08-09-2004 12:46 PM

you could put two NICs in your PC, and then run iptables (masquerading, NAT, etc. etc.) to share the connection. You would essentially be using your PC as a router. shhh don't tell.... ;)

Using something like Jay's Firewall it would be extremely easy to configure and maintain.

nhs 08-09-2004 12:47 PM

Running a router type setup shouldn't be a problem provided you can get hold of another network card and a length of crossover cable. Should be quite cheap.

echo 1 >/proc/sys/net/ipv4/ip_forward will turn on the router functionality however a few firewall rules are needed first. The trick to keeping everything OK with the college network is to use IP Masquerading or SNAT (depending on whether you have a static IP address) where both essentially rewrite all packets leaving by a specific interface (eth0 probably) so that they appear to come from this machine. You will need to run the following line to set up the firewall:

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source IP address of eth0

for a static IP address. If your IP address changes then

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

should work. To save the configuration use "iptables-save >file". You will then need a line somewhere in your startup scripts "iptables-restore <file". Then install and configure your second network interface to use some IP address and netmask which is different from anything on the college network (e.g. 172.16.0.1 if all the addresses begin 10.). The Freevo machine will need an IP address similar (but not the same as) the IP address of the main machine (e.g. 172.16.0.2). The Freevo machine should then have it's default gateway set to the eth1 IP address of the main machine (172.16.0.1) and it should have the same level of Internet access as your main machine without any external indication that there is more than one machine connected.

I would suggest reading the iptables man page as this contains detailed information on how to configure iptables and there is a lot of information on the web about IP Masquerading as it is commonly used to share dial up modem internet connections.


All times are GMT -5. The time now is 05:55 AM.