LinuxQuestions.org
Help answer threads with 0 replies.
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 02-23-2010, 05:49 AM   #1
tiuz
Member
 
Registered: Mar 2006
Distribution: Slackware 14
Posts: 92

Rep: Reputation: 15
Routing via Iptables wonīt work


Hello,

I have setup a linuxbox running a dhcp and dns server for the internal LAN to work as Router/Gateway for the LAN.

The box has two network interfaces (eth0 - connected to the LAN - and eth1 directly connected to the ADSL Modem) the internet connection is initiated with pptp and when the connection is established itīs reachable via ppp0.

I have then setup this iptables rules, but for some reason forwarding to the internal LAN wonīt work, i get the correct IPīs and so on, but nothing comes back from the router and i have no idea why.

# EXTERNAL=eth1 directly connected to ADSL-Modem
# INTERNAL=eth0
# Internet=ppp0 after initiating the connection with pptp
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A OUTPUT -o lo -p all -j ACCEPT
iptables -A INPUT -i eth0 -p all -j ACCEPT
iptables -A OUTPUT -o eth0 -p all -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
iptables -A OUTPUT -p icmp -j ACCEPT
iptables -A INPUT -p all -s localhost -i ppp0 -j DROP
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -A FORWARD -i eth0 -j ACCEPT

So everything from the internet should be blocked expect the connections initiated by one of the boxes on the LAN and of course the router, and everything from the internal net to the router should be accepted.

Thanks for any hints / help.

tiuz
 
Old 02-23-2010, 06:08 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
iptables -A INPUT -p all -s localhost -i ppp0 -j DROP

What are you trying to do with that line ?
It looks like any input that comes from localhost via the interface ppp0 is dropped.
How can that be ? How can a packet be sourced from localhost but come in through ppp0 ? Surely in the best case that drops all packets coming in from the world.

http://www.yolinux.com/TUTORIALS/Lin...rkGateway.html

http://www.netfilter.org/documentati...T-HOWTO-8.html

http://www.netfilter.org/documentati...O-4.html#ss4.1

Last edited by smoker; 02-23-2010 at 06:23 AM.
 
Old 02-23-2010, 08:21 AM   #3
tiuz
Member
 
Registered: Mar 2006
Distribution: Slackware 14
Posts: 92

Original Poster
Rep: Reputation: 15
> iptables -A INPUT -p all -s localhost -i ppp0 -j DROP

Takes from

http://www.yolinux.com/TUTORIALS/Lin...rkGateway.html

Section:

Adding more security rules to your gateway:

I canīt remember everything on that since itīs been ages since i last setup a FW via iptables but i guess itīs something to do with "spoofing"

> What are you trying to do with that line ?
> It looks like any input that comes from localhost via the interface ppp0 > is dropped.
> How can that be ? How can a packet be sourced from localhost but come in > through ppp0 ? Surely in the best case that drops all packets coming in > from the world.
>
> http://www.yolinux.com/TUTORIALS/Lin...rkGateway.html
>
> http://www.netfilter.org/documentati...T-HOWTO-8.html
>
> http://www.netfilter.org/documentati...O-4.html#ss4.1

Thanks !!
 
Old 02-23-2010, 09:15 AM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Ok, I see now.

How about your last line :

iptables -A FORWARD -i eth0 -j ACCEPT

shouldn't there be a -o option too ?

iptables -A FORWARD -o eth0 -j ACCEPT

and perhaps put both those lines before the :

iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

?

http://www.redhat.com/docs/manuals/e...l-ipt-fwd.html
and the page that follows it.

regards

Alan
 
Old 02-23-2010, 02:21 PM   #5
tiuz
Member
 
Registered: Mar 2006
Distribution: Slackware 14
Posts: 92

Original Poster
Rep: Reputation: 15
Ahh YES ! That was the trick :-)

Thanks very much !!

Perhaps i should save the configfile this time :-)
 
Old 02-23-2010, 05:27 PM   #6
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
No worries,

please understand I am learning just as much as you are here.
I am no guru, but I like a nice problem.
Luckily I have the time to find these things out at the moment.

I'm as pleased as you are.

Glad I could help.

regards

Alan

ps. did you put those lines before the masquerade line in the end ?

Last edited by smoker; 02-23-2010 at 05:35 PM.
 
  


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
kubuntu. my modem won,t work! pressea Linux - Networking 1 08-14-2006 03:06 AM
IP Forwarding wonīt work tiuz Slackware 5 04-27-2006 08:20 PM
BootP won;t work but DHCP will rhaley Linux - Networking 1 06-10-2005 11:37 AM
Boot screen won,t work help!!!!!! drysac Mandriva 4 11-02-2004 12:07 PM
Why won’t this Java Script Work? dholingw Programming 4 02-25-2004 03:41 PM

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

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