LinuxQuestions.org
Visit Jeremy's Blog.
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 02-24-2007, 07:41 AM   #1
arunksit
LQ Newbie
 
Registered: Feb 2007
Posts: 13

Rep: Reputation: 0
internet connection sharing in linux


Hi,
I am using edubuntu 6.06 in my machine & i've got two ethernet cards.One for internet & other for LAN.Internet is working fine in my system.I want to share net connection with one windows machine in our local network.Around 50 machines are there in our local network connected via ethernet switch.Please suggest a suitable software with which i can share my internet with only one machine,authenticating by means of IP address or MAC address.


Thanks in advance...
 
Old 02-24-2007, 04:12 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by arunksit
I am using edubuntu 6.06 in my machine & i've got two ethernet cards.One for internet & other for LAN.Internet is working fine in my system.I want to share net connection with one windows machine in our local network.Around 50 machines are there in our local network connected via ethernet switch.Please suggest a suitable software with which i can share my internet with only one machine,authenticating by means of IP address or MAC address.
this is easily done using iptables, which is already included in your distro...

here's a script i put together for you to get you started:
Code:
#!/bin/sh

IPT="/sbin/iptables"

WAN_IFACE="eth0"
LAN_IFACE="eth1"

WINDOWS_PC_MAC="ex:ex:ex:ex:ex:ex"
WINDOWS_PC_IP="123.123.123.123"


# Shouldn't be any need for you to edit below this line.

$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT ACCEPT

$IPT -t mangle -P PREROUTING ACCEPT
$IPT -t mangle -P INPUT ACCEPT
$IPT -t mangle -P FORWARD ACCEPT
$IPT -t mangle -P OUTPUT ACCEPT
$IPT -t mangle -P POSTROUTING ACCEPT

$IPT -t nat -P PREROUTING ACCEPT
$IPT -t nat -P POSTROUTING ACCEPT
$IPT -t nat -P OUTPUT ACCEPT

$IPT -F
$IPT -F -t nat
$IPT -F -t mangle

$IPT -X
$IPT -X -t nat
$IPT -X -t mangle

$IPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -i lo -j ACCEPT

$IPT -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

$IPT -A FORWARD -i $LAN_IFACE -o $WAN_IFACE -m mac --mac-source \
$WINDOWS_PC_MAC -s $WINDOWS_PC_IP -m state --state NEW -j ACCEPT

$IPT -t nat -A POSTROUTING -o $WAN_IFACE -j MASQUERADE
to enable forwarding, you'll need to make sure you have this line uncommented in your /etc/sysctl.conf file:
Code:
net/ipv4/ip_forward=1
when you edit that file, you'll need to either reboot, or execute this command for the change to take effect:
Code:
sudo sysctl -p
if this is the first time you deal with iptables or packet forwarding, you are bound to have questions about this - please don't hesitate to ask...

Last edited by win32sux; 02-24-2007 at 07:11 PM.
 
Old 02-25-2007, 09:39 AM   #3
arunksit
LQ Newbie
 
Registered: Feb 2007
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks for the info..
I did as u said and added the script to /etc/sysctl.conf.But when i enter the command sudo sysctl -p, i get syntax error messages in the file .the sharing is not working..

Thanks in advance

Last edited by arunksit; 02-25-2007 at 09:42 AM.
 
Old 02-25-2007, 12:52 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
the syntax for the line was wrong. use "net.ipv4.ip_forward = 1"
 
Old 02-25-2007, 01:46 PM   #5
arunksit
LQ Newbie
 
Registered: Feb 2007
Posts: 13

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by acid_kewpie
the syntax for the line was wrong. use "net.ipv4.ip_forward = 1"
Thanks for the info..
Again it is flashing the error message that the lines
WINDOWS_PC_MAC etc are having wrong syntax.We have to place the script in the sysctl.conf file ,right..?
Thanks in advance....
 
Old 02-25-2007, 01:55 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you mean that big long iptables script? oh god no, certainly not, that'll bust all sorts of things. he just intended that to be a general script to put wherever you felt like.
 
Old 02-25-2007, 03:43 PM   #7
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by acid_kewpie
the syntax for the line was wrong. use "net.ipv4.ip_forward = 1"
the reason i chose slashes when i posted is cuz ubuntu comes with commented examples in the sysctl.conf file - all using slashes instead of periods... if i'm not mistaken, the kernel will accept either syntax, though...

@arunksit: just to clarify what has already been stated by acid_kewpie: the only line you need to add to your sysctl.conf is the ip_forward one... the script i posted should be saved as a file of its own... you would then edit said file, providing the IP and MAC of the windows box (and making sure the interface names are correct)... then you'd make the file executable and then execute it... then you could begin testing connectivity from the windows box to make sure it's working fine... remember you'll need to configure the GATEWAY address of the windows box to be the IP of the $LAN_IFACE on the linux box...

in fact, could you post the output of these from the linux box?? it would help us make sure you are all set as far as IP configuration et al is concerned...
Code:
ifconfig
Code:
route -n
Code:
cat /etc/resolv.conf
make sure you obfuscate the IP of your $WAN_IFACE before posting, for your protection... for example, instead of 200.123.123.234 you could use 200.123.xxx.xxx or similar...

Last edited by win32sux; 02-25-2007 at 07:04 PM.
 
Old 02-25-2007, 03:46 PM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
really? oh well, my bad. every commented example i've seen is with .'s. obviously it's the bash script in it that's doign the damage!
 
  


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
sharing internet connection in linux parthbakshi SUSE / openSUSE 1 03-10-2006 12:46 PM
Linux internet sharing connection with XP des33 Linux - Networking 2 03-10-2005 07:05 AM
Internet Connection Sharing through Linux 9 unmesh vaidya Linux - Newbie 1 11-25-2003 07:32 AM
Internet Connection Sharing LINUX Please HELP MistroTHX Linux - Networking 2 10-06-2003 03:50 PM
Sharing Internet connection via Linux 8.0 troyzeng Linux - Networking 1 09-20-2003 02:41 PM

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

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