LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 08-14-2003, 02:18 PM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
internet sharing


Hi there! I have 2 pcs in my house. The first has linux os and the second w98.
How can i share the internet connection of the linux pc so w98 can surf the internet?
Thanx
Alex
 
Old 08-14-2003, 02:55 PM   #2
andrew001
Member
 
Registered: Nov 2002
Distribution: Slackware 9.0
Posts: 321

Rep: Reputation: 30
Yes. This questions has been asked many times on this forum (even once by myself). Please search for existing threads before you start a new one.

If you REALLY can't find anytthing you need to read about how to set up IP Masquerading, NAT, or Proxy.

~Andrew
 
Old 08-14-2003, 03:08 PM   #3
Mathieu
Senior Member
 
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
Manual Setup for RedHat or Mandrake

Edit the file /etc/sysctl.conf and on the line net.ipv4.ip_forward = 0, change 0 to 1.
Code:
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
In order for the changes to take effect,
at the command line, type: service network restart

Now you need to setup IP forwarding and Masquerading.
First, you need to flush the old rules.
So open a console window and at the command line, type:
Code:
service iptables stop
service iptables save
The following commands will create new rules for your system.
Code:
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP

iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
NOTE: In this case, eth0 connects to the internet and eth1 connects to the local network.
You may need to switch eth0 and eth1.
The ifconfig command will give you more information.

To save iptables modifications, at the command line, type: service iptables save.
IPtable rules are located in the /etc/sysconfig/iptables file.

Don't forget to start iptables: service iptables start

Last edited by Mathieu; 09-10-2003 at 06:44 PM.
 
Old 08-14-2003, 04:18 PM   #4
tyler0123
Member
 
Registered: Aug 2003
Posts: 134

Rep: Reputation: 16
also, remember to set the default gateway of the windows box to the lan ip of the linux box.
 
Old 09-10-2003, 01:27 PM   #5
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
xmmmm

I have suse 8.1 but there is no /etc/sysctl.conf .. I must create a new one?
 
Old 09-10-2003, 02:32 PM   #6
Mathieu
Senior Member
 
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
No. My previous post is only for RedHat or Mandrake.

For SuSE, you can do the following:

Create a file in the /etc/rc.d directory called rc.firewall and add the following to it.
Code:
#!/bin/bash
IPTABLES=/sbin/iptables

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

$IPTABLES -P INPUT ACCEPT
$IPTABLES -F INPUT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -F OUTPUT
$IPTABLES -P FORWARD DROP
$IPTABLES -F FORWARD
$IPTABLES -t nat -F

$IPTABLES -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i eth1 -o eth0 -j ACCEPT

$IPTABLES -t nat -A POSTROUTING -o eth0 -j MASQUERADE
NOTE: In this case, eth0 connects to the internet and eth1 connects to the local network. You may need to switch eth0 and eth1.
The ifconfig command will give you more information.

Don't forget to change the permissions of rc.firewall
Code:
chmod 700 /etc/rc.d/rc.firewall
And, of course, you will have to append the following line to /etc/rc.d/boot.local
If you can't find the boot.local file, look for /etc/rc.d/rc.local
Code:
/etc/rc.d/rc.firewall

Last edited by Mathieu; 02-22-2004 at 10:01 AM.
 
Old 09-10-2003, 03:48 PM   #7
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
thx

Thnx a lot!!
This is the only thing that i must do? Great.
Do u know how i must setup w98?
Where i can find a place with documentation for internet sharing?
 
Old 09-10-2003, 06:44 PM   #8
Mathieu
Senior Member
 
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
Well... no...

Is the Linux PC (which has the Internet connection) able to connect to the internet ?
Did you configure the second network card ?

Assuming that the second network card is 192.168.1.1
On win98, go to Control Panel and click on Network.
Select TCP/IP and click on Properties.
- Set the IP address (192.168.1.2) and the Subnet Mask (255.255.255.0).
- In the Gateway tab, add the IP of the Linux PC (192.168.1.1)
- In the DNS tab, add the DNS IPs from your internet provider. You can get these IPs on Linux by looking in /etc/resolv.conf
 
Old 11-14-2003, 09:03 AM   #9
moto
LQ Newbie
 
Registered: Nov 2003
Location: mumbai
Distribution: redhat linux 9
Posts: 2

Rep: Reputation: 0
Give the following three commands

iptables -t nat -F POSTROUTIG
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "1">/proc/sys/net/ipv4/ip_forward
 
Old 11-14-2003, 10:01 AM   #10
paul.nel
Member
 
Registered: Nov 2003
Location: Cape Town
Distribution: Gentoo, Redhat 9, SuSE 9.0, 9.2, Win XP
Posts: 149

Rep: Reputation: 15
For an excellent rundown on setting up internet sharing find teh IP-Masquerading-HowTo at www.tldp.org. Most of the rules that Mathieu gave you probably came from here. They look very similar.

Good luck.
p.n
 
Old 11-16-2003, 02:15 PM   #11
revoloco
LQ Newbie
 
Registered: Nov 2003
Location: Mexico
Distribution: Slackware, Gentoo
Posts: 7

Rep: Reputation: 0
Ok, but what if I have a modem to connect to internet, and the eth0 is connected to the local network?, Everything else is the same, the linux box (redhat9) is the one that connects to the internet.
Thanks, any help will be apreciated.
 
Old 11-16-2003, 03:24 PM   #12
tricky_linux
Member
 
Registered: Jul 2003
Distribution: Red Hat Linux 9.0; Old and Solid
Posts: 674

Rep: Reputation: 30
to Mathieu~

But how about linux to linux.
I have an Dell Laptop which was running redhat linux 9.0 which equipped with an MiniPci modem which i can't get it to work. and I have a desktop which i could use redhatlinux 9.0 to dialup the internet.
SO, do i do the same thing as you state.
eth1 was my desktop's second lan(192.168.0.231) and all my pc was connected to a 10t hub.
I did
net.ipv4.ip_forward = 1 in /etc/sysctl.conf
services network restart
services iptables stop
service iptables save
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP

iptables -A FORWARD -i ppp0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o ppp0 -j ACCEPT

iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
services iptables save
services iptables start

What do i need to do on my laptop?
I did configure my 3com lan(192.168.0.123) and i can ping 192.168.0.231 which was my desktop's ip and i did set my laptop's default gateway address to 192.168.0.231.
But when i open up my mozilla browser, trying to go to www.google.com. It says "www.google.com could not be found. Please check the name and try again."
Do know what's wrong or did i do it right?

Last edited by tricky_linux; 11-16-2003 at 03:26 PM.
 
Old 11-17-2003, 06:41 PM   #13
Mathieu
Senior Member
 
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
revoloco: Take a look at tricky_linux's set up.

tricky_linux:
Did you add your DNS IPs to /etc/resolv.conf ?
- Copy the contents of /etc/resolv.conf from the desktop to the laptop.
- Restart your Network service.
Are you now able to ping an external IP address (216.239.39.100) and a domain (google.ca) ?

Also, in your setup, you mentioned eth1. Are you sure it is eth1 and not eth0 ?
 
Old 11-18-2003, 06:43 PM   #14
tricky_linux
Member
 
Registered: Jul 2003
Distribution: Red Hat Linux 9.0; Old and Solid
Posts: 674

Rep: Reputation: 30
to Mathieu~
I didn't do anythings about file "/etc/resolv.conf"
Missed somepart.
anyway, i am sure of the port my local net used was eth1.
Because i have an ASUS A7N8X Deluxe mobo and redhatlinux 9.0 doesn't support onbaord NVIDIA's ethenet card. So, i had compile the source myself . Then eth1 appears which was using nvnet. SO i know that must be.
I can ping locally, but not internet from my laptop.
But i will do the part which i missed and the content was
"Don't forget to change the permissions of rc.firewall

code:chmod 700 /etc/rc.d/rc.firewall



And, of course, you will have to append the following line to /etc/rc.d/rc.local

code:/etc/rc.d/rc.firewall"


And for my laptop wich can't get access to internet through modem, what do i need to do for it? Do i only need to just set the IP address?

I will try what you had said and see it works or not.

Last edited by tricky_linux; 11-18-2003 at 06:47 PM.
 
Old 11-18-2003, 07:01 PM   #15
Mathieu
Senior Member
 
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
Yes, do the modifications to /etc/resolv.conf

And

Since you are using RedHat 9.0, follow the steps in the post entitled Manual Setup for RedHat or Mandrake (the third post).

The post concerning rc.firewall is for other Linux distribution.
 
  


Reply



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
Internet Sharing crazykiller Linux - Networking 12 10-29-2005 05:06 AM
mandrake 10.1 sharing files and internet sharing xfiles_arram Linux - Networking 0 05-21-2005 02:22 PM
File sharing and internet sharing mullet Linux - Networking 1 10-14-2003 01:30 PM
internet sharing vher Linux - Networking 2 01-18-2003 03:30 AM
internet sharing jetfreggel Linux - Newbie 11 05-23-2002 11:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:48 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
Open Source Consulting | Domain Registration