Community discussions

MikroTik App
 
gemesif
just joined
Topic Author
Posts: 15
Joined: Wed Aug 29, 2018 4:04 pm
Location: Hungary, Budapest

Mikrotik SMB server – connecting with Windows and Linux client(syllabus)

Sun Jun 12, 2022 6:16 pm

Purpose, to share my experiences about this theme.

Labs environment:
- Mikrotik hAP ac2, RouterOS 6.49.6, with USB stick
- Microsoft Windows 10 Pro
- Ubuntu Linux 20.04 LTS guest, on VirtulBox, bridged WAN interface with Windows

I. Router configurattion
in terminal:
(minimal configuration)
Note: RouterOS only supports SMB v1.0 and v2.002
/ip smb
set enabled=yes
/ip smb shares
add directory=/disk1 name=mikrotikusb
check it:
/ip smb shares print 
Flags: X - disabled, I - inactive, * - default 
 #    NAME                                                              DIRECTORY                                                             MAX-SESSIONS
 0  * ;;; default share
      pub                                                               /flash/pub                                                                      10
 1    mikrotikusb                                                       /disk1                                                                          10

/ip smb users print 
Flags: * - default, X - disabled 
 #    NAME                                                                PASSWORD                                                               READ-ONLY
 0 *  guest                                                                                                                                      yes  

/ip dns static print 
Flags: D - dynamic, X - disabled 
 #    NAME                          REGEXP                          TYPE     ADDRESS                                                          TTL         
 0    ;;; defconf
      router.lan                                                             192.168.88.1                                                     1d          
 1    bananapi.lan                                                           192.168.88.182                                                   1d          
 .
 .
 .

II. Windows configuration
in cmd prompt:
net use
New connections will be remembered.


Status       Local     Remote                    Network

-------------------------------------------------------------------------------
OK           Y:        \\bananapi.lan\bananapitmp
                                                Microsoft Windows Network
OK           Z:        \\bananapi\bananapi       Microsoft Windows Network
The command completed successfully.
choose free netwotk drive, and
net use X: \\router.lan\mikrotikusb /user:guest /persistent:yes
Enter the password for 'guest' to connect to 'router.lan':
The command completed successfully.
Enter the password for 'guest' - push Enter, guest has't password
net use
New connections will be remembered.


Status       Local     Remote                    Network

-------------------------------------------------------------------------------
OK           X:        \\router.lan\mikrotikusb  Microsoft Windows Network
OK           Y:        \\bananapi.lan\bananapitmp
                                                Microsoft Windows Network
OK           Z:        \\bananapi\bananapi       Microsoft Windows Network
The command completed successfully.
list mapped drive:
dir X:


    Directory: X:\


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----     2022. 06. 08.     18:18        6926360 attack.0.txt
-a----     2022. 06. 06.     15:55        8731450 attack.1.txt
III. Linux configuration
in command prompt - bash:
smbclient -U guest //router.lan/mikrotikusb
Enter WORKGROUP\guest's password: 
Try "help" to get a list of possible commands.
smb: \> 
smb: \> help
?              allinfo        altname        archive        backup         
blocksize      cancel         case_sensitive cd             chmod          
chown          close          del            deltree        dir            
du             echo           exit           get            getfacl        
geteas         hardlink       help           history        iosize         
lcd            link           lock           lowercase      ls             
l              mask           md             mget           mkdir          
more           mput           newer          notify         open           
posix          posix_encrypt  posix_open     posix_mkdir    posix_rmdir    
posix_unlink   posix_whoami   print          prompt         put            
pwd            q              queue          quit           readlink       
rd             recurse        reget          rename         reput          
rm             rmdir          showacls       setea          setmode        
scopy          stat           symlink        tar            tarmode        
timeout        translate      unlock         volume         vuid           
wdel           logon          listconnect    showconnect    tcon           
tdis           tid            utimes         logoff         ..             
!              
smb: \> 

'l' list files:

smb: \> l
  .                                 DAH    12288  Thu Jun  9 21:10:27 2022
  ..                                DAH      440  Tue Jun  7 18:25:27 2022
  attack.0.txt                        A  1157041  Fri Jun 10 12:01:13 2022
  attack.1.txt                        A  8962063  Thu Jun  9 21:10:18 2022
see man smbclient
mount:
man 8 mount.cifs

sudo mount.cifs //router.lan/mikrotikusb /mnt/tmpshare --verbose -o vers=2.0,username=guest,pass=""
or with mount option
sudo mount -t cifs //router.lan/mikrotikusb /mnt/tmpshare --verbose -o vers=2.0,username=guest,pass=""

/etc/fstab
/router.lan/mikrotikusb        /mnt/tmpshare   cifs    vers=2.0,username=guest,pass=,noauto    0 0
Mount 'by hand':
sudo mount -v -a
sudo mount -v /mnt/tmpshare/
sudo mount -v //router.lan/mikrotikusb
Automatic mount on boot or with mount -a, change noauto to auto


Summary
Labs working well.
Further steps suggested; making dedikated user, with password on Mikrotik site.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], GoogleOther [Bot] and 67 guests