LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-14-2015, 01:15 AM   #1
shoya
LQ Newbie
 
Registered: Jan 2015
Location: Japan
Posts: 3

Rep: Reputation: Disabled
Help me understand how natd works in Linux


Hello all.
I wanna know how nat system works in Linux.

In FreeBSD, it works by using IPFIREWALL, a firewall system which has a function to redirect specific packets to a process,
and DIVERT SOCKET, which is a special socket on FreeBSD and used when FIREWALL diverts packets to a process.
Using these two function enables us to divert specific packets
which should be transmitted immidiately to a process, and we also can
resend the packets from the process after changing their data, by writing them back to the DIVERT SOCKET.

Let me give an example.
---Example------------------------------------
#ipfw flush
#ipfw add 100 divert 8888 tcp from any to any
#ipfw add 65534 allow ip from any to any
----------------------------------------------

After we apply these rules, every tcp packets will be redirected to
the process which opens 8888 port of DIVERT SOCKET.
Since packets sent from this process start rule matching after No.100 rules, they will be matched No.65534 rule.
Now we know we can change the data of packets and resend them.
And nat system in FreeBSD works using this function.
Sorry if you already knew things I mentioned above.

Although I already know some bacis usages of ipfirewall and nat system in Linux,
I dont undetstand the inside of the system.
So if you have any tips, I'd really appriciate if you would tell me.
Thanks in advance for any tips.

Last edited by shoya; 01-14-2015 at 01:24 AM.
 
Old 01-14-2015, 09:13 PM   #2
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Hi: & Welcome to Linux Questions!-

I'm not your go to Guru for Network Address translation but these links are a start.

http://www.slashroot.in/linux-nat-ne...uter-explained
http://www.revsys.com/writings/quicktips/nat.html

This article is 8 pages long so it might have more information to give you the knowledge that your seeking.
http://computer.howstuffworks.com/nat.htm

Hope that helps.
 
Old 01-15-2015, 02:00 AM   #3
shoya
LQ Newbie
 
Registered: Jan 2015
Location: Japan
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you for yuor information !
Unfortunately, I couldn't find what I've been seeking from your links.
But thanks anyway !

The thing I wanna know is :
Can we implement a program which can catch and resend packets like the natd in FreeBSD I mentioned above ?

According to the links you gave me, nat system in Linux seems to do that via iptables.
So can we implement a program and run it like nat system?
Or nat system is a kinda special process and we can't do that?

Do you have any idea about this?

Last edited by shoya; 01-15-2015 at 02:03 AM.
 
Old 01-15-2015, 03:00 PM   #4
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by shoya View Post
Thank you for yuor information !
Unfortunately, I couldn't find what I've been seeking from your links.
But thanks anyway !

The thing I wanna know is :
Can we implement a program which can catch and resend packets like the natd in FreeBSD I mentioned above ?

According to the links you gave me, nat system in Linux seems to do that via iptables.
So can we implement a program and run it like nat system?
Or nat system is a kinda special process and we can't do that?

Do you have any idea about this?
Your Welcome:-

I suppose that it would be possible to implement a program and run it like the nat system.
My thinking on this (think, notice I said THINK) in order for something to be resent it would have to be directed by a process or perhaps a script.

There are all kinds of scripts out there. One I most recently learned of is a 'redirect script'

The thing with that is (if I had to guess) is a developer that has the mind and the skills to develop such processes and initializations in an application could tell you how to make that happen. Aside from that a computer engineer would be the one to go to on this. A web master might know too. Sorry I don't know more. I'm studying myself.-

Maybe by studying some of the practices, protocols and techniques that developers and computer engineers use everyday will give you knowledge and insight.

I have found that sometimes the very answer that I'm looking for is in the mix right in front of me.
In other words the answer may already be there in your reach but it's that you need to change the perspective of how you look at it. Perception and perspective can be a friend.
There is always more than one way of looking at something.

Aside from that; shoya, I'm out of ideas.

Good luck!
 
Old 01-20-2015, 12:27 AM   #5
shoya
LQ Newbie
 
Registered: Jan 2015
Location: Japan
Posts: 3

Original Poster
Rep: Reputation: Disabled
Although I've not found what I wanna know,
thank you for your advice.
I really appreciate your words. )
 
Old 01-20-2015, 03:55 PM   #6
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by shoya View Post
Although I've not found what I wanna know,
thank you for your advice.
I really appreciate your words. )
Well...Thank You shova; your very Welcome!

Good luck-
 
  


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
can someone help me understand this command and how it works please. rookee Linux - Newbie 1 10-30-2014 10:42 PM
Trying to understand how slackpkg update works Zwergele Slackware 2 10-15-2014 03:08 PM
Trying to understand how Ethernet works resetreset Linux - Networking 7 08-10-2012 01:33 PM
Do you understand how autotools works? hydraMax Programming 16 03-20-2012 05:19 PM
Does anyone understand why the audio works, but will not come through my TV? maestro52 Fedora 1 12-15-2009 07:00 PM

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

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