LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 04-30-2014, 07:35 PM   #1
schandran
LQ Newbie
 
Registered: Apr 2014
Posts: 7

Rep: Reputation: Disabled
iptables


Hello everyone i'm new to the linux world.

I was asked the following question:

/sbin/iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to-destination 8.8.8.8
a. What will this command do on execution?
b. If I run this command on a machine receiving DNS requests, what will

Any help would be appreciated.
 
Old 04-30-2014, 08:03 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,404

Rep: Reputation: Disabled
a. It will add a new rule to the bottom of the PREROUTING chain of the nat table.

b. I'm afraid I can't answer that, as half the question is missing.

If you're going to cut and paste from an assignment (you weren't actually "asked the following question", were you), make sure you include all the text.

By the way, what do you think the command will do?
 
Old 04-30-2014, 08:35 PM   #3
schandran
LQ Newbie
 
Registered: Apr 2014
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks Ser Olmy. I came across it on a Interview Take home. I'm not too good with the networking stuff yet.

If I had to guess (using the iptables man pages)
I'd think its creating a rule to that says all packets with a destination of udp port53 be sent to destination 8.8.8.8

The two lines above question a) was the whole command. like I said total newb :-)
 
Old 04-30-2014, 09:08 PM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,404

Rep: Reputation: Disabled
Quote:
Originally Posted by schandran View Post
If I had to guess (using the iptables man pages)
I'd think its creating a rule to that says all packets with a destination of udp port53 be sent to destination 8.8.8.8
You're absolutely right.

The nat table (accessed using the "-t nat" parameter to iptables) contains chains with rules that modify the source or destination IP addresses of packets, and/or port numbers if the TCP or UDP protocol is used.

This particular rule is added to the PREROUTING chain, which contain rules for changing the destination addresses (and/or port numbers) of packets. It says "any UDP packets sent to destination port 53 [which is the port used by the DNS service] should be handled by the DNAT target".

The parameters to the DNAT target tells it to alter the destination address to 8.8.8.8 (and leave the port number as-is). This will cause all DNS queries to be redirected to 8.8.8.8, which is the IP address of one of Google's publicly available DNS servers.
 
Old 04-30-2014, 10:06 PM   #5
schandran
LQ Newbie
 
Registered: Apr 2014
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thank you!
 
  


Reply


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
iptables can't initialize iptables table `filter': Bad file descriptor donalbane Linux - Networking 2 08-17-2011 09:36 AM
iptables error in android: iptables-save and iptables-restore not working preetb123 Linux - Mobile 5 04-11-2011 02:56 PM
On what basis CHAIN integer values are generated in IPtables under iptables file? haariseshu Linux - Server 3 11-05-2009 05:25 AM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 09:20 PM
Iptables - Couldn't load target `ACCPET':/lib/iptables/libipt_ACCPET.so: z00t Linux - Security 3 01-26-2004 03:24 AM


All times are GMT -5. The time now is 06:31 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration