Resolve netbios-name and pass it to mount.cifs in script
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I have a script that mounts all the shares from my Windows computer. It's basically:
mount.cifs //192.168.0.7/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,vers=3.0
..for about 10 lines.
Problem is, my network is DHCP. So every now and then I have to go change the IP in this script.
The script used to work this way:
mount.cifs //OTHERPC/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,ver=3.0
But at some point it started producing the error:
mount error: could not resolve address for OTHERPC: Unknown error
Nautilus resolves the name without a problem, though.
Is there a way to resolve the IP, store it in a variable and then use mount.cifs with //$variable instead of the IP directly in the script?
Thank you
shell-script scripting samba
add a comment |Â
up vote
3
down vote
favorite
I have a script that mounts all the shares from my Windows computer. It's basically:
mount.cifs //192.168.0.7/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,vers=3.0
..for about 10 lines.
Problem is, my network is DHCP. So every now and then I have to go change the IP in this script.
The script used to work this way:
mount.cifs //OTHERPC/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,ver=3.0
But at some point it started producing the error:
mount error: could not resolve address for OTHERPC: Unknown error
Nautilus resolves the name without a problem, though.
Is there a way to resolve the IP, store it in a variable and then use mount.cifs with //$variable instead of the IP directly in the script?
Thank you
shell-script scripting samba
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a script that mounts all the shares from my Windows computer. It's basically:
mount.cifs //192.168.0.7/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,vers=3.0
..for about 10 lines.
Problem is, my network is DHCP. So every now and then I have to go change the IP in this script.
The script used to work this way:
mount.cifs //OTHERPC/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,ver=3.0
But at some point it started producing the error:
mount error: could not resolve address for OTHERPC: Unknown error
Nautilus resolves the name without a problem, though.
Is there a way to resolve the IP, store it in a variable and then use mount.cifs with //$variable instead of the IP directly in the script?
Thank you
shell-script scripting samba
I have a script that mounts all the shares from my Windows computer. It's basically:
mount.cifs //192.168.0.7/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,vers=3.0
..for about 10 lines.
Problem is, my network is DHCP. So every now and then I have to go change the IP in this script.
The script used to work this way:
mount.cifs //OTHERPC/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,ver=3.0
But at some point it started producing the error:
mount error: could not resolve address for OTHERPC: Unknown error
Nautilus resolves the name without a problem, though.
Is there a way to resolve the IP, store it in a variable and then use mount.cifs with //$variable instead of the IP directly in the script?
Thank you
shell-script scripting samba
shell-script scripting samba
edited Apr 18 '17 at 15:05
asked Apr 18 '17 at 4:16
user659632
162
162
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
I see two options you should try before fiddling around with storing the IP in a variable. (Besides, unless the servers already have a hostname, how will you figure out the new IP?)
Try mounting with hostname instead of IP, if it is a dynamic IP.
mount.cifs //cifs.server.com/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,vers=3.0
- If the network is under your control, make DHCP reservations for the IP of the cifs servers.
This might have been useful information in my post, the script used to be like you described in your first option. mount.cifs //otherpc/pictures and so on and it worked fine. But at some point, the script started giving the error "mount error: could not resolve address for OTHERPC: Unknown error." That's why I changed it to the IP. Nautilus can resolve the netbios name without a problem, though.
â user659632
Apr 18 '17 at 15:00
add a comment |Â
up vote
0
down vote
I had exactly the same problem after an do-release-upgrade
to Ubuntu 18.04.1 LTS. All shares that mounted happily before ended with this ugly
mount error: could not resolve address for server.domain.local: Unknown error
nslookup
was resolving correctly, syslog
and strace
did not show anything.
In the end, the problem was the .local
domain together with a change (possibly during the release upgrade) in the /etc/nsswitch.conf
witch put the mDNS Avahi/Bonjour daemon mdns4_minimal
before dns lookup.
So the problem was solved after I changed the order from
hosts: files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns
to
hosts: files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return]
I can't remember all helpfull links, but this one certainly did the trick: https://askubuntu.com/a/853284/810573
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I see two options you should try before fiddling around with storing the IP in a variable. (Besides, unless the servers already have a hostname, how will you figure out the new IP?)
Try mounting with hostname instead of IP, if it is a dynamic IP.
mount.cifs //cifs.server.com/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,vers=3.0
- If the network is under your control, make DHCP reservations for the IP of the cifs servers.
This might have been useful information in my post, the script used to be like you described in your first option. mount.cifs //otherpc/pictures and so on and it worked fine. But at some point, the script started giving the error "mount error: could not resolve address for OTHERPC: Unknown error." That's why I changed it to the IP. Nautilus can resolve the netbios name without a problem, though.
â user659632
Apr 18 '17 at 15:00
add a comment |Â
up vote
0
down vote
I see two options you should try before fiddling around with storing the IP in a variable. (Besides, unless the servers already have a hostname, how will you figure out the new IP?)
Try mounting with hostname instead of IP, if it is a dynamic IP.
mount.cifs //cifs.server.com/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,vers=3.0
- If the network is under your control, make DHCP reservations for the IP of the cifs servers.
This might have been useful information in my post, the script used to be like you described in your first option. mount.cifs //otherpc/pictures and so on and it worked fine. But at some point, the script started giving the error "mount error: could not resolve address for OTHERPC: Unknown error." That's why I changed it to the IP. Nautilus can resolve the netbios name without a problem, though.
â user659632
Apr 18 '17 at 15:00
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I see two options you should try before fiddling around with storing the IP in a variable. (Besides, unless the servers already have a hostname, how will you figure out the new IP?)
Try mounting with hostname instead of IP, if it is a dynamic IP.
mount.cifs //cifs.server.com/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,vers=3.0
- If the network is under your control, make DHCP reservations for the IP of the cifs servers.
I see two options you should try before fiddling around with storing the IP in a variable. (Besides, unless the servers already have a hostname, how will you figure out the new IP?)
Try mounting with hostname instead of IP, if it is a dynamic IP.
mount.cifs //cifs.server.com/pictures ~/otherpc/pictures -o user=me,domain=mynetwork,password=12345,vers=3.0
- If the network is under your control, make DHCP reservations for the IP of the cifs servers.
answered Apr 18 '17 at 7:28
Rabban
693210
693210
This might have been useful information in my post, the script used to be like you described in your first option. mount.cifs //otherpc/pictures and so on and it worked fine. But at some point, the script started giving the error "mount error: could not resolve address for OTHERPC: Unknown error." That's why I changed it to the IP. Nautilus can resolve the netbios name without a problem, though.
â user659632
Apr 18 '17 at 15:00
add a comment |Â
This might have been useful information in my post, the script used to be like you described in your first option. mount.cifs //otherpc/pictures and so on and it worked fine. But at some point, the script started giving the error "mount error: could not resolve address for OTHERPC: Unknown error." That's why I changed it to the IP. Nautilus can resolve the netbios name without a problem, though.
â user659632
Apr 18 '17 at 15:00
This might have been useful information in my post, the script used to be like you described in your first option. mount.cifs //otherpc/pictures and so on and it worked fine. But at some point, the script started giving the error "mount error: could not resolve address for OTHERPC: Unknown error." That's why I changed it to the IP. Nautilus can resolve the netbios name without a problem, though.
â user659632
Apr 18 '17 at 15:00
This might have been useful information in my post, the script used to be like you described in your first option. mount.cifs //otherpc/pictures and so on and it worked fine. But at some point, the script started giving the error "mount error: could not resolve address for OTHERPC: Unknown error." That's why I changed it to the IP. Nautilus can resolve the netbios name without a problem, though.
â user659632
Apr 18 '17 at 15:00
add a comment |Â
up vote
0
down vote
I had exactly the same problem after an do-release-upgrade
to Ubuntu 18.04.1 LTS. All shares that mounted happily before ended with this ugly
mount error: could not resolve address for server.domain.local: Unknown error
nslookup
was resolving correctly, syslog
and strace
did not show anything.
In the end, the problem was the .local
domain together with a change (possibly during the release upgrade) in the /etc/nsswitch.conf
witch put the mDNS Avahi/Bonjour daemon mdns4_minimal
before dns lookup.
So the problem was solved after I changed the order from
hosts: files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns
to
hosts: files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return]
I can't remember all helpfull links, but this one certainly did the trick: https://askubuntu.com/a/853284/810573
add a comment |Â
up vote
0
down vote
I had exactly the same problem after an do-release-upgrade
to Ubuntu 18.04.1 LTS. All shares that mounted happily before ended with this ugly
mount error: could not resolve address for server.domain.local: Unknown error
nslookup
was resolving correctly, syslog
and strace
did not show anything.
In the end, the problem was the .local
domain together with a change (possibly during the release upgrade) in the /etc/nsswitch.conf
witch put the mDNS Avahi/Bonjour daemon mdns4_minimal
before dns lookup.
So the problem was solved after I changed the order from
hosts: files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns
to
hosts: files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return]
I can't remember all helpfull links, but this one certainly did the trick: https://askubuntu.com/a/853284/810573
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I had exactly the same problem after an do-release-upgrade
to Ubuntu 18.04.1 LTS. All shares that mounted happily before ended with this ugly
mount error: could not resolve address for server.domain.local: Unknown error
nslookup
was resolving correctly, syslog
and strace
did not show anything.
In the end, the problem was the .local
domain together with a change (possibly during the release upgrade) in the /etc/nsswitch.conf
witch put the mDNS Avahi/Bonjour daemon mdns4_minimal
before dns lookup.
So the problem was solved after I changed the order from
hosts: files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns
to
hosts: files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return]
I can't remember all helpfull links, but this one certainly did the trick: https://askubuntu.com/a/853284/810573
I had exactly the same problem after an do-release-upgrade
to Ubuntu 18.04.1 LTS. All shares that mounted happily before ended with this ugly
mount error: could not resolve address for server.domain.local: Unknown error
nslookup
was resolving correctly, syslog
and strace
did not show anything.
In the end, the problem was the .local
domain together with a change (possibly during the release upgrade) in the /etc/nsswitch.conf
witch put the mDNS Avahi/Bonjour daemon mdns4_minimal
before dns lookup.
So the problem was solved after I changed the order from
hosts: files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns
to
hosts: files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return]
I can't remember all helpfull links, but this one certainly did the trick: https://askubuntu.com/a/853284/810573
answered Aug 21 at 11:48
sc911
1
1
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f359594%2fresolve-netbios-name-and-pass-it-to-mount-cifs-in-script%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password