Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
iptables woes
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
turumbar
n00b
n00b


Joined: 09 Apr 2004
Posts: 20
Location: gdl.mx

PostPosted: Sun Apr 11, 2004 6:26 pm    Post subject: iptables woes Reply with quote

I've been trying to setup iptables to share an internet connection.
I can get the latop and the server to ping to each other, samba is working, and dhcp server on the home lan is working.

I have followed the steps here:
https://forums.gentoo.org/viewtopic.php?t=159133&highlight=kernel+options+iptables
and no luck so far.

This is what I'm doing:
Wre eth0 is the connection to the cable modem, and eth1 is the connection to the local net.
Code:

#iptables -F
#iptables -X
#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#iptables -A FORWARD -i eth1 -o eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT                                                                             
 


And I get this:
Code:

# iptables -L -v
Chain INPUT (policy ACCEPT 175 packets, 142K bytes)
 pkts bytes target     prot opt in     out     source               destination
 
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  eth1   eth0    anywhere             anywhere            state NEW,RELATED,ESTABLISHED
 
Chain OUTPUT (policy ACCEPT 222 packets, 18014 bytes)
 pkts bytes target     prot opt in     out     source               destination


It seems that I'm doing everything I need to, but no luck.
I have also tried running utilities like firestarter, with the same result.
Back to top
View user's profile Send private message
manywele
l33t
l33t


Joined: 12 Jul 2003
Posts: 743
Location: Inside

PostPosted: Sun Apr 11, 2004 7:01 pm    Post subject: Reply with quote

If you're using a 2.6.x kernel then you need to turn on forwarding by typing
Code:
echo "1" > /proc/sys/net/ipv4/ip_forward
Back to top
View user's profile Send private message
turumbar
n00b
n00b


Joined: 09 Apr 2004
Posts: 20
Location: gdl.mx

PostPosted: Sun Apr 11, 2004 8:00 pm    Post subject: Reply with quote

it is on.
Sorry I forgot to mention it.
Back to top
View user's profile Send private message
Nossie
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 181

PostPosted: Sun Apr 11, 2004 11:04 pm    Post subject: Reply with quote

Maybe you can try the monmotha firewall script (it's in portage). I don't know if it will solve anything though.
Back to top
View user's profile Send private message
Floog
Tux's lil' helper
Tux's lil' helper


Joined: 29 Nov 2002
Posts: 116

PostPosted: Mon Apr 12, 2004 1:25 am    Post subject: Re: iptables woes Reply with quote

Turumbar, are you certain that iptables is running the firewall rules upon startup? Reboot your machine and see if the iptables service starts successfully upon boot. I forget the message you see upon initialization and I can't reboot right now to check it out cuz i'm compiling OpenOffice from source.

Make sure you are giving enough statements to tell linux where to locate, start, and run iptables. Here's some of my /etc/conf.d/iptables:

IPTABLES=/sbin/iptables
DEPMOD=/sbin/depmod
MODPROBE=/sbin/modprobe

$DEPMOD -a
$MODPROBE ip_tables
$MODPROBE ip_conntrack
$MODPROBE ip_conntrack_ftp
$MODPROBE ip_conntrack_irc
$MODPROBE iptable_nat
$MODPROBE ip_nat_ftp

#echo " Enabling forwarding.."
echo "1" > /proc/sys/net/ipv4/ip_forward

#echo " Enabling DynamicAddr.."
#echo "1" > /proc/sys/net/ipv4/ip_dynaddr

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 eth0 -o eth1 -j ACCEPT
$IPTABLES -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i eth1 -o eth0 -j ACCEPT

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


Floog
Back to top
View user's profile Send private message
turumbar
n00b
n00b


Joined: 09 Apr 2004
Posts: 20
Location: gdl.mx

PostPosted: Tue Apr 13, 2004 3:01 am    Post subject: Reply with quote

yes, I'm certain iptables is getting enought info to start.

in fact, most of the time I don't even reboot, I just try to configure it on the comand line... no luck so far.
Back to top
View user's profile Send private message
Floog
Tux's lil' helper
Tux's lil' helper


Joined: 29 Nov 2002
Posts: 116

PostPosted: Tue Apr 13, 2004 4:26 am    Post subject: Re: iptables woes Reply with quote

I believe you've got ..... -i eth1 -o eth0 -m state --state ESTABLISHED ....... backwards.

Try my iptables lines. My setup uses eth0 as the connection to the cable modem and eth1 connecting to the LAN just as you want to do. Try this:

$IPTABLES -A FORWARD -i eth0 -o eth1 -j ACCEPT
$IPTABLES -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i eth1 -o eth0 -j ACCEPT

Restart iptables with these rules in place. It can't hurt. Your MASQUERADE line looks fine to me.

HTH,
Floog

turumbar wrote:
eth0 is the connection to the cable modem, and eth1 is the connection to the local net.
Code:

#iptables -F
#iptables -X
#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#iptables -A FORWARD -i eth1 -o eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT                                                                             
 


Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum