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 03-20-2004, 03:00 PM   #1
arrruken
Member
 
Registered: Apr 2003
Distribution: gentoo
Posts: 238

Rep: Reputation: 32
Me & Iptables dont work--Solved


Trying to set up a router, I like to do one thing at a time though, so here's my question: Forgetting about security, and NAT for right now, All I want to do is have my PC's on the internal side of the router be able to ping the modem.
The setup is:
DSL-Modem(192.168.1.254)---->(192.168.1.1)eth0/Gentoo\eth1(192.168.0.1)---->switch--->PC's(192.168.0.x)
Im sure my kernel looks good, I know that /proc/sys/net/ipv4/ip_forward is set to "1", and is so everytime I boot, I know the iptables config file in /etc/conf.d/iptables has ip forwarding enabled.
With all that said, these basic rules should allow me to ping the router correct?
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

I dont see why I would need anything else to just ping the router. Please tell me if Im missing something or you see something wrong. RIght now its timing out every time.

Last edited by arrruken; 03-20-2004 at 04:16 PM.
 
Old 03-20-2004, 03:15 PM   #2
atlesn
Member
 
Registered: Oct 2003
Location: Oslo, Norway
Distribution: RedHat 9.0, Fedora Core 1/2/3, Debian 3.0, Smoothwall
Posts: 110

Rep: Reputation: 15
echo 1 > /proc/sys/net/ipv4/ip_forward

To enable forwarding
 
Old 03-20-2004, 03:31 PM   #3
arrruken
Member
 
Registered: Apr 2003
Distribution: gentoo
Posts: 238

Original Poster
Rep: Reputation: 32
Re: Me & Iptables dont work

Quote:
Originally posted by arrruken

Im sure my kernel looks good, I know that /proc/sys/net/ipv4/ip_forward is set to "1", and is so everytime I boot, I know the iptables config file in /etc/conf.d/iptables has ip forwarding enabled.
I know, is there anything else that would cause this not to work?
 
Old 03-20-2004, 03:43 PM   #4
atlesn
Member
 
Registered: Oct 2003
Location: Oslo, Norway
Distribution: RedHat 9.0, Fedora Core 1/2/3, Debian 3.0, Smoothwall
Posts: 110

Rep: Reputation: 15
Wink

Sorry for skipping that part, must have read your post too fast.

Try

iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT

if your LAN iface is eth0. This at least works for me.
 
Old 03-20-2004, 04:01 PM   #5
arrruken
Member
 
Registered: Apr 2003
Distribution: gentoo
Posts: 238

Original Poster
Rep: Reputation: 32
Well that worked for some reason, I didnt think I would need NAT to just ping, but I guess I did. I really appreciate the help.
Now that that is working, am I gonna need this line:
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
Or better question, would I have any problems with any services on the PC's right now?

Last edited by arrruken; 03-20-2004 at 04:06 PM.
 
Old 03-20-2004, 04:08 PM   #6
atlesn
Member
 
Registered: Oct 2003
Location: Oslo, Norway
Distribution: RedHat 9.0, Fedora Core 1/2/3, Debian 3.0, Smoothwall
Posts: 110

Rep: Reputation: 15
Nat is needed when the two ifaces are not on the same subnet.

Just nice to help.
 
Old 03-20-2004, 04:28 PM   #7
atlesn
Member
 
Registered: Oct 2003
Location: Oslo, Norway
Distribution: RedHat 9.0, Fedora Core 1/2/3, Debian 3.0, Smoothwall
Posts: 110

Rep: Reputation: 15
Not on your gentoo, but here is how to open ports to other comps behind it:

(one line)
iptables -A FORWARD -i eth1 -p tcp --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

iptables -t nat -A PREROUTING -j DNAT -p tcp --dport 80 --to-destination 192.168.0.x

This redirects to a webserver with the tcp protocol
 
  


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
Why dont my soundcard work? traX1 Linux - Hardware 2 07-28-2005 07:38 AM
Japanese canna won't work : Warning: かな漢字変&am OrganicOrange84 Debian 3 06-30-2005 02:28 PM
fluxbox & fbdesk = dont work well? kurrupt Linux - Software 1 06-02-2005 02:05 AM
gdesklets dont work freeka Linux - Software 2 02-28-2005 10:59 AM
Things dont work when you dont understand withoutaclue Linux - Newbie 3 03-12-2003 09:51 AM

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

All times are GMT -5. The time now is 06:52 PM.

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