Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-18-2006, 02:03 AM   #1
LQ Newbie
Registered: Oct 2006
Posts: 6

Rep: Reputation: 0
forwarding packets with iptable and nat

I am trying to write a firewall script to allow packets to be forwarded from one network card eth0 to eth1 - the gateway. Since I do not have routing service set up on the machine, can I use NAT to have iptables route the packets across?

example copied from the www:
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT
iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT

Thanks for replying.

Old 10-18-2006, 02:13 AM   #2
Registered: Mar 2006
Distribution: RedHat, Slackware, Experimenting with FreeBSD
Posts: 222

Rep: Reputation: 30
You need to enable IP forwarding on your system:

echo 1 > /proc/sys/net/ipv4/ip_forward

This is temporary and will be wiped once you reboot. Depending on your distribution, you can save the change permanently in /etc/sysctl.conf or /etc/rc.d/rc.local.
For Slackware just add the execute permission to /etc/rc.d/rc.ip_forward
Old 10-20-2006, 03:07 AM   #3
LQ Newbie
Registered: Oct 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks Slackdeamon:
I will give your suggestion a try


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
port forwarding using IPTABLE ...( Help) ad2005 Linux - Networking 5 03-15-2006 10:56 PM
Not forwarding packets meadensi Linux - Networking 0 02-08-2005 07:02 PM
how to nat playstation2 packets ( iptables ) nanoprobe Linux - Networking 1 01-23-2005 12:40 PM
IPTable Problems (Port Forwarding)... Arch3Angel Linux - Security 3 12-04-2004 04:56 PM
Iptable NAT issues and DCC Kristijan Linux - Security 9 01-08-2004 07:12 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:39 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration