LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 06-10-2004, 05:13 AM   #1
SpeedKing
LQ Newbie
 
Registered: Jun 2004
Distribution: Suse
Posts: 2

Rep: Reputation: 0
Internet Connection Sharing


I am NEW to linux but have managed to get up and running pretty well. The prob is for a less computer literate friend who also is a linux convert now thanks to Suse and me. I am asking this becaues i can't help him on my config coz i have broadband via a router and my network was set up auto during install.

He has two comps - his running Linux connected to internet via 56k modem, and his brothers successfully networked running windows 98

His brother needs to connect to the net through his computer, but neither he or I have any idea on how to set it up.

So far we have

Suse Linux 9.1 - connected to net via ppp dialup fully configured
- networked to windows box with IP of 192.168.0.1 with subnet 255.255.255.0

Windows 98 Box - connected to Linux box via eth0
- IP of 192.168.0.157 with subnet 255.255.255.0
- Default gateway at 192.168.0.1

Wot do we have to do on either box to get the old 98 machine online?

any help will be most appreciated. GUI instructions preferable, little text file editing experience between either of us

cheers
 
Old 06-10-2004, 10:27 AM   #2
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
what you need is NAT (or "masquerade") and forwarding on the linux box that "shares" the connection to the win98 box...I use this method, but I have one old linux-box as a firewall, another as my own pc and one (my bros) that runs windows. everything works...you'll need iptables for this, and iptables-forwarding/NAT enabled in your kernel (probably is?)

so go and get iptables and install it....here: iptables.org

after this, you just add some rules to your iptables on the linux machine, that enable forwarding and masquerade the ip addresses so that the net works also on the other machine....I think the commands are some like these: (I just wrote them from what I remember...haven't touched on my firewall config for a while, but I think these do):

/sbin/iptables -A FORWARD -i eth0 -j ACCEPT
/sbin/iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

that should work; the interface that accesses net is ppp0 (dial-up connection) and the interface that is shared to is ethernet device eth0. change if you need to....the first line enables forwarding (if eth0 wants something, the data is sent there and not to the linux box itself), second adds masquerading (so that the win-box's ip is translated so it seems like the one of linux-box's, and after data comes back, the translation is done backwards so that both machines kind of like use the same ip and there comes no problems with where the data should be sent) and the third line appends a new rule to accept everything that's being forwarded, if it's part of some known connection.

if you have not set any firewall (iptables) before, then do

/sbin/iptables --flush

before the three lines above. that "clears" the table....oh yeah, and one more thing: after you've done these, test that the net works. if it does, then you _must_ save these lines to some start-up script, like /etc/rc.local (unless some network script already exists), because otherwise they get erased at every restart.

this is a simple thing really...and sorry about the lack of GUI, but iptables is the best when it's in console - some firewall builder (GUI) could do this for you, but I'm not sure...this works and is easy

oh, and if that doesn't work that's above, post here...as I said, I just think I remember them so I might have forgotten some line (or was that third line even needed?)...haven't played with iptables for a while. but after those you don't need to set anything else, net just should work, if the network is already set....

EDIT: yeah, I did forget something the third line is not needed now that I think of it really...but this one is needed:

echo "1" > /proc/sys/net/ipv4/ip_forward

to get the forwarding really start. so, to make it clear, here's what you do in console, as root:

/sbin/iptables --flush
/sbin/iptables -A FORWARD -i eth0 -j ACCEPT
/sbin/iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
echo "1" > /proc/sys/net/ipv4/ip_forward

and that's all. now go to the windows-machine, open up a browser, check from your internet settings that an internet connection is first looked for from the _network_ and only if that doesn't exist, then the _straight_ connection. after this is all right, type some address in your browser and try if it goes should.

and after you see it works, add those 4 lines above to some startup (init) script; if you don't know to which, add them to /etc/rc.local with some text editor of your choise.

Last edited by b0uncer; 06-10-2004 at 10:40 AM.
 
Old 06-10-2004, 11:20 AM   #3
sharma_deepak83
LQ Newbie
 
Registered: May 2004
Location: India
Distribution: Red Hat, mandrake, Fedora,Knoppix
Posts: 27

Rep: Reputation: 15
Got a similar problem?

I have a similar problem. I have a Win2k box connected to the internet via a dialup connection. The problem is that the other machine is LINUX Fedora core 1 BOX. I want it to be online too. Tell me how can I do that. I have Internet connection sharing enabled on Windows 2000. So what all I have to do in LINUX to make it online. Please help me all.
 
Old 06-10-2004, 12:52 PM   #4
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
duh...I'm not that familiar with this stuff, I mean, if or how it differs if windows shares the connection and not linux...but, generally speaking, somekind of NAT would be needed in this case too, I think. and I don't know if or how windows handles this...because the NAT is supposed to be done on the machine that connects to the net. instead I'd change things so that linux connects to net and windows through it...

check at least that in your /etc/hosts.conf the order-line is

order hosts,bind

and not "bind,hosts". I've got to think of this and perhaps google a bit...and also check that your /etc/hosts includes your windows-box's ip address if you don't use dhcp or something like that...

EDIT: at least before I find something else, I think that if the following conditions are filled, the sharing should do:

1) server is sharing the connection and doing possibly the NAT when needed
2) server and clients are using tcp/ip protocol, and ethernet is working
3) clients are configured to first check the ethernet for connection, and only if it fails, use a "straight" connection

so if your linux has the hosts.conf set to first look "hosts" and after it "bind", and the file hosts includes the server's ip address or you use dhcp to get it, everything should work...just remember to add your ISP's DNS-server's ip-address to your linux-box's /etc/resolv.conf or you are not able to use any other method than ip-addresses while surfing etc.

I'll post if I come up with something else

Last edited by b0uncer; 06-10-2004 at 01:25 PM.
 
Old 06-10-2004, 04:28 PM   #5
danoh
LQ Newbie
 
Registered: Jun 2004
Posts: 3

Rep: Reputation: 0
Re: Got a similar problem?

Quote:
Originally posted by sharma_deepak83
I have a similar problem. I have a Win2k box connected to the internet via a dialup connection. The problem is that the other machine is LINUX Fedora core 1 BOX. I want it to be online too. Tell me how can I do that. I have Internet connection sharing enabled on Windows 2000. So what all I have to do in LINUX to make it online. Please help me all.
Thats an Easy one,. Just go to properties on your dial up on your 2000 machine, go to advanced, and set up internet connection sharing. Fedora will find your 2000 machine thru etho 1 and set up mshome network, which will see your 2000 machine, but not the other way around. If it does not connect to the internet then, got to settings in fedora, and choose proxy, but if you only have a nic, and no modem on fedora, you shouldn't have to. Just go to network control and activate etho1 after setting up the 2000 machine to share.

EDIT: Your internet connection on fedora will be as slow as windows. If you set up a modem on fedora, Its almost as fast as cable compared to MS.

Last edited by danoh; 06-10-2004 at 04:34 PM.
 
Old 06-10-2004, 05:13 PM   #6
bareego
Member
 
Registered: Nov 2003
Location: Brisbane, Australia
Distribution: Crux 2.0
Posts: 66

Rep: Reputation: 15
The "quick and dirty" way of doing connection sharing :

A) Server side

1) Windows :

Windows 98SE or later, run the ICS wizard.

2) Linux

find out what device you want to share (ppp0 for dialup, eth0 for ethernet or whatever)
with ifconfig

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -j MASQUERADE -o ppp0 (change last entry with your "shared" device handle)


B) On the client side

1) Windows

Go to the TCPIP properties of your lan connection.
On DNS tab put the DNS IP of your ISP
On Gateway tab put the IP of your Server on the lan

2) Linux

echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf (xxx.xxx.xxx.xxx being the DNS IP of your ISP)
route add default gw yyy.yyy.yyy.yyy (yyy.yyy.yyy.yyy being the IP of your Server on the lan)

All this can be automated by running a DHCP server with the appropriate settings and let the clients "autodetect" the settings (eg dhcpcd eth0 on linux)

Cheers
Bareego
 
Old 06-10-2004, 07:03 PM   #7
SpeedKing
LQ Newbie
 
Registered: Jun 2004
Distribution: Suse
Posts: 2

Original Poster
Rep: Reputation: 0
I wrote a script for him following your instructions and thosse out of another text book

#!bin/sh
# flush any existing rules
/sbin/iptables -F -t nat

# enable NAT
/sbin/iptables -A POSTROUTING
-t nat -s -192.168.0.0/24 -o \ppp0 -j MASQUERADE echo 1 >
/proc/sys/net/ip_forward

The book then told me to saved it in /etc/rc.d/rc.ipmasq
Then chmod 700 /etc/rc.d/rc.ipmasq

Does this mean it will start every time he boots or do i have to put something in the rc.local for him?

Thanks for the prompt replies

Last edited by SpeedKing; 06-10-2004 at 07:06 PM.
 
Old 06-10-2004, 10:47 PM   #8
sharma_deepak83
LQ Newbie
 
Registered: May 2004
Location: India
Distribution: Red Hat, mandrake, Fedora,Knoppix
Posts: 27

Rep: Reputation: 15
What abt the Ip address?

When I enable Internet connection sharing on my Windows 2000 box, OS automatically assigns 192.168.0.1 255.255.255.0 to my Window machine. SO I enabled "get IP address automatically on the other window machine" and enabled "automatically obtain" DNS address. So now in LINUX when I enable it has got a small list box that allows me choose from (dhcp,bootp,(I dont remeber this one)).

WHich should I choose?
 
Old 06-11-2004, 05:45 AM   #9
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
things can get difficult with ms I see good I chose linux to share my connection.

sharma_deepak83, you can of course try the different options if you like...I don't know this for sure but I'd first try dhcp. it's quite totally useless on small networks (a few machines) where it's easiest to just assign own ethernet-class ip-addresses and keep track of them..but anyway, try dhcp first...windows is probably using that...

...but if some of you has better knowledge of this, spit out I don't know about MS that much anymore...perhaps I did back in the days. now I'm almost completely a penguin
 
Old 06-11-2004, 01:09 PM   #10
sharma_deepak83
LQ Newbie
 
Registered: May 2004
Location: India
Distribution: Red Hat, mandrake, Fedora,Knoppix
Posts: 27

Rep: Reputation: 15
Done, Thanx a lot?

yes my LAN is picking up speed and LINUX is online 2. Thanx to all for helping me.
 
Old 06-27-2004, 10:46 AM   #11
gryzli
LQ Newbie
 
Registered: Jun 2004
Location: Bulgaria
Distribution: Fedora core 2.0
Posts: 7

Rep: Reputation: 0
hi guys,i have a problem with linux i-net share..
The script doesn't work properly.I make all the steps u describe,but the winxp machine still don't work(i-net).
i have winxp machine connected with cross-cabel to linux fedora core2 box.
the linux eth1 (is the device connected to the win machine)- 192.168.0.1
eth0 is the device connected to my ISP. 192.168.101.51
ppp0 - the pppoe connection
i don't now why i can't share the connection...
 
  


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
sharing my internet connection berrance Linux - Networking 1 02-25-2005 12:33 PM
SHaring internet connection bart59 Linux - Networking 1 01-27-2005 08:24 AM
Internet Connection Sharing geekbyday Linux - Networking 9 11-19-2004 11:59 PM
Internet connection sharing mark_booze Linux - Newbie 22 01-02-2004 01:37 AM
Internet Connection Sharing Chijtska Linux - Networking 7 09-02-2002 12:50 PM


All times are GMT -5. The time now is 10:29 AM.

Main Menu
Advertisement
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