Question

Problem Communicating behind NAT/firewall

Asked by: Vinod_VijayanVin

Hello Experts,
 
 We creating a client-server chat program. The program works fine in the absence of  NAT/firewall.
 But if either the server or client is behind NAT then communication with it cannot take place from
 outside.  Now is there a way to make the communication  possible even if either of the client or server
 is behind the firewall/NAT.Can this be done without  port forwarding or addding any rule to the
 NAT/firewall just like how the Yahoo Messenger does it.  We are using C# Socket Programming.
Any idea or C# code for solving the problem is welcome.

Thanks in advance.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2005-06-09 at 08:29:38ID21452579
Tags

behind

,

firewall

Topic

C# Programming Language

Participating Experts
2
Points
0
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. No Sound in MSN Messenger and Yahoo Messenger
    Hi I have a problem in MSN messenger and yahoo messenger i can't hear the other person and they can't hear me when i speak on MSN messenger. sound output is ok mic is ok in audio test in the messenger, i am running windows xp and running the internet over a server windows 20...
  2. yahoo messenger
    hello im looking where to find an yahoo messenger clone or a yahoo messenger component does anybody know where i can find one
  3. LAN & RAS Clients can't Windows Messenger Video chat…
    Hi! I have at work a PPPoE Internet Connection in a Windows 2000 Server machine. After some days I finally configured the RRAS Service to provide Internet access to both private LAN and RRAS clients. The problem is that the private LAN and RRAS clients can use just the basic...
  4. voice chat in yahoo messenger
    Helo group, I am new to linux iptables.Plz help me in this problem .We have redhat 8 linux on which we are runing iptables but customer behind this machine enable to use yahoo voice chat .What I have to do .These are the rules we are using xport PATH="/usr/local/sbin:/u...
  5. messeger and NAT
    dear experts my brother and i both behind NAT. my brother has webcam how can i see his face. thanks in advance raghu
  6. Yahoo messenger with "Use Proxy" settings not working..
    we had a new nokia IP 320 box with checkpoint NG with AI. Our setup is: LAN->Firewall->Router. Our LAN consists of Exchange server and ISA server in caching only mode. STATIC NAT is configured for ISA server and exchange server. Rule configured in firewall for ISA ser...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: j-trobecPosted on 2005-06-10 at 08:21:31ID: 14189524

The problem is that any time you want to send a message, you have to know what port you're sending it to...and that port needs to be open.  So, at the least, the server will need an open well known port.  One thing you may try, so that the client doesn't need to open ports is use a model where the client just regularly polls the server for incoming messages.  That way the client always innitiates the connection, and never needs to open a port and listen for incoming connections.

 

by: Vinod_VijayanVinPosted on 2005-06-14 at 01:16:52ID: 14209242

Hi j-trobec,
     I think you have misunderstood the problem

>The problem is that any time you want to send a message, you have to know what port you're sending it to...and that port    >needs to be open.  So, at the least, the server will need an open well known port.
  There is a well known open port at the server where the server listens for connection requests and the client connects to the
  server at that port. But if the server is behind firewall/NAT(i.e in a private LAN) and the client is in an outside n/w, the client  
  cannot make direct connection to the server because the firewall/NAT intercepts the packets sent from the server as also that  
  received from the client. The below diagram will explain it properly

----------------------------------------------------\           /
                                                                   \       /
       -----------                   -------------             \   /                      ----------------
      | Client1   |                |   Server  |              | |                       |    Client2    |
       -----------                   -------------             /    \                       ---------------
             LAN                                                 /       \
-----------------------------------------------------/          \                 Internet
                                                                      |
                                                                      |
                                                                firewall/NAT

   1. Consider the Server as the Chat Server
   2. Client1 and Server are in the same private network.
   3. The network is connected to the internet through firewall.
   4. Client2 is not in the same network as Client1 and Server but is connected to the internet
   5. In the above case Client1 can communicate with the Server without any hassle.
   6. Client2 cannot connect to server unless the port forwarding is done for the Server at the firewall/NAT.
   
    Now is there a way for communication to take place between Server and Client2 without manual port forwarding.
   A related problem : Is there a way to determine if a client or server is behind NAT/firewall.


 

by: j-trobecPosted on 2005-06-14 at 07:02:22ID: 14211433

I'm sorry for the miscommunication, Vinod.  When I said that the server needed an open well known port, what I was intending to say was that the server needed to have that port accessible to the client, meaning that the firewall would have to forward those packets to the server.  If this wasn't the case, then a NAT firewall really wouldn't do anyone any good; if it was possible to open connections to a server behind the firewall without configuring the firewall, of what use would that firewall be in the first place?

So, I believe that the answer to your first question is: no.  The firewall MUST be configured to allow communication from the client to pass through to the server.

In regards to determining if a client or server is behind a firewall, I am not aware of any certain tests available.  However, you could try programmatically testing available connections.  For example, say you have a program running on a machine, and you'd like to determine whether or not that machine is behind a firewall.  This machine can first test for internet access by pinging some well known internet sites.  Once that's done, the machine could then contact a server that you've put on the internet.  This server will then attempt to open a client connection to several ports on the original machine.  If none of the requests are successful, the server will have a good guess that the original machine is behind a firewall.  The original machine can then check back in with the server to find out the results of the test.

Hopefully that helps.

 

by: Vinod_VijayanVinPosted on 2005-07-13 at 06:29:57ID: 14430713

Hi TheLearnedOne,
  As i have not received any useful responses i am closing this question as requested.

 

by: j-trobecPosted on 2005-07-13 at 07:02:59ID: 14431075

While you may not deem my responses useful, they are accurate answers to your question.  If you happen to find a way to connect to a server that is behind a firewall without configuring that firewall, please notify the manufacturers of that firewall so they can issue a recall.

 

by: Vinod_VijayanVinPosted on 2005-07-14 at 07:32:25ID: 14441157

Well j-trobec,

 This was your response to my post
>> So, I believe that the answer to your first question is: no.  The firewall MUST be configured to >>allow communication from the client to pass through to the server.

       In my original post i had mentioned  "Yahoo Messenger".  I checked up with my System  
 administrator to find that there was no rule set up for the messenger. It uses some "Socks Firewall Library" to make communication possible even if client is behind firewall. So your observation is wrong.

 

by: j-trobecPosted on 2005-07-14 at 08:23:57ID: 14441905

Ok, you checked with your systems administrator, and found out that there was no configuration of your internal firewall to account for yahoo messenger.  Do me a favor and also ask your administrator this: do you run an internal Yahoo! Messenger server?  Of course not...

The point is that the machines on your internal network act as SOCKS clients.  Let me emphasize this, because it's important: the machines inside your network are CLIENTS.  The situation you described was that the server was behind a NAT firewall...in your words:

> 1. Consider the Server as the Chat Server
> 2. Client1 and Server are in the same private network.
> 3. The network is connected to the internet through firewall.

see, the server there is behind a firewall.

You may not realize it, but this makes a huge difference.  Look at this information about SOCKS:

"Applications use SOCKS in a very similar way to Winsock. Unlike HTTP application-layer proxies, which can connect to a server given only the DNS address, a SOCKS connection requires a legitimate IP address. Therefore, clients on the internal network must have the capability to resolve DNS addresses on the external network. Fortunately, most proxy servers that support SOCKS also provide DNS services.

Once the application knows the IP address of the destination server, it makes a request to SOCKS to communicate with the application server. This request will include the IP address of the server, information about the type of connection, and the user’s identity."

-- taken from http://www.windowsitlibrary.com/Content/386/18/4.html

Hopefully you took note of the reoccurrence of the phrase "IP address" in reference to the destination server...in your case, as we've established, you have your destination server behind a Firewall.  Now, ask your network administrator this question: if you want to setup a server on your internal network with an IP address that is reachable from the outside, would they have to do any configuration of the Firewall?

They should tell you that yes, some configuration will be necessary.

I urge you to use just a little bit of common sense on this.  Honestly ask yourself this question: if people can connect to servers on your internal network with out any configuration of the firewall, then of what possible use is the firewall in the first place?

Thank you and goodnight.

 

by: Vinod_VijayanVinPosted on 2005-07-15 at 02:33:50ID: 14448985

Hi j-trobec,
      Thanks for enlightening me. You were right and the link was very useful. Please post more links of  SOCKS.  But i am a little confused here. If the scernario is like i have mentioned before


----------------------------------\          /                    \        / ----------------------------------            
                                            \       /                       \     /    
    -----------     ------------        \   /     ----------         \  /                    --------------
   | Client1  |   |  Server |          ||      |Client2 |         ||                    |  Client3   |
    -----------     ------------        /   \     ----------         /  \                    --------------
             LAN 1                       /      \                        /     \                    LAN 2
----------------------------------/         \   Internet       /        \-----------------------------------
                                                  |                            |
                                                  |                            |
                                              firewall/NAT1         firewall/NAT2

 Now lets consider i have port forwarded the well known port of the pc that hosts the chat server
and gave it a domain name and IP address to be accessible from outside. Now any clients from
outside can have direct communication through normal socket connections without worrying about
the  NAT/firewall. So SOCKS doesn't come into picture for this type of clients. In the above
scenario Client2 can connect to Chat Server without worrying about SOCKS.
            Now Client3 cannot directly communicate with Chat Server as it is in a different n/w. So
 as you said it should implement a SOCK client. In this scenario i have two conflicating thoughts
 so please help me on this

     1. If i am not wrong the Chat Server should act as  the socks server. That means i have to implement both SOCKS client and SOCKS server. The SOCKS Server will be implemeted at each and every Chat Server and the SOCKS client will be implemented for every Chat Client.

     2. Or is it that i have to only implement SOCKS Client and the SOCKS Server is already
implemented by most of the proxy server(or NAT or firewalls). So in the above scenario
firewall/NAT2 will be the SOCKS server and Client3 will be the SOCKS client for communication
to be made possible between the Chat Server and the Client3. I think this is more right option.
 But i want a clarification bcoz in this case i am assumming that each and every proxy server avaliable in market or currently deployed have support for SOCKS included.

 

by: Vinod_VijayanVinPosted on 2005-08-08 at 02:21:05ID: 14621718

Hi j-trobec and TheLearnedOne,
    The SOCKS solution works only when the port 1080 which is the default port for SOCKS is open. In most cases
 the port is closed by administrator due to security issues. The only protocol that is allowed by most firewalls is HTTP as Web
 Browsing is the common activity that takes place in a priavate LAN. So most firewall bypassing techniques are based on  taking
 advantage of HTTP by using HTTP tunneling. An example in this regard is Quicktime as given by the link

   http://developer.apple.com/documentation/QuickTime/QTSS/Concepts/chapter_2_section_14.html

 While the HTTP commands post and get can be used for uploading and downloading files how can HTTP be used for building
 a chat application. Is there any example application or source code on how to make use of HTTP tunneling for building
 firewall bypassing Chat applications. Any link or idea in this regard will be appreciated.

   
 


 

 

by: moduloPosted on 2005-08-11 at 11:20:28ID: 14654315

PAQed with points refunded (500)

modulo
Community Support Moderator

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...