LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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
 
LinkBack Search this Thread
Old 01-02-2005, 06:31 PM   #1
Random`Zero
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 192.168.1.1/24 -o eth0 -j MASQUERADE
$ iptables -A FORWARD -j ACCEPT -i eth1 -s 192.168.1.1/24
$ 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, 10:08 PM   #2
guzzi
Member
 
Registered: Jun 2004
Location: Lawrence, KS
Distribution: Slackware
Posts: 294

Rep: Reputation: 32
internet share

hello Random`Zero

#!/bin/sh
# 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, 10:43 PM   #3
Cii
Member
 
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, 01:26 AM   #4
Random`Zero
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 192.168.1.1 stuff.
 
Old 01-03-2005, 09:19 PM   #5
guzzi
Member
 
Registered: Jun 2004
Location: Lawrence, KS
Distribution: Slackware
Posts: 294

Rep: Reputation: 32
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-03-2005, 11:15 PM   #6
bobinglis
Member
 
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-03-2005, 11:22 PM   #7
bobinglis
Member
 
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 xxx.xxx.xxx.xxx, 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:
IPADDR[0]=""
NETMASK[0]=""
USE_DHCP[0]="yes"
DHCP_HOSTNAME[0]=""

# Config information for eth1:
IPADDR[1]="192.168.0.1"
NETMASK[1]="255.255.255.0"
USE_DHCP[1]=""
DHCP_HOSTNAME[1]=""


# Config information for eth2:
IPADDR[2]=""
NETMASK[2]=""
USE_DHCP[2]=""
DHCP_HOSTNAME[2]=""

# Config information for eth3:
IPADDR[3]=""
NETMASK[3]=""
USE_DHCP[3]=""
DHCP_HOSTNAME[3]=""

# Default gateway IP address:
GATEWAY="xxx.xxx.xxx.xxx"

# 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.
DEBUG_ETH_UP="no"
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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 10:38 AM
Connecting 2 slack 10.0 machines. Uncommenting rc.modules, sharing adsl connection fabio_listas Slackware - Installation 0 07-12-2004 11:36 AM
Internet Connection Sharing 2 FC1 machines explorer Fedora 1 05-05-2004 02:09 AM
Internet Sharing on Linux machines varunbihani Linux - Networking 10 07-20-2003 09:34 AM
Windows Xp, Slackware Internet Connection Sharing. Volcom Slackware 14 07-04-2003 06:18 PM


All times are GMT -5. The time now is 02:38 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration