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 11-06-2004, 08:18 AM   #1
atari303
Member
 
Registered: May 2001
Posts: 34

Rep: Reputation: 15
slackware 10 & iptables


Hello all,

I have upgraded to Slackware 10 and lost my network:

rc.local file assigns eth1 inet addr:192.168.0.3 and netmask 255.255.255.0 and runs rc.firewall successfully as I can see this from boot.

ifconfig shows eth0 & eth1 up with eth1 having the 192.168.0.3 address. (This time Slackware 10 actually found my 2nd NIC so I didn't have to load drivers as with previous installs.)

windows xp machine has an IP of 192.168.0.4, subnet:255.255.255.0 and a gateway of 192.168.0.3 along with the DNS of my internet provider.

lsmod shows ipt_MASQUERADE, ipt_state, ipt_LOG, along with a bunch of other iptables related modules.

I have connectivity from my ISP to the Slackware machine but cannot communicate between Windows & Slackware, cannot ping to either from either.

I cannot think of what I'm missing, finally here is my rc.firewall file:


#!/bin/sh
#
# rc.firewall-2.4
FWVER=0.63
#
# Initial SIMPLE IP Masquerade test for 2.4.x kernels
# using IPTABLES.
#
# Once IP Masquerading has been tested, with this simple
# ruleset, it is highly recommended to use a stronger
# IPTABLES ruleset either given later in this HOWTO or
# from another reputable resource.
#
#
#
# Log:
# 0.63 - Added support for the IRC IPTABLES module
# 0.62 - Fixed a typo on the MASQ enable line that used eth0
# instead of $EXTIF
# 0.61 - Changed the firewall to use variables for the internal
# and external interfaces.
# 0.60 - 0.50 had a mistake where the ruleset had a rule to DROP
# all forwarded packets but it didn't have a rule to ACCEPT
# any packets to be forwarded either
# - Load the ip_nat_ftp and ip_conntrack_ftp modules by default
# 0.50 - Initial draft
#

echo -e "\n\nLoading simple rc.firewall version $FWVER..\n"


# The location of the 'iptables' program
#
# If your Linux distribution came with a copy of iptables, most
# likely it is located in /sbin. If you manually compiled
# iptables, the default location is in /usr/local/sbin
#
# ** Please use the "whereis iptables" command to figure out
# ** where your copy is and change the path below to reflect
# ** your setup
#
#IPTABLES=/sbin/iptables
IPTABLES=/usr/local/sbin/iptables


#Setting the EXTERNAL and INTERNAL interfaces for the network
#
# Each IP Masquerade network needs to have at least one
# external and one internal network. The external network
# is where the natting will occur and the internal network
# should preferably be addressed with a RFC1918 private address
# scheme.
#
# For this example, "eth0" is external and "eth1" is internal"
#
# NOTE: If this doesnt EXACTLY fit your configuration, you must
# change the EXTIF or INTIF variables above. For example:
#
# EXTIF="ppp0"
#
# if you are a modem user.
#
EXTIF="eth0"
INTIF="eth1"
echo " External Interface: $EXTIF"
echo " Internal Interface: $INTIF"


#======================================================================
#== No editing beyond this line is required for initial MASQ testing ==


echo -en " loading modules: "

# Need to verify that all modules have all required dependencies
#
echo " - Verifying that all kernel modules are ok"
/sbin/depmod -a

# With the new IPTABLES code, the core MASQ functionality is now either
# modular or compiled into the kernel. This HOWTO shows ALL IPTABLES
# options as MODULES. If your kernel is compiled correctly, there is
# NO need to load the kernel modules manually.
#
# NOTE: The following items are listed ONLY for informational reasons.
# There is no reason to manual load these modules unless your
# kernel is either mis-configured or you intentionally disabled
# the kernel module autoloader.
#

# Upon the commands of starting up IP Masq on the server, the
# following kernel modules will be automatically loaded:
#
# NOTE: Only load the IP MASQ modules you need. All current IP MASQ
# modules are shown below but are commented out from loading.
# ===============================================================

#Load the main body of the IPTABLES module - "iptable"
# - Loaded automatically when the "iptables" command is invoked
#
# - Loaded manually to clean up kernel auto-loading timing issues
#
echo -en "ip_tables, "
/sbin/insmod ip_tables


#Load the IPTABLES filtering module - "iptable_filter"
# - Loaded automatically when filter policies are activated


#Load the stateful connection tracking framework - "ip_conntrack"
#
# The conntrack module in itself does nothing without other specific
# conntrack modules being loaded afterwards such as the "ip_conntrack_ftp"
# module
#
# - This module is loaded automatically when MASQ functionality is
# enabled
#
# - Loaded manually to clean up kernel auto-loading timing issues
#
echo -en "ip_conntrack, "
/sbin/insmod ip_conntrack


#Load the FTP tracking mechanism for full FTP tracking
#
# Enabled by default -- insert a "#" on the next line to deactivate
#
echo -en "ip_conntrack_ftp, "
/sbin/insmod ip_conntrack_ftp


#Load the IRC tracking mechanism for full IRC tracking
#
# Enabled by default -- insert a "#" on the next line to deactivate
#
echo -en "ip_conntrack_irc, "
/sbin/insmod ip_conntrack_irc


#Load the general IPTABLES NAT code - "iptable_nat"
# - Loaded automatically when MASQ functionality is turned on
#
# - Loaded manually to clean up kernel auto-loading timing issues
#
echo -en "iptable_nat, "
/sbin/insmod iptable_nat


#Loads the FTP NAT functionality into the core IPTABLES code
# Required to support non-PASV FTP.
#
# Enabled by default -- insert a "#" on the next line to deactivate
#
echo -en "ip_nat_ftp, "
/sbin/insmod ip_nat_ftp


# Just to be complete, here is a list of the remaining kernel modules
# and their function. Please note that several modules should be only
# loaded by the correct master kernel module for proper operation.
# --------------------------------------------------------------------
#
# ipt_mark - this target marks a given packet for future action.
# This automatically loads the ipt_MARK module
#
# ipt_tcpmss - this target allows to manipulate the TCP MSS
# option for braindead remote firewalls.
# This automatically loads the ipt_TCPMSS module
#
# ipt_limit - this target allows for packets to be limited to
# to many hits per sec/min/hr
#
# ipt_multiport - this match allows for targets within a range
# of port numbers vs. listing each port individually
#
# ipt_state - this match allows to catch packets with various
# IP and TCP flags set/unset
#
# ipt_unclean - this match allows to catch packets that have invalid
# IP/TCP flags set
#
# iptable_filter - this module allows for packets to be DROPped,
# REJECTed, or LOGged. This module automatically
# loads the following modules:
#
# ipt_LOG - this target allows for packets to be
# logged
#
# ipt_REJECT - this target DROPs the packet and returns
# a configurable ICMP packet back to the
# sender.
#
# iptable_mangle - this target allows for packets to be manipulated
# for things like the TCPMSS option, etc.

echo ". Done loading modules."



#CRITICAL: Enable IP forwarding since it is disabled by default since
#
# Redhat Users: you may try changing the options in
# /etc/sysconfig/network from:
#
# FORWARD_IPV4=false
# to
# FORWARD_IPV4=true
#
echo " enabling forwarding.."
echo "1" > /proc/sys/net/ipv4/ip_forward


# Dynamic IP users:
#
# If you get your IP address dynamically from SLIP, PPP, or DHCP,
# enable this following option. This enables dynamic-address hacking
# which makes the life with Diald and similar programs much easier.
#
echo " enabling DynamicAddr.."
echo "1" > /proc/sys/net/ipv4/ip_dynaddr


# Enable simple IP forwarding and Masquerading
#
# NOTE: In IPTABLES speak, IP Masquerading is a form of SourceNAT or SNAT.
#
# NOTE #2: The following is an example for an internal LAN address in the
# 192.168.0.x network with a 255.255.255.0 or a "24" bit subnet mask
# connecting to the Internet on external interface "eth0". This
# example will MASQ internal traffic out to the Internet but not
# allow non-initiated traffic into your internal network.
#
#
# ** Please change the above network numbers, subnet mask, and your
# *** Internet connection interface name to match your setup
#


#Clearing any previous configuration
#
# Unless specified, the defaults for INPUT and OUTPUT is ACCEPT
# The default for FORWARD is DROP
#
echo " clearing any existing rules and setting default policy.."
$IPTABLES -P INPUT ACCEPT
$IPTABLES -F INPUT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -F OUTPUT
$IPTABLES -P FORWARD DROP
$IPTABLES -F FORWARD
$IPTABLES -t nat -F

echo " FWD: Allow all connections OUT and only existing and related ones IN"
$IPTABLES -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
$IPTABLES -A FORWARD -j LOG

echo " Enabling SNAT (MASQUERADE) functionality on $EXTIF"
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

echo -e "\nrc.firewall-2.4 v$FWVER done.\n"


any help would sooooo very appreciated,

thank you,
 
Old 11-06-2004, 09:31 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,691

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Unable to ping is a problem. So what is the hardware configuration? How is the windows PC connected to the Slack box?

IMHO the default policy should be drop instead of accept for everything.
 
Old 11-06-2004, 10:21 AM   #3
scottman
Member
 
Registered: Jul 2004
Location: USA
Distribution: Slackware, FreeBSD, LFS
Posts: 72

Rep: Reputation: 15
Try to ping your xp machine while specifying the interface in the ping command.

#ping -I eth1 192.168.0.4

One thing I've found I have to do to get forwarding and masquerading working is
use the route command to connect the internet to the internal network. You can
check your current routing table with the "route" command. If your internet works
from your slackware gateway box, then you should have an entry for your eth0 with
your ISP gateway. You may need one for your eth1 in order for your internal computer
to connect to your ISP gateway. Try the following:

#route add default gateway 192.168.0.3 eth1

You said that your upgrading, so I am guessing that your cables and network cards
have all been tested, and that the problem started with the upgrade. Let us know
if the interface ping command works, or the route add gives your xp machine internet
access. Also double check any firewall on the xp machine.
 
Old 11-06-2004, 11:11 AM   #4
atari303
Member
 
Registered: May 2001
Posts: 34

Original Poster
Rep: Reputation: 15
Thank you for your replies.

ping -I eth1 192.168.0.4 shows destination host unreachable, and also after route add default gateway 192.168.0.3 eth1.

eth1 connection from Slackware box is going to line 1 of a 4 port hub and line 2 from hub goes to the windows machine. I've tested both cables so maybe my hub died? Although the lights do show. I guess I'm confused, the only 2 things that I can think that I did differently during this install was say yes to run this computer as a gateway and i didn't have to setup iptables nor my 2nd NIC like I have done in the past. Is my rc.firewall not correct for kernel 2.4.26? I don't know.

Thanks for helping.
 
Old 11-06-2004, 11:22 AM   #5
atari303
Member
 
Registered: May 2001
Posts: 34

Original Poster
Rep: Reputation: 15
One thing that I just noticed at startup and I don't know if this helps but I showed:

Done loading modules. .
enabling dorwarding. .
enabling DymamicAddr. .
clearing any existing rules and setting default policy. .
FWD: Allos all connections OUT and only existing and related ones IN
Enabling SNAT (MASQUERADE) functionality on eth0

is that last line right? should masquerading be on eth0 and not eth1? I will check that out but thought that I would mention it here quick.
 
Old 11-06-2004, 12:32 PM   #6
scottman
Member
 
Registered: Jul 2004
Location: USA
Distribution: Slackware, FreeBSD, LFS
Posts: 72

Rep: Reputation: 15
Your firewall and masquerading rule look fine to me, as long as you have everything
you need in the kernel, or as modules, which you mentioned earlier. You shouldn't be
dropping anything through iptables either, in fact, as michaelk mentioned, your firewall
is very loose.

One thing we can do is make sure your Slackware box sees your eth1 at the correct
address. You can ping that address, and by specifying eth1 it ensures you don't get
a reply through your loopback.

#ping -I eth1 192.168.0.3

If that doesnt work try it without the interface argument.

#ping 192.168.0.3

If both worked, then you'll want to take a closer look at the windows set up, and make sure
your using the right type of cables to connect to the hub. They should be regular cables,
if you have a cross-over cable in there it would cause problems.

Also, if you could post the output of the "route" command, that may help me or someone else
see something. If theres a line that identifies your eth0 internet address remember to replace it
with x.x.x.x or something.
 
Old 11-06-2004, 12:56 PM   #7
atari303
Member
 
Registered: May 2001
Posts: 34

Original Poster
Rep: Reputation: 15
oops, I'm sorry, there was no output from the route command (route add default gateway 192.168.0.3 eth1), I was brought back to the prompt.

pinging eth1 from Slackware works succesfully issueing with and without -I. I just cannot ping 192.168.0.4 from Slackware however. I only have straight-through cables but I will try replacing the cables althogether like you suggest and looking at the Windows machine a little more closely. I can connect the Windows machine directly to my router and it does pull pages but maybe there's something I'm missing. There is no firewall on the windows machine and the windows firewall was disabled, maybe I will pick up another hub, I wanted to anyway, but I will keep messing around with this one for a little while.

It's good to know that at least I'm on the right track. btw, do you know where I could grab a more secure rc.firewall script or do you think that changing accept to drop should be fine for this one?

Thank-you for all your help and great suggestions.
 
Old 11-06-2004, 01:40 PM   #8
scottman
Member
 
Registered: Jul 2004
Location: USA
Distribution: Slackware, FreeBSD, LFS
Posts: 72

Rep: Reputation: 15
Well, before you go out and buy new hardware, you could try pinging
the local address on all the networked computers. You could also set
up a dhcp server using the slackware package dhcpd. You may already
have it installed. If you had that set up, you could pump out network info
to all computers you connect automatically. Here's a mini-howto on that.
You basically just need an /etc/dhcpd.conf and to run the program at reboot,
maybe from /etc/rc.d/rc.local.

http://www.tldp.org/HOWTO/DHCP/index.html

As far as the security questions, that firewall would allow the slackware
cpu unrestricted in and out internet access. It would apply connection
tracking only to the other cpus on the network. Heres a link to a
thread that list a lot of links for security and firewall questions.

http://www.linuxquestions.org/questi...threadid=45261
 
Old 11-07-2004, 02:17 AM   #9
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
Try a different port on the Hub for your Windows machine -- this drove me buggy for a long while; lights were working but there was no real connectivity to a specific port.
 
  


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
(FreeBSD && Fedora Core 4 && Slackware 10.0) Filesystem Support taylor_venable *BSD 1 07-14-2005 02:24 PM
Samba & IPTABLES & Network Drives Oh My! logicdisaster Linux - Networking 3 06-03-2004 06:07 PM
slackware problem with aterm && mouse wheel infamous41md Linux - Newbie 3 01-01-2004 08:04 PM
Slackware & iptables question jim64 Linux - Networking 0 10-05-2003 10:54 AM
%&*#&$$ iptables modules Hangdog42 Linux - Newbie 10 03-03-2003 08:16 PM

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

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