On Sat, 25 Dec 2004 17:24:26 +0700 iktjen <[EMAIL PROTECTED]> wrote:
> Merry Christmas, everybody. > > I would like to ask can we make internet router o nat using Java ? > I have search, but I can't find any tutorial or open source how to > make router/nat. Can anybody help me ? > thank you very much. Not possible in Java. Internet IP routers do not work on TCP/UDP alone, they use raw IP packets for most things (routing being one). You can produce the same outcome for the logic that a router uses, for instance, with two interfaces, A B: Interface IP Address Subnet Network Address Broadcast A 192.168.0.1 255.255.255.0 192.168.0.0 192.168.0.255 B 65.2.1.1 255.255.255.0 65.2.1.0 65.2.1.255 The router itself will have a routing table, which is a set of rules: Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 * 255.255.255.0U 0 0 0 eth0 default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 This is the table that has come from my linux workstation. As we see the default route there says "any packet which is not for 192.168.0.* shall be directed to the gateway 192.168.0.1". Of course, 192.168.0.1 is the interface A on the router. That interface on the router will read the packet and say "Aha! this packet has been handed to me, but is intended for ___". In the router itself, it determins this through doing an common bitwise operations on the network addresses of the packet and it's own interfaces. I will leave that bit of magic for you and google to play with. Neadless to say, Java CANNOT perform routing operations as it CANNOT access RAW IP packets. Evidence of this is inability to use ICMP. There are third party additions for Java, but once you use those you no longer are using Java but some mangled piece of software that is not portable. If you turely have a use for a software router where you cannot deply Linux then use C, not C++. ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/5cFolB/TM --------------------------------------------------------------------~-> If you have any comments or questions, submit it on the message board. NO spam/ads/job posting or you will be BANNED from this group. Exception can be made it happen by notify me ahead of time. all new members' message will be verified by me (spam..) before it get posted. Yahoo! Groups Links <*> To reply to this message, go to: http://groups.yahoo.com/group/java_official/post?act=reply&messageNum=17918 Please do not reply to this message via email. More information here: http://help.yahoo.com/help/us/groups/messages/messages-23.html <*> To visit your group on the web, go to: http://groups.yahoo.com/group/java_official/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
