ping hostnames using avahi # Ubuntu in VMware. No resolving - vmware

I'm having a really strange problem. I have 2 virtual machines running ubuntu 11.4 in VMware player. These virtual machines have a bridged connection to my network. Since they use DHCP it would be more easy to let them talk to each other using hostnames instead of IP addresses.
That is where the it becomes a strange situation.
ping 192.168.0.10 //this is machine 1
ping 192.168.0.11 //this is machine 2
both work like a charm
ping machine1.local
ping machine2.local
work great on their own system. but ping machine1.local on machine 2 results in a "ping: unknown host machine1.local"
After trying and checking everything and getting nothing but the local machine in the avahi-browse, I installed wireshark to get to know what's really going on.
I ran wireshark, and then ran avahi-browse. In wireshark I saw all the responses to the MDNS message AND I GOT machine1.local AND machine2.local!!!
GREAT! but when I turned off wireshark the avahi-browse cache went empty again...
Why is it that when I have wireshark on in the virtual machine, the avahi-daemon gets the MDNS messages, and when I turn it off, the messages get lost again...

You may need to switch to the e1000 network adapter to (fully) support multicast. To switch to the e1000, open your vmx file in an editor and find the entry for the virtual ethernet adapters. Change or add this line:
ethernet0.virtualDev = "e1000"
(If you have more than one adapter, change it for each of ethernet0, ethernet1, etc.)
This thread details some of the multicast issues that seem similar to yours:
http://communities.vmware.com/message/1549658
This document describes the various possible virtual adapters and their limitations and capabilities:
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=1001805

Related

TCP streams on iOS don't show up on a wireless network

I am trying to send and receive TCP streams from an iPad via a wireless connection to a laptop. I create sockets with boost::asio. This project is a port of a data streaming library that I maintain that works quite well on Windows, OSX, and Linux.
I can get the app to send and receive streams to/from other computers on a wired LAN when I run it on the simulator. But, when I target the device itself, I can't see any streams.
As I say, I am communicating via wireless between an iPad and a laptop. I create a wireless network on the laptop and then give the iPad a static IP. The connection appears to be fine, because I can ping the iPad with no packet loss. I have also tried connecting the devices by putting them on the same wireless LAN (although I'm not supposed to use wireless routers at work) and this also does not work.
According to apple, setting up streams like this with NSStream will just work. Maybe there is some permissions magic happening under the hood that I am not doing with my calls to boost::asio functions. In any case, I can't see the streams.
Actually, it turns out the only thing that was wrong was that I needed to set up my routing table so that it pointed multicast to the wireless card:
> sudo route -nv add -net 224.0.0.183 -interface en1
I got the IP from inspecting packets in wireshark -- it is the address that my device is multicasting to in my laptop. Sending works (from device to laptop), receiving is still silent though. This may be something else that needs to be set int the routing table (I really don't understand much at all about multicasting) or else I can fiddle with some config settings with my library.

virtualbox bridged interface won't connect to internet

I'm trying to connect an ubuntu 12.04 to my local network + internet, i would like it to be directly reachable from the local network, NAT interface don't do it so i tried setting up a bridge (in the virtualbox GUI). But then i can access any other host on the LAN from the guest, but i can't access internet, the DHCP seems to work fine since my guest OS gets an IP in the correct range and with the correct mask. However i can't even ping the router which connect me to the internet (the same machine as the DHCP server).
here's my configuration:
host machine: linux mint debian edition X86-64
guests: win7 64 and ubuntu server 12.04 x86-64 (both have the same issue)
router-gateway-dhcp: livebox from orange ISP
host network interface: wifi usb dongle with chipset RTL8191SU (which works fine for my host)
I know the bridged mode isn't supported by all wireless adapter, but isn't it weird that i can access local network but not the internet?
maybe the problem comes from the gateway itself?
any advice would be very appreciated
In general, there is no problem in using VirtualBox in bridged mode on a laptop. I use it very often and on different platforms, yet it can be related to your network adapter.
Can you try to debug your network by using tcpdump (if familiar) or wireshark? I once had the problem that the mac address got rejected by the router. Can you check if the router is permissive for unauthorized mac addresses or anything alike?

Micro Cloud Foundry offline mode

during the last week I spent all my time trying to access the MCF in offline mode. I'm working behind a company network (proxy) and the MCF try to do things that conflict with the local network.
I've followed several different tutorials such as 1. Working offline with MCF and 2. Working offline with MCF. But the result keeps the same, even if I change all sort of configuration on my ubuntu.
Trying to set up the target.
vm target http: //api.mycloud.me
HTTP exception: Errno::ECONNREFUSED:Connection refused - connect(2)
The MCF console show the following information:
Identity: mycloud.me (ok)
Admin: admin#mycloud.me
IP address 10.0.x.x (network up / offline)
When I ping to the IP address, I got positive return.
PING 10.0.x.x (10.0.x.x) 56(84) bytes of data.
64 bytes from 10.0.x.x: icmp_req=1 ttl=62 time=1.06 ms
64 bytes from 10.0.x.x: icmp_req=2 ttl=62 time=0.896 ms
64 bytes from 10.0.x.x: icmp_req=3 ttl=62 time=0.880 ms
--- 10.0.2.15 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.880/0.948/1.069/0.089 ms
But if I try to do a telnet to the port 80 or a ssh I got connection refused error.
ssh: connect to host mycloud.me port 22: Connection refused
I don't know what I need to do to fix this, if anyone have a tip that help me to figure out a solution, I'll be very thankful.
Cheers!
OK dudes! That I fixed it!
So, after some problems to understand what was happening, I could finally connect to the Micro Cloud. I'm still validating the information from the two tutorials above, because could have some conflicted data.
I didn't test if it is necessary to set a nameserver to the dhclient, but the second tutorial seems to be more reliable. Just one tip, run the ssh -L tunnel on a separate terminal, and leave it open. This wasn't so clear for people like me, that was not used to working with network administration.
Thanks for the help.
given the assigned IP address, it looks like you are using bridged networking, have you tried changing the VM configuration to use NAT instead?
This will use an interface exclusive to your local machine and the VM and shouldn't be affected by your corporate network.

Socket application does not work over the internet

I've got a problem in socket programming. I'm currently writing a simple server/client application which asks connecting clients to answer a survey (I'm following the exercises in the book: TCP/IP Sockets in C: Practical guide for Programmers). It works fine in my local network (using localhost to connect), but I can't make it work over the internet.
Since I changed some of the code found in the book, I tried to compile the original source code from the book but it still doesn't work. I assume this is not a code problem but a network problem.
I did some research and so I turned off my firewall, I forwarded the port I'm using (12543) in my router but it still doesn't work... I've got a remote windows server running Windows 7 for testing: when I run my server on it and try to connect from my computer it fails, when I try to run my server from my computer and try to connect from the remote windows server: it fails again. Even when I run my server on my computer and try to connect with the client from the same computer using my private IPv4 address 192.168.x.x or my public one, it fails ! Oh, and there is no firewall running on the windows server.
I really don't know what to do now... I can ping my windows server from my computer, I can ping my computer from my windows server, but it's impossible to connect to my application.
The source code can be found here: http://cs.ecs.baylor.edu/~donahoo/practical/CSockets2/textcode.html (SurveyServer2.cpp, SurveyClient2.cpp, SurveyCommon.h), but I don't think it's a code problem.
Please tell me if it's not clear enough. And excuse me if I did some grammatical errors, I'm french!
Any help would be appreciated, thanks!
EDIT : Ok, I know what's going on: it's a compatibility issue between IPv4 and IPv6! It's not properly working yet, but I now know what to fix. Thanks everybody :)
SECOND EDIT : Well, I think I finally understood. I was binding my server to a IPv6 address, but the host my server is running on only have a public IPv4 address. When I tried to connect, the DNS resolution only returned a IPv4 address so I was unable to connect to my server. I told to getaddrinfo to return only IPv4 addresses, so now it binds on a IPv4 address and it works fine.
There is surely a way to add a IPv6 address to my host but I don't think I will need it, it works okay right now, I hope this doesn't cause any trouble.
The code makes usage of getaddrinfo and need a hostname not a IP address.
It does sound like you have a connectivity issue or a DNS issue.
Ensure the name resolution is working:
Enter 'ping server_NAME' on the command line of the client machine.
If it can't find an IP address for the server name that could be your issue.
Ensure connectivity:
On the server command line:
enter 'netstat -an -p TCP'. This will show a list of all programs listening and their port numbers. You should see your server listening on port 12543.
On the machine where you are running your client program:
Use telnet to see if you can get through to the server. You can set the port number telnet uses with a command line option. Usually something like 'telnet -p 12543 server-ip'. If it says 'connection refused' then there's a connectivity issue (a firewall/etc). If it opens a connection you will get no error message and you will be able to type text to be sent to the server. You really only care if telnet was able to establish a tcp connection here.
If Telnet does connect then your issue is communication between the programs and not a network issue.

C/C++ detect network type

I need to write a win32 c/c++ application which will be able to determine whether the PC it's running on is connected to one of 2 networks. The first network is the company LAN (which has no internet connection) and the second network is a standalone switch with a single PC connected to it (the PC that the program is running on).
I'm pretty new to network programming but so far I have tried testing to see if a network drive which is held on our LAN can be mapped. This works fine if the PC is connected to the LAN, the drive mapping succeeds so so LAN detection is successful. However, if the PC is connected to the switch, this results in a VERY long timeout which is not a suitable as it will delay the program so much as to make it unusable.
Does anyone have any alternative suggestions?
I'm using c/c++ in VS 6.0
[Update]
Whilst trying a few different ideas and looking at some of the suggestions below I thought I should update with some additional information as many (if not all) of the suggestions I don't think will work.
(1) The aforementioned LAN has no external connections at all, it is completely isolated so no resolving of external DNS or pinging websites is possible.
(2) Hostname, MAC address, IP, Default Gateway, Subnet etc etc (basically everything you see in ipconfig -all) are all manually configured (not dynamic from the router) so checking any of these settings will return the same whether connected to the LAN or the switch.
(3) Due to point (2), any attempts to communicate with the switch seem to be unsuccessful, in fact almost all networking commands (ping, arp etc) seem to fail - I think due to the machine trying to connect to the LAN when it isn't there :-(
One thing I have found which works is pinging the default gateway IP which times out when connected to the switch. This is sort of ok as I can reduce the timeout of ping so it doesn't just hang for ages but it feels like a bit of a hack and I would certainly appreciate any better solutions.
Thanks
As far as TCP/IP is concerned there is no such thing as a LAN on WAN. There are a set of non-internet routable addresses like 192.168.x.x and 10.x.x.x but these are sometimes used by ISP short of IP addresses.
You best bet is to use Asynchronous APIs when making TCP/IP connections. WIN32 defines a whole buch of OVERLAPPED APIs for this purpose. This will prevent your application from grinding to a halt while waiting for a remote connection.
Alternatively put the socket stuff into another thread and then only notify the UI when the operation is done.
I would first try to differentiate between the two using information available locally--that is, from your computer. Does the output of ipconfig /all differ depending on which network you're connected to? If so, exploit that difference if you can.
Is it possible to get the MAC address of the standalone switch? Of the switch that controls the company LAN? That would be a sure way to tell. Unless somebody cloned the MAC address.
If you try using the existence or non-existence of some network service to determine which network you're connected to, you can never be sure. For example, if you failed to map that network drive, all you know is that the network drive isn't available. You can't say for certain that you're not connected to the company LAN. Same is true if you use ping. Lack of response from a particular machine means only that the machine didn't respond.
Various things you can look at for differentiation:
DNS domain name (GetComputerNameEx)
MAC address of gateway (ping it, then GetIpNetTable)
Routing table(do you have a gateway and default route on the company LAN)
WNet discovered network resources (WNetOpenEnum, WNetEnumResource)
Ability to resolve external hostnames (try a 5-10 names like www.google.com, www.microsoft.com and so on, if one resolves you should have internet)
You'll have to decide how many indicators are "enough" to decide you're on one or the other LAN though if tests fail. Then keep retrying until you have a definite result.
http://msdn.microsoft.com/en-us/library/aa366071%28v=VS.85%29.aspx has a lot of network related functions that you can experiment with to create further indicators.