Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 01-02-2005, 07:31 PM   #1
LQ Newbie
Registered: Dec 2004
Posts: 22

Rep: Reputation: 15
Internet connection sharing between 2 slackware machines

I've tried everything but nothing works..

What seems to be the most popular solution is:
$ iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE
$ iptables -A FORWARD -j ACCEPT -i eth1 -s
$ iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

But I still can't access the net on my 2nd pc.

Does anyone know what's wrong?
Old 01-02-2005, 11:08 PM   #2
Registered: Jun 2004
Location: Lawrence, KS
Distribution: Slackware
Posts: 301

Rep: Reputation: 35
internet share

hello Random`Zero

# flush any old rules
iptables -F -t nat
iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A OUTPUT -o lo -p all -j ACCEPT
# -- this opens Secure Shell port --------
iptables -A INPUT -p tcp -i eth0 --dport 22 -j ACCEPT
iptables -A INPUT -p udp -i eth0 --dport 22 -j ACCEPT
# ---- Accept established connections -----------
iptables -A INPUT -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --tcp-option ! 2 -j REJECT
# -- drop all other ports ----------
iptables -P INPUT DROP
# turn on NAT (IP masquerading for outgoing packets)
iptables -A POSTROUTING -t nat -o ppp0 -j MASQUERADE
# enable IP forwarding (of incoming packets)
echo 1 > /proc/sys/net/ipv4/ip_forward
# --- update /var/log/syslog with activity-----makes lots of data ---
iptables -A INPUT -j LOG --log-prefix "INPUT_DROP: "
#iptables -A OUTPUT -j LOG --log-prefix "OUTPUT_DROP: "

The above will work as a firewall and internet sharing script. Name it rc.firewall and put it in
/etc/rc.d and make it executable.

also on the second Slackware box, the /etc/rc.d/rc.inet1.conf will need the ip address
of the gateway unit.

There may be more, but I believe that's it. I'm on a laptop in my living doing just exactly what it is that you are trying to establish.

Good Luck
Old 01-02-2005, 11:43 PM   #3
Registered: Jul 2003
Location: Canada
Distribution: SuSE 9.2
Posts: 41

Rep: Reputation: 15
hey guzzi, just wondering if this script specific for slackware or would it run in other distros as well?
Old 01-03-2005, 02:26 AM   #4
LQ Newbie
Registered: Dec 2004
Posts: 22

Original Poster
Rep: Reputation: 15
Thanks for the help guzzi but isn't ppp0 used when you're connected directly to the modem?

I'm behind a (Linksys) router and I was told that I had to use the stuff.
Old 01-03-2005, 10:19 PM   #5
Registered: Jun 2004
Location: Lawrence, KS
Distribution: Slackware
Posts: 301

Rep: Reputation: 35
internet share

Opps..Random`Zero I think you are right.

I am on a dial up so I use the ppp0. Guess I just think everyone else is too. Ha.

And, I don't really know how yours would be configured. Other than if the ethernet card in your
box that the script is running on is using eth0 to access the router, it may be that you could use
eth0 in place of ppp0.

And Cii, I have not tried this with other distros, but if they use iptables, it "should" work.

I have a 486 running a stripped down version of Slack10. It has a modem and one ethernet card.
The ethernet card is connected to a 8 port switch that all the other systems here are also connected
to. With that script running on the 486, and it also dialing and establishing the connection to my ISP
all the systems have access to the internet. That script has kept a windows2000 box running
Norton Internet Security 2004 from ever being triggered. Whereas if the win2000 box connects
to the internet through it's own modem, Norton triggers often.
Old 01-04-2005, 12:15 AM   #6
Registered: Dec 2003
Location: MK
Distribution: \\slackware 10.1
Posts: 50

Rep: Reputation: 15
Do Ifconfig -a and post o/p, your router should be setup for DHCP and the NIC(normally eth0) which is connected will need to set to DHCP = yes, you DHCPC running, have a look at dhcp howtos for more explanations as there are different setup options.
Old 01-04-2005, 12:22 AM   #7
Registered: Dec 2003
Location: MK
Distribution: \\slackware 10.1
Posts: 50

Rep: Reputation: 15
here is a working conf file all you need is the router gateway address in place, hope this helps

# /etc/rc.d/rc.inet1.conf
# This file contains the configuration settings for network interfaces.
# If USE_DHCP[interface] is set to "yes", this overrides any other settings.
# If you don't have an interface, leave the settings null ("").

# Config information for eth0:

# Config information for eth1:

# Config information for eth2:

# Config information for eth3:

# Default gateway IP address:

# Change this to "yes" for debugging output to stdout. Unfortunately,
# /sbin/hotplug seems to disable stdout so you'll only see debugging output
# when rc.inet1 is called directly.


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 internet connection between Slackware and XP via crossover cable islord Linux - Networking 3 01-24-2005 11:38 AM
Connecting 2 slack 10.0 machines. Uncommenting rc.modules, sharing adsl connection fabio_listas Slackware - Installation 0 07-12-2004 12:36 PM
Internet Connection Sharing 2 FC1 machines explorer Fedora 1 05-05-2004 03:09 AM
Internet Sharing on Linux machines varunbihani Linux - Networking 10 07-20-2003 10:34 AM
Windows Xp, Slackware Internet Connection Sharing. Volcom Slackware 14 07-04-2003 07:18 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration