You are not logged in.

#1 2015-06-19 22:25:12

SteveSapolsky
Member
Registered: 2014-08-09
Posts: 16

Using nbd. Changing the default port.

Does anybody know how to change the default port in nbd-server? There are very few tutorials and examples of how to use nbd. Most of the material is ancient and nothing I've tried so far works properly. FTR, there is also  an ancient out-dated thread which tries to figure out how to use NBD

I have a weird behavior with nbd-server (3.10). When I have success in specifying what port to use, it also starts to listen to a bunch of other ports as well. If you don't specify any port and let it use the default, it does not listen to any additional ports. For example, below I try to make it listen to the port 9000 on localhost.

~ sudo nbd-server localhost:9000 /dev/sdc
** (process:3121): WARNING **: Specifying an export on the command line is deprecated.

** (process:3121): WARNING **: Please use a configuration file instead.

As you can see it listens to the port 9000, but it also listens to a bunch of other ports, including the default one.

~ sudo netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:55055           0.0.0.0:*               LISTEN      3122/nbd-server                
tcp        0      0 0.0.0.0:10809           0.0.0.0:*               LISTEN      3122/nbd-server     
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      3122/nbd-server             
tcp6       0      0 :::51489                :::*                    LISTEN      3122/nbd-server     
tcp6       0      0 ::1:9000                :::*                    LISTEN      3122/nbd-server   

My config file is simple:

[generic]
  user = nbd
  group = nbd
[otherexport]
    exportname = /dev/sdc
    #port = 9000

As you've probably noticed, it prints a warning "WARNING **: Specifying an export on the command line is deprecated." But without the `/dev/sdc` argument it ignores the port completely and listens to the default port. Here I try to specify just the port:

~ sudo nbd-server localhost:9000
~ sudo netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name         
tcp        0      0 0.0.0.0:10809           0.0.0.0:*               LISTEN      3171/nbd-server       

Running it without any arguments does work. It starts without warnings and it listens to only one port, as you can see below. Unfortunately that's not the port I want it to listen to:

~ sudo nbd-server
~ sudo netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:10809           0.0.0.0:*               LISTEN      3222/nbd-server     

I tried to fiddle with the config file as well. However, the protocol changed and you can no longer specify a port in the config file. Switching to oldstyle protocol does not work:

~ sudo nbd-server
** Message: Since 3.10, the oldstyle protocol is no longer supported. Please migrate to the newstyle protocol.
** Message: Exiting.

the config for the command above ^ was:

[generic]
  oldstyle=true # this switches it the old protocol
  user = nbd
  group = nbd
[otherexport]
    exportname = /dev/sdc
    port = 9000 # new protocol simple ignores the port line whether it's commented or not

Does anybody know how to use it properly? Otherwise, I think I'll have to just use iptables to redirect traffic to the default port and block the default port from the outside.

Offline

Board footer

Powered by FluxBB