关于Samba
samba是Linux和Unix平台的一款实现了SMB协议的软件,可以使得windows平台的主机也可以访问Linux和Unix平台主机共享出来的资源。
SMB协议(Server Message Block)是由微软开发的一种软件程序级的网络传输协议,基于NetBIOS,主要功用是使得一个网络上的机器共享计算机文件、打印机、串行端口和通讯等资源,使用C/S架构运行,主要作用在Windows平台。
samba服务监听的协议端口:
- UDP协议 端口号:137 NetBIOS名字服务 服务名称:nmbd
- UDP协议 端口号:138 NetBIOS数据包服务
- TCP协议 端口号:139 文件共享和打印机共享 服务名称:smbd
- TCP协议 端口号:445 NetBIOS在Windows2000及以后版本使用此端口
Openwrt下直接安装samba服务
终端输入
opkg update
opkg install samba
安装完成后,重启 OpenWrt 路由器以使配置生效。
Openwrt下USB TypeA编译适配Samba
可以到Openwrt官网搜索samba相关内容进行学习
以下以samba3.6为例表述我自己在openwrt下的操作步骤:
- 首先需要下载对应的tar包到openwrt源码根目录的dl文件夹下
- makefile等文件放在package/network/services/samba36目录下
samba36
├─ files
├─ patches
└─ Makefile - 随后根据个人需求对配置文件做修改,其中samba.config是uci配置文件,samba.conf.template是配置模板,samba.init是samba初始化脚本
Makefile:默认配置即可
# Copyright (C) 2007-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=samba
PKG_VERSION:=3.6.25
PKG_RELEASE:=1.1
PKG_SOURCE_URL:=http://ftp.samba.org/pub/samba \
http://ftp.samba.org/pub/samba/stable
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_MD5SUM:=76da2fa64edd94a0188531e7ecb27c4e
PKG_LICENSE:=GPLv3
PKG_LICENSE_FILES:=COPYING
PKG_MAINTAINER:=Felix Fietkau <[email protected]>
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
MAKE_PATH:=source3
CONFIGURE_PATH:=source3
PKG_BUILD_BIN:=$(PKG_BUILD_DIR)/$(MAKE_PATH)/bin
define Package/samba36-server
SECTION:=net
CATEGORY:=Network
TITLE:=Samba 3.6 SMB/CIFS server
URL:=http://www.samba.org/
DEPENDS:=+USE_EGLIBC:librt
endef
define Package/samba36-client
SECTION:=net
CATEGORY:=Network
TITLE:=Samba 3.6 SMB/CIFS client
URL:=http://www.samba.org/
DEPENDS:=+libreadline +libncurses
endef
define Package/samba36-server/config
config PACKAGE_SAMBA_MAX_DEBUG_LEVEL
int "Maximum level of compiled-in debug messages"
depends on PACKAGE_samba36-server || PACKAGE_samba36-client
default -1
endef
define Package/samba36-server/description
The Samba software suite is a collection of programs that implements the
SMB protocol for UNIX systems, allowing you to serve files and printers to
Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred
to as the LanManager or Netbios protocol.
endef
TARGET_CFLAGS += -DMAX_DEBUG_LEVEL=$(CONFIG_PACKAGE_SAMBA_MAX_DEBUG_LEVEL) -D__location__=\\\"\\\" -ffunction-sections -fdata-sections
TARGET_LDFLAGS += -Wl,--gc-sections
CONFIGURE_VARS += \
ac_cv_lib_attr_getxattr=no \
ac_cv_search_getxattr=no \
ac_cv_file__proc_sys_kernel_core_pattern=yes \
libreplace_cv_HAVE_C99_VSNPRINTF=yes \
libreplace_cv_HAVE_GETADDRINFO=yes \
libreplace_cv_HAVE_IFACE_IFCONF=yes \
LINUX_LFS_SUPPORT=yes \
samba_cv_CC_NEGATIVE_ENUM_VALUES=yes \
samba_cv_HAVE_GETTIMEOFDAY_TZ=yes \
samba_cv_HAVE_IFACE_IFCONF=yes \
samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes \
samba_cv_HAVE_SECURE_MKSTEMP=yes \
samba_cv_HAVE_WRFILE_KEYTAB=no \
samba_cv_USE_SETREUID=yes \
samba_cv_USE_SETRESUID=yes \
samba_cv_have_setreuid=yes \
samba_cv_have_setresuid=yes \
ac_cv_header_zlib_h=no \