• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Vandie_Studios · Sep 01, 2015 at 11:09 AM · networkingmononatpunchthrough

Unet & Mono.Nat

Personally, I can't stand cloud hosted servers that I don't get to set up myself. Due to t$$anonymous$$s, I didn't want to use Unity Multiplayer but I liked the ease of use of Unet. Due to t$$anonymous$$s I did a bunch of reading on how I could get around it.

In the end I found t$$anonymous$$s forum post: Forum Post

W$$anonymous$$ch offered an interesting solution, To use Mono.NAT to preform a nat punch through on a lan game and then set up a custom server list. Now the tutorials linked on how to set up mono.NAT are very straight forward but I am unsure as to where abouts I need to put the code?

I assume its somewhere in the network manager script but I don't know where exactly.

Any help is greatly appreciated.

Signed, Vandie

Comment

People who like this

0 Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vandie_Studios · Sep 01, 2015 at 02:10 PM 0
Share

Any ideas?

avatar image Phedg1 · Feb 21, 2016 at 03:57 AM 0
Share

So, you had the mono.nat dll in the root of your assets folder and the punchthrough.cs file in the root of you assets folder, not attached to anything, and it just worked?

I can't seem to get this setup to work on mine.

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Vandie_Studios · Sep 01, 2015 at 05:34 PM

Ok turns out that all I had to do was create a new c# file that was purely the following code:

 using Mono.Nat;
 public class punchthrough {
 
     public punchthrough(){
         NatUtility.DeviceFound += DeviceFound;
         NatUtility.DeviceLost += DeviceLost;
         NatUtility.StartDiscovery ();
     }
 
     private void DeviceFound(object sender, DeviceEventArgs args)
     {
         INatDevice device = args.Device;
         device.CreatePortMap(new Mapping(Protocol.Tcp, 2033, 2033));
         // on device found code
     }
     
     private void DeviceLost(object sender, DeviceEventArgs args)
     {
         INatDevice device = args.Device;
         device.DeletePortMap(new Mapping(Protocol.Tcp, 2033, 2033));
         // on device disconnect code
     }
 }
 

I sent the file to a few others and it appears to punch through fine on port 2033

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by TwistedSage · Mar 06, 2016 at 02:44 PM

Hi. I just startet to look into Mono.NAT.

Once the port map is done, do I host the server on the internal IP (I create the port mapping like t$$anonymous$$s: device.CreatePortMap(new Mapping(Protocol.Tcp, 25000, 25000));) (or just 127.0.0.1) and then tell people to connect through the IP I get from device.GetExternalIP().ToString()?

Thanks in advance :)

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

30 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Networking Example Doesnt Connect 0 Answers

Symmetric Nat Punchthrough Problem 1 Answer

What is NAT Punchthrough - Android 1 Answer

How To Client Connect Player Host Via Public Ip 0 Answers

Receiving NAT punchthrough attempt from target 2500 failed 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges