LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 09-18-2010, 12:49 PM   #1
avalosdanielr
LQ Newbie
 
Registered: Dec 2009
Posts: 6

Rep: Reputation: 0
Automated way of loging into servers by netbios name instead of ip's


In recent days, (today is September 18, 2010) I've been surfing the web trying to learn how to access nodes in my soho lan by netbios names instead of having to connect through the ip number, because ip's change every time according to DHCP assignments.

I do not know what has happened to the "new" command mount.cifs, but things seem to have become a bit more complicated with the new version. Security problems, they say, and surely that's the reason.

I show here an automated way of loging into servers by netbios name instead of having to resort to the use of IP numbers, hosts files, wins servers and all that jazz. This is especially useful if your soho lan have five or more network nodes, and you do not want to go finding out the ip numbers assigned to the machines you want to connect to (temporarily or permanently).

This is my approach: instead of the usual mount.cifs command:

mount.cifs //ServerIP/Servershare/ /Localmountpoint -o user=yourID%yourPASS

I replaced it by the following:

mount.cifs //$(nmblookup ServerName | gawk '/<00>/ {print $ 1}')/Servershare /Localmountpoint -o user=yourID%yourPASS.

Thus, when executing "nmblookup ServerName" nmblookup returns as output:
(assuming the server ServerName has ip=192.168.1.122)

querying ServerName on 192.168.1.255
192.168.1.122 ServerName<00>

This output is piped to gawk to isolate the line containing <00>, and gawk outputs the first element (print $1) of that line, which happens to be the ip of the server ServerName.

I tested the script in my soho network, which now has Linux, Windows XP and Windows 7 nodes, and it worked perfectly for both tipes of servers.

I'm using GNU's gawk, but I'm pretty sure that awk would do the job just as well.
 
Old 10-18-2010, 10:50 AM   #2
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
Alright, thanks for solution.
 
  


Reply

Tags
automated, netbiosnbtscan, serverhow


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loging Out thedoctor Linux - Newbie 1 03-12-2010 10:43 AM
loging mahmoudchamra Linux - Newbie 1 11-19-2009 04:40 AM
Automated telnet for testing servers jcllings Linux - General 4 08-21-2009 02:09 AM
Switched Servers...kept the same ip's chownuseradd Linux - Newbie 5 12-17-2007 08:25 AM
IPTables - Multiple Public IP's to private IP's matneyc Linux - Security 8 05-27-2005 12:23 PM


All times are GMT -5. The time now is 10:26 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration