Score:0

How to deploy two samba server instances on Ubuntu 22.04.2

al flag

I've searched for information about this topic, but it seems to be a strange thing that almost nobody cares about.

I have found some old information, but either it is outdated or it is unanswered questions in forums.

I have tried asking to chatbots, but as expected, their answers are not correct/well documented.

I want to have one samba server for home use with different shares and read and/or write permissions on each one. And another one for read-only, non sensitive data (Like software, Windows ISOs, music, films, etc.), access from internet (opening a port 445 from outside to my internal read-only samba server 445 port), so I can access it from everywhere, without the need for SSH tunnels or whatever. In this second instance of samba server, I would only expose non-personal, non-sensitive data, and read-only access in all shares. That way, even if someone hacks my samba password (please correct me if I'm wrong) I would not loose anything.

I'd like to know:

  • Is it possible in a single Ubuntu server to deploy two samba server services?
  • How would I duplicate my ethernet port? I've already tried configuring my netplan file as this:
#This is the network config written by 'subiquity'
network:
  version: 2
  renderer: networkd

  ethernets:
    enp2s0:
      dhcp4: false
      dhcp6: false

  bridges:
    br0:
      interfaces: [enp2s0]
      addresses:
        - 192.168.1.2/24:
            label: "br0:0"
        - 192.168.1.4/24:
            label: "br0:1"
      nameservers:
        addresses:
        - 8.8.8.8
        - 8.8.4.4
        search: []
      routes:
      - to: default
        via: 192.168.1.3
        metric: 100
        on-link: true
      mtu: 1500
      parameters:
        stp: true
        forward-delay: 4
      dhcp4: no
      dhcp6: no

and I think I could use br0:0 to one service and br0:1 to the other service.

  • How should I configure the smbd.service file (original), and the new smbd2.service file (new one)?
  • Do you have any other advice / notes regarding my question?
cn flag
Why would that require two samba servers? That can be done with 1 and 2 users and/or 2 directories. And no you can not use the same port for two servers. This has all you need: https://wiki.samba.org/index.php/Multiple_Server_Instances but for what you want it to do ... there should be no need for it: 2 users with different permissions should be enough.
cn flag
Your question is sort of wrong: you should be asking about how to get the middle part of your question. This "different shares and read and/or write permissions on each one. And another one for read-only, non sensitive data". And not throw in things you expect to need like samba. Mind that samba only makes sense if you have a non-linux machine. Otherwise nfs is the better method.
BorHacker avatar
al flag
@Rinzwind, I don't want to expose all my personal samba shares to everyone in internet. This is a securlty measure. Even I'm not 100% sure of exposing only the non-personal, non-sensitive readonly shares.
BorHacker avatar
al flag
@Rinzwind, AFAIK, if I have two IP addresses in my server, each one can have a port 445 dedicated to samba server.
BorHacker avatar
al flag
@Rinzwind, I already Saw that guide and its outdated. I was following It and I saw that It has another way of managing servicies or something like that.
BorHacker avatar
al flag
@Rinzwind I usually use my samba shares from Windows hosts, It Is its main use
BorHacker avatar
al flag
I will try another approach: installing an Ubuntu Server virtual machine with qemu. And then run a samba server from the virtual machine. Anyway if there's anybody who tell me a better solution it would be great.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.