The Tech Pulse

The Tech Pulse

Ubuntu Server - Samba

Using Samba on your Samsung NC110 running Ubuntu Server 24.04.1 is a lightweight and manageable solution that should not have a significant impact on your server, especially if it’s being used primarily for network storage and media sharing.

Here’s a detailed assessment of potential impact along with ways to optimize your server’s performance when using Samba.


Performance and Resource Impact

1. CPU and Memory Usage

  • Samba is generally lightweight and does not demand high CPU or memory resources for basic file-sharing tasks.
  • Your Samsung NC110 has a limited processor (likely an Intel Atom) and 2GB to 4GB of RAM, so you should:
    • Monitor memory usage if you are running other services like Jellyfin, WireGuard, or media transcoding.
    • Samba’s memory usage increases slightly with more concurrent connections or large file transfers, but it’s typically manageable.

Optimization Tip:

  • Use RAM-efficient configurations by disabling unnecessary Samba features (like printers) in the config file.

2. Network Bandwidth Usage

  • Since Samba will transfer files over your network, expect some bandwidth usage spikes during large file uploads or downloads.
  • However, as long as your server is connected to Ethernet (recommended for Samba), the impact on network speed should be minimal.

Optimization Tip:

  • Limit Samba transfer speeds by setting rate limits if needed, to avoid bandwidth hogging:
    socket options = SO_RCVBUF=65536 SO_SNDBUF=65536
    This can be added to /etc/samba/smb.conf.

3. Storage Impact

  • The main impact of Samba will come from storage usage, as files shared and transferred to the shared directory will take up space on your NC110.
    • If you have limited disk space, keep an eye on available storage with:
      df -h
    • You can also schedule cleanup tasks to ensure disk space remains available.

Optimization Tip:

  • Use log rotation to prevent Samba logs from taking up disk space:
    sudo nano /etc/logrotate.d/samba
    Example config:
    /var/log/samba/*.log {
        daily
        rotate 7
        compress
        delaycompress
        missingok
        notifempty
    }
    

4. Running Multiple Services Simultaneously

If your NC110 is also running other services (like Jellyfin or WireGuard), there might be resource competition since the Atom CPU and memory are limited.

Optimization Tips:

  • Monitor the system load using:
    top
  • Reduce Samba’s priority to ensure it doesn’t hog system resources:
    sudo nice -n 10 smbd

5. Security Considerations

Using Samba to share files makes your home network accessible, so it’s important to secure the service to prevent unauthorized access.

Best Practices for Security:

  • Restrict access to Samba shares by IP address in /etc/samba/smb.conf:

    hosts allow = 192.168.1.0/24
    
  • Use strong passwords for Samba users and require authentication:

    sudo smbpasswd -a [your-username]
  • Firewall Configuration: Allow Samba through the firewall but limit it to internal networks:

    sudo ufw allow from 192.168.1.0/24 to any port 137,138 proto udp sudo ufw allow from 192.168.1.0/24 to any port 139,445 proto tcp

6. Monitoring Samba's Performance on NC110

To ensure Samba is not causing performance bottlenecks:

  • Use system monitoring tools:

    htop iotop

    These will show you CPU, memory, and disk I/O usage to spot any issues caused by Samba.

  • Check Samba logs for errors or performance issues:

    sudo tail -f /var/log/samba/log.smbd

Conclusion: Will Samba Impact Your NC110 Server?

Given your Samsung NC110’s limited hardware, Samba should run fine for light file-sharing tasks. However:

  • If you plan on serving large files or concurrent users, Samba might affect performance.
  • If your NC110 is already running services like Jellyfin or WireGuard, keep an eye on system resources to avoid slowdowns.
  • With proper optimizations (like reduced logging, memory limits, and firewall rules), Samba can operate efficiently without negatively impacting your server.

In summary, Samba is a good fit for your NC110 server as long as:

  1. Concurrent usage is kept low.
  2. Ethernet is used for reliable transfers.
  3. You monitor the system resources periodically to ensure smooth operation.

UFW

Great! Since your Samsung NC110 server already has UFW (Uncomplicated Firewall) installed, let’s walk through the proper firewall configuration for Samba. This will ensure your server is secure while allowing only internal devices on your network to access your shared files.


How to Configure UFW for Samba on Your NC110

1. Understand Samba Ports

For Samba to work, several network ports must be opened. Here’s a quick overview of the required ports:

  • 137/UDP: NetBIOS Name Service
  • 138/UDP: NetBIOS Datagram Service
  • 139/TCP: NetBIOS Session Service
  • 445/TCP: SMB over TCP (used for file sharing)

You need to allow these ports in UFW, but only for trusted devices on your home network to ensure security.


2. Check Your Local Network IP Range

Before configuring UFW, verify the IP address range of your home network. Typically, routers assign addresses in the range:

  • 192.168.1.0/24 (common)
  • 192.168.0.0/24 (alternative)

You can check your NC110’s IP and network with:

ip a

Look for your Ethernet or Wi-Fi interface to confirm the IP range (e.g., 192.168.1.x).


3. Allow Samba through UFW for Your Local Network

Use the following UFW commands to allow Samba traffic only for devices on your local network. Replace 192.168.1.0/24 with your actual network range if it differs.

# Allow Samba UDP traffic on ports 137 and 138 sudo ufw allow from 192.168.1.0/24 to any port 137,138 proto udp # Allow Samba TCP traffic on ports 139 and 445 sudo ufw allow from 192.168.1.0/24 to any port 139,445 proto tcp

4. Enable and Check UFW Status

After adding the rules, reload and enable UFW to apply the changes:

sudo ufw reload sudo ufw enable

Then, verify that the Samba rules are active:

sudo ufw status verbose

You should see entries like this:

To                         Action      From
--                         ------      ----
137,138/udp                ALLOW       192.168.1.0/24
139,445/tcp                ALLOW       192.168.1.0/24

5. Optional: Block Samba from the Internet

To block external access, ensure UFW denies all incoming traffic by default, which is good practice.

Check your default policies:

sudo ufw status verbose

If the output shows:

Default: deny (incoming), allow (outgoing)

You're all set. If not, update it with:

sudo ufw default deny incoming sudo ufw default allow outgoing

6. Testing Samba Access from Another Device

  1. Try accessing your Samba share from a Windows or macOS machine on the same network.

    • Windows:
      Open File Explorer and enter:

      \\[NC110-server-IP]\MyFiles
      
    • macOS:
      In Finder, go to Go > Connect to Server and enter:

      smb://[NC110-server-IP]/MyFiles
      
  2. If successful, the shared folder will open. If not, review the UFW rules and ensure Samba services are running:

    sudo systemctl status smbd nmbd

7. Troubleshooting Tips

  • UFW not blocking external access properly? Double-check that no "Allow Anywhere" rules exist:

    sudo ufw status | grep "Anywhere"
  • Need to remove a specific rule?
    Use:

    sudo ufw delete allow from 192.168.1.0/24 to any port 137,138 proto udp

Conclusion

Using UFW to control Samba access ensures that only trusted devices on your local network can connect to your shared folders. The security provided by UFW is crucial when running any service on a home server, especially Samba, as it could otherwise expose your files to the internet. With this setup:

  • Your network shares are secure and accessible only to internal devices.
  • Unauthorized external access is blocked.
  • You maintain control over your NC110’s resources.

Now you can safely enjoy Samba network storage on your $0 Home Server, knowing that your firewall is properly configured!