Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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
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
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?
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
Distribution: Gentoo, Redhat 9, SuSE 9.0, 9.2, Win XP
Posts: 149
Rep:
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.
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.
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.
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 ?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.