Search code examples
windowvirtualboxsambanat

How to change the window 445 port


my host OS is window7;
my guest OS is centos7 is runing on virtualbox;
i hope share centos7's files for window7 via samba server;
the samba server is runing in the centos7;

when centos7 connect network with "Bridged networking" or "Host-only networking" ;
Assuming that the centos7 IP is 10.254.254.254;
i can Configuring a-network-driver for window7,like "\\10.254.254.254\www",it is working;

now,i only want to use "Network Address Translation Service (experimental)" for the centos7; but i still want to share centos7's files for window7 via "samba server";

i can Configuring port forwarding with NAT,like that:

hostIP:port <= guestIP:port
0.0.0.0:80 <= 10.254.254.2:80  
127.0.0.2:22 <= 10.254.254.2:22  

now i can visit my web : http://192.168.1.8 or http://127.0.0.2;
and connect the ssh server: 127.0.0.2:22 it working;

but,if i Configuring the smb port forwarding with NAT,like:

127.0.0.2:445 <= 10.254.254.2:445   (it not working)  
127.0.0.2:139 <= 10.254.254.2:139  (it working)  

i know i can not re-bind the 445 port for "centos's" smb server;

so, i can not share file via "\\127.0.0.2\www"; then,i google,some one say:"window smb server and client port is 445"; now i think:"can i change the window's port of 445 to anyother number,4450?5555?",if it can,i can Configuring the smb port forwarding with NAT,like:

127.0.0.2:4450 <= 10.254.254.2:445  
127.0.0.2:1390 <= 10.254.254.2:139  

i had try :

  1. HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\NetBT\Parameters

    Value Name: SmbDeviceEnabled
    Type: REG_DWORD
    Value Data: 0
    

    and then restart window7, but the "netstat -p TCP -noba" still show me:

    [svchost.exe] TCP    0.0.0.0:445  
    
  2. try change port to 5555,and restart,but fail,the port still show me 445

    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Smb] "SessionPort"=dword:0000022b
    "DatagramPort"=dword:0000022b

any idea ?
thank you!


Solution

  • Because of this problem cannot be solved;
    I am using the following solutions now:

    1 rebuid my nginx service from nginx-source,to add webDAV mod;
    2 share centos7's files via nginx-webDAV service;

    why? because i found:

    when i use "host-only" and "NAT" for centos,They are all the LAN IP address ;

    when the guest os's ip setting like that: the interface of "host-only":

     IPDDR=10.254.254.254, and my host os don't sharing my WIFI for it,  
    so it can't connect to WAN,   
    becuase i only want it share me centos's files ; 
    

    the interface of "NAT" :

     ipddr=10.0.0.2,it can connect to WAN,  
    for the other services,like:ssh/web/mysql, and so on; 
    

    then ssh/web/mysql don't know connect to which GATEWAY.

    maybe i can write some "route" to fix it,but it is a big bad thing;