Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 07-24-2006, 06:14 AM   #1
Registered: Sep 2005
Distribution: FreeBSD
Posts: 84

Rep: Reputation: 15
how to NAT ip to LAN


I have 5 ip static addresses (for ex. - 5)
One of them uses my router box on eth0. (
I have LAN on eth1 (

BUT one of the users of the LAN needs to use this secon free static ip on his pc in the LAN.

So how can I route/forward this IP? Is there any NAT or something rule ?

(I there is some need to know I`m using iptables + HLS (home lan security firewall)
Please help!!!

Old 07-24-2006, 10:56 AM   #2
LQ Newbie
Registered: Jul 2006
Distribution: Ubuntu
Posts: 22

Rep: Reputation: 15
Smile iptables - why yes

Hello Sushy,

Assuming those ip addresses never change (static) then you will probably want to enable IP_Forwarding and make a simple SNAT (secure nat) rule in iptables.

Something along these lines should do it:
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p
iptables -A FORWARD -i eth0 -o eth1 -s -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -s -j SNAT --to-source
Obviously you may need to change the ip's if those aren't what you're actually using, and be sure to use iptables-save to keep those settings upon reboot :-)
Old 07-24-2006, 04:42 PM   #3
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 379Reputation: 379Reputation: 379Reputation: 379
Originally Posted by NSWKim
iptables -A FORWARD -i eth0 -o eth1 -s -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -s -j SNAT --to-source
i'd make a small tweak to this suggestion, as it would not work with the FORWARD chain's policy set to DROP (as it should be)... also, there's a typo with the -i and -o interfaces (they should be inverted)... here's my tweaked suggestion:
iptables -P FORWARD DROP

iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A FORWARD -i eth1 -o eth0 -s \
-m state --state NEW -j ACCEPT

iptables -t nat -A POSTROUTING -o eth0 -s \
-j SNAT --to-source
just my ...


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
What FireWall & NAT for home LAN? fipeso Linux - Newbie 6 04-19-2005 02:41 PM
WiFi LAN and NAT - seeking for advice dom_lochet Linux - Wireless Networking 3 01-26-2005 05:55 AM
NAT for lan 192.168.2.x urukhay Linux - Networking 1 11-09-2004 04:49 AM
RH 9 : Enable My LAN to Access TFTP Server Using NAT mr13stu Linux - Networking 0 02-19-2004 03:14 PM
What's the difference between Linux-NAT and Sygate-NAT? yuzuohong Linux - Networking 0 08-07-2002 04:07 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:26 PM.

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