LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 06-06-2005, 11:32 PM   #1
friendklay
Member
 
Registered: Jan 2003
Posts: 36

Rep: Reputation: 15
Question Intenet Sharing on Linux


Hi gurus,
how do I do a simple internet sharing on Linux? I know I have to use iptables and add some routes. I have two network cards. One connects to the ADSL Modem, while the other connects to the internal network. How do I set this up?
Thanks
 
Old 06-07-2005, 12:03 AM   #2
~=gr3p=~
Member
 
Registered: Feb 2005
Location: ~h3av3n~
Distribution: RHEL 4, Fedora Core 3,6,7 Centos 5, Ubuntu 7.04
Posts: 227

Rep: Reputation: 30
Re: Intenet Sharing on Linux

Quote:
Originally posted by friendklay
Hi gurus,
how do I do a simple internet sharing on Linux? I know I have to use iptables and add some routes. I have two network cards. One connects to the ADSL Modem, while the other connects to the internal network. How do I set this up?
Thanks
very good document on using the best Squid proxy server :

http://www.linuxhomenetworking.com/linux-adv/squid.htm
 
Old 06-07-2005, 12:06 AM   #3
aaa
LQ Guru
 
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194

Rep: Reputation: 47
Use this script:
Code:
EXTIF=adsl_interface_name_here
INTIF=internal_interface_name_here
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
iptables -A FORWARD -i $INTIF -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
Also you may want to setup dhcpd.
 
Old 06-07-2005, 12:21 AM   #4
friendklay
Member
 
Registered: Jan 2003
Posts: 36

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by aaa
Use this script:
Code:
EXTIF=adsl_interface_name_here
INTIF=internal_interface_name_here
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
iptables -A FORWARD -i $INTIF -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
Also you may want to setup dhcpd.
So the gateway IP for the INTIF would be the IP address of EXTIF, and the gateway IP of the machines inside the LAN would be the IP of INTIF, right?
 
Old 06-07-2005, 08:41 AM   #5
lindani
LQ Newbie
 
Registered: Jun 2005
Posts: 13

Rep: Reputation: 0
Hi friendklay :

your adsl interface=ppp0

you must write this command only:

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

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

at end add this line(echo 1 >/proc/sys/net/ipv4/ip_forward) to /etc/rc.d/rc.local file.

good luck.
 
Old 06-08-2005, 05:08 AM   #6
friendklay
Member
 
Registered: Jan 2003
Posts: 36

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by lindani
Hi friendklay :

your adsl interface=ppp0

you must write this command only:

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

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

at end add this line(echo 1 >/proc/sys/net/ipv4/ip_forward) to /etc/rc.d/rc.local file.

good luck.

My adsl interface is eth0, since I am using an ADSL Modem/Router combo box. I also have two network cards, to seperate my internal network and the internet. I have got it all working now. However, I can't access my adsl console anymore, nor can I ping out. What's amiss?
 
Old 06-08-2005, 06:48 AM   #7
friendklay
Member
 
Registered: Jan 2003
Posts: 36

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by aaa
Use this script:
Code:
EXTIF=adsl_interface_name_here
INTIF=internal_interface_name_here
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
iptables -A FORWARD -i $INTIF -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
Also you may want to setup dhcpd.
I have got that part done. How do I setup gateway IPs for the two interfaces? The thing is I thought to put the IP of eth0 as the gateway IP of eth1. But this didn't work. It seems it only works when I leave the gateway IP of eth1 blank.
 
Old 06-08-2005, 12:04 PM   #8
aaa
LQ Guru
 
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194

Rep: Reputation: 47
Why do you need gateway ips? eth0 should get it's gateway from the adsl automatically, the eth1 does not need one. You only need to assign the gateway on the second computer.
 
  


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
Setting up Wireless Intenet on Mandrake 10.1 phoonerorlater Linux - Newbie 1 10-03-2004 09:22 PM
Intenet Configuration - Unable to browse ro_1010 Linux - Networking 6 03-08-2004 01:10 AM
i can't connect linux to the intenet!! please help imkrazysk8er123 Mandriva 12 09-30-2003 06:33 PM
Intenet through router and cable modem dhirajsharma Linux - Networking 4 09-24-2003 01:45 AM
Intenet Proxy Server VJ2003 Linux - Networking 2 05-03-2003 02:01 AM

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

All times are GMT -5. The time now is 11:05 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