0

I am using a java program on Lubuntu which backs up my windows computer through Wi-Fi LAN. I need to access to his windows shared folder but with PC-NAME, not with IP Address. How can I do that?

I am using cifs utils to achieve that and for permanent mount it is in /etc/fstab:

//PCName/ShareF /media/PCName/ShareF cifs credentials=/home/user/.myrcre

But I get this error:

mount error: could not resolve address for PCName: Unknown error

I need to access the windows PC through its name, not ip address, because I dont want to set the static ip, and because of that, the IP address changes sometimes. I need it mounted permanently, no matter if server or client is shuted down.

Maybe, it is here some another possibility, e.g. java code could obtain IP address from PCName, but I dont know why. Cant find anything.

Thank you for any answer.

Altair
  • 325
  • 3
  • 16

1 Answers1

1

First of all, Lubuntu needs to know who is PCName, so ping it from terminal and verify:

ping PCName

If you can resolve PCName to XXX.YYY.KKK.ZZZ, you can mount it.

If you can't resolve the name, Lubuntu can't mount an undefined network resource and i suppose that it's your case:

mount error: could not resolve address for PCName

This is a network question, not really a programming question.

Have you a Domain Server or a DNS server in the network?

If you have it, on your Lubuntu PC set the DNS server to that ip and try to resolve PCName again. Lubuntu will be able to resolve PCName asking to the server (DNS or DC).

Have you access to the DHCP server (on the router I suppose) ?

If you have it, you can map you PCName's MAC address to a particular fixed address. Your Windows PC is still in DHCP but it receive always the same ip.

On Lubuntu add a row in /etc/hosts and the trick is done.

Can't you apply those solutions? ARP-scanning

If you know your Windows PCName's mac address, you can make an ARP scan on the network.

You'll receive a map IP -> MAC so from MAC you get the IP. Now, you can mount your PCName by his IP.

This solution may fail if a firewall, an antivirus software or a IPS block the arp-scanning.

Remember : you can do all linux commands throw Runtime.exec, read this other question. If you can do it in Linux, you can do it in Java

Daniele Licitra
  • 1,520
  • 21
  • 45
  • Thanks for answer, but when i try this command ping PCName, output: ping: PCName: Temporary failure in name resolution. I have added DNS into /etc/systemd/resolved.conf and restart it, still not working. I have allowed firewall port 53 udp and tcp. Still not change. I can ping my PCName from different Windows device, but not from my Lubuntu :( – Altair May 18 '19 at 11:36
  • 1
    The DHCP router mapping solved my problem. Thank you very much. :) – Altair May 18 '19 at 12:18