LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-14-2006, 02:40 AM   #1
mbreith
Member
 
Registered: Feb 2006
Location: oregon
Distribution: PIII fedora2 | P4 fedora2 | Thinkpad fedora2
Posts: 54

Rep: Reputation: 15
Trying to connect a second computer to the internet through the first


I want to connect one of my computers to the internet using the connection from another computer. I tried looking in the howto's and such, but I don't even know what services and daemons I need. It's hard to find stuff when I don't know what I am looking for.

The computer that has the internet connection is running a basic version of suse9.1. Mostly I let it install itself, so I don't know exactly what it has on there already. I am connecting with a DSL modem through an ethernet cable. This computer also has a second ethernet card connected to my other computer.

My other computer that I want to connect is running fedora core 2. I think it also has two ethernet cards, but one of them is built into the mainboard and is covered by the case. The network cable is installed correctly between the two computers (I am able to network the Windows halfs of the same two computers).

So will somebody tell me what I am looking for so I can go find it.
Thanks
 
Old 02-14-2006, 04:53 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
you need iptables with masquerade and ip_forward set to 1.
 
Old 02-15-2006, 01:20 AM   #3
mbreith
Member
 
Registered: Feb 2006
Location: oregon
Distribution: PIII fedora2 | P4 fedora2 | Thinkpad fedora2
Posts: 54

Original Poster
Rep: Reputation: 15
Ok, not quite there yet.

I searched online and found a shell script to get this started. Just giving the useful information that it runs rather than pasting the entire script.

/sbin/modprobe ip_masq_ftp
echo "1" > /proc/sys/net/ipv4/ip_forward
/sbin/ipchains -P forward DENY
/sbin/ipchains -A forward -s 192.168.0.0/24 -j MASQ

Running that first line gives me this error:
FATAL: Module ip_masq_ftp not found.

Please don't tell me that I need to recompile the kernel. I really don't think I am ready for that, but that is what that error sounds like to me.
 
Old 02-15-2006, 02:57 PM   #4
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Try this :
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

(supposing your internet is on eth0)

Are you planning to do passive ftp? If not, then you dont need ip_masq_ftp

Last edited by Agrouf; 02-15-2006 at 03:08 PM.
 
Old 02-15-2006, 03:15 PM   #5
mbreith
Member
 
Registered: Feb 2006
Location: oregon
Distribution: PIII fedora2 | P4 fedora2 | Thinkpad fedora2
Posts: 54

Original Poster
Rep: Reputation: 15
bash: iptables: command not found

I think I need to download and install something to get this working. A new distribution perhaps?

How difficult is it to get an external DSL modem connected and working with my DSL provider in fedora or debian or something. The only thing I like about suse anymore is that yast connected to the internet without any trouble.

I assume that if I install a different distro, I should back up all my files in my home folders. Should I back up all the hidden files also, or will they not be useable in the new OS?
 
Old 02-16-2006, 11:35 AM   #6
mbreith
Member
 
Registered: Feb 2006
Location: oregon
Distribution: PIII fedora2 | P4 fedora2 | Thinkpad fedora2
Posts: 54

Original Poster
Rep: Reputation: 15
I replaced the distro with Fedora core 2. I found the /sbin/iptables. I also found a tutorial online which has a large shell script that I only barely understand. What I got out of it is this:

/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_dynaddr
/sbin/iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

Does this look right?

It still isn't working. Is there something I need to do with the other computer to tell it where to look to connect to the internet?
 
Old 02-19-2006, 11:10 PM   #7
mbreith
Member
 
Registered: Feb 2006
Location: oregon
Distribution: PIII fedora2 | P4 fedora2 | Thinkpad fedora2
Posts: 54

Original Poster
Rep: Reputation: 15
Ok. Changing the order because I hear it makes a difference. I also learned how to list the contents of the iptables.

Code:
[root@pool-71-111-89-152 ]# echo "1" > /proc/sys/net/ipv4/ip_forward
[root@pool-71-111-89-152 ]# /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
[root@pool-71-111-89-152 ]# /sbin/iptables -t nat -n -L -v 
Chain PREROUTING (policy ACCEPT 157 packets, 13489 bytes)
 pkts bytes target     prot opt in     out     source               destination                                                                                 
 
Chain POSTROUTING (policy ACCEPT 40 packets, 2481 bytes)
 pkts bytes target     prot opt in     out     source               destination                                                                                 
    0     0 MASQUERADE  all  --  *      eth0    0.0.0.0/0            0.0.0.0/0                                                                                 
 
Chain OUTPUT (policy ACCEPT 40 packets, 2481 bytes)
 pkts bytes target     prot opt in     out     source               destination
What does the source 0.0.0.0/0 destination 0.0.0.0/0 mean?

On my 'server' system, eth0 is connected to the internet and eth1 is connected to the other computer.

I have my other computer's network settings to use the IP address of eth1 as its default gateway. I am still getting a 'www.anywebsite.com cannot be found' error. Do I need to set up a DNS somewhere?

Does anyone have more suggestions or websites for me?
 
Old 02-21-2006, 02:13 AM   #8
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
An address with 0s at the end is a subnetwork.
For instance : if the subnet ip mask is 255.255.255.0, addresses 192.168.1.1 and 192.168.1.2 are nodes (computers) and 192.168.1.0 is the sub network of all computers with an address like 192.168.0.x
You can write it 192.168.1.0/255.255.255.0 or 192.168.1.0/24 (because the first 24 bits of the mask are 1 and the rest is 0.
So, 0.0.0.0/0 is the subnetwork of all addresses (not really a subnetwork then, but all the network), because all the mask is 0 and all the address is 0. It means than any address is in this network. In your case, it means that all addresses will be masqueraded.

Last edited by Agrouf; 02-21-2006 at 02:17 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to connect one computer to another without an internet connection? wearetheborg Linux - Software 9 12-28-2004 12:02 AM
how i can make connect to internet through another computer ibrhaidar Linux - Networking 2 12-25-2004 11:41 AM
Internet is slower on my win computer than on my linux computer eXor Linux - Networking 1 12-03-2004 08:58 AM
Internet on 2nd computer thru 1st computer jmsuthar General 4 09-11-2004 11:03 PM
can't connect to the internet:linux dont read my internet address droplsh Linux - General 1 02-29-2004 07:32 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration