LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-20-2010, 02:56 PM   #1
brgsousa
Member
 
Registered: Aug 2007
Location: Salvador, Brazil
Distribution: Debian, Ubuntu
Posts: 185

Rep: Reputation: 15
how to add iptables NAT exception


Hi everyone,
I'm having some trouble with NAT in my gateway.

For the 10.13.0.0/16 network, I do not want to apply NAT through the gateway. However, the way it is configured, it is applying SOURCE NAT to traffic coming from 10.13.0.0/16 and changing source ip address to 8.8.8.1
For example, pinging from 10.13.0.11 to 10.101.14.1 (passing through the gateway, which is also a router in this case), then SNAT is applied and the ip packet gets changed to :
--------------------------------
| source address : 8.8.8.1_____|
--------------------------------
| dest. address_ : 10.101.14.1 |
--------------------------------

NAT's configuration in gateway/router:

Code:
iptables -t nat -A POSTROUTING -d 8.8.8.0/24 -o $EXTERNAL -j RETURN
iptables -t nat -A POSTROUTING -d 10.0.0.0/8 -o $EXTERNAL -j RETURN
iptables -t nat -A POSTROUTING -o $EXTERNAL -j LOG

iptables -t nat -A POSTROUTING -s 10.11.0.0/16 -d ! 8.8.8.0/24 -j SNAT --to-source 8.8.8.41
iptables -t nat -A POSTROUTING -s 10.12.0.0/16 -d ! 8.8.8.0/24 -j SNAT --to-source 8.8.8.42

iptables -t nat -A POSTROUTING -d ! 8.8.8.0/24 -j SNAT --to-source 8.8.8.1
So, I don't want to apply SNAT to traffic comming from 10.13.0.0/16.
How can I add this SNAT exception?
 
Old 05-20-2010, 11:17 PM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
I think you just need to put this rule above all the other nat POSTROUTING rules:
Code:
iptables -t nat -A POSTROUTING -s 10.13.0.0/16 -j ACCEPT
 
1 members found this post helpful.
Old 05-26-2010, 11:57 AM   #3
brgsousa
Member
 
Registered: Aug 2007
Location: Salvador, Brazil
Distribution: Debian, Ubuntu
Posts: 185

Original Poster
Rep: Reputation: 15
worked
 
  


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
Is there any way to add an exception for a port in the firewall setting, permanently? senrooy Linux - Kernel 6 03-03-2010 12:28 AM
iptables: can't initialize iptables table `NAT' linuxgentoo Linux - Kernel 3 01-17-2010 10:15 AM
add/remove software exception occurred FC6 imakickthebox Linux - Newbie 8 09-23-2007 05:47 PM
exception occurred when opening add/remove software on fedora 5 amee_stars Fedora 2 01-13-2007 05:08 AM
IPtables Redirection Exception? BoarderX Linux - Networking 7 09-22-2004 06:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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