折腾WNDR4300路由器, 刷dd-wrt固件,安装Entware,部署cups打印服务器,改刷OPENWRT才成功识别打印机

废话不多说,直接开干,先刷固件

一、先刷固件

先断电,按着重置不放,开电源, 待电源灯光第二次连续闪烁即可刷入新固件。
刷固件要把本地IP地址按下图改一下,IP地址:192.168.1.2 网关192.168.1.1
在这里插入图片描述

然后用FTFP工具按下图配置,浏览到你下载的img固件,我下的是这个固件版本,点击PUT按钮,待上传完后面点击OK。
在这里插入图片描述
稍等片刻,注意观察路由器的亮灯状态,稳定后即可完成刷机。
用浏览器打开http://192.168.1.1页面,不用密码即可进入管理页面。
设置好密码,即可用SSH登陆命令模式界面。

root@OpenWrt:~# opkg update  #更新源
root@OpenWrt:~# opkg install luci-i18n-base-zh-cn #安装中文
root@OpenWrt:~# opkg install openssh-sftp-server #安装SFTP,方便上传文件

二、挂载U盘

界面配置很友好,功能强大,完善,但不好安装OPKG包,需要插U盘来扩展分区,再来安装所需要的包。

插上U盘看,看看U盘的UUID

root@DD-WRT:~# blkid	#查看UUID
/dev/sda1: LABEL="KINGSTON" UUID="BBFA-C9B1"

root@DD-WRT:~# df -Th	#查看分区与挂载情况
Filesystem           Type            Size      Used Available Use% Mounted on
rootfs               rootfs         22.3M     22.3M         0 100% /
/dev/root            squashfs       22.3M     22.3M         0 100% /
none                 tmpfs         512.0K         0    512.0K   0% /dev
/dev/sda1            ext4           56.5G     66.9M     53.6G   0% /opt
/dev/mtdblock/3      jffs2          97.9M      2.4M     95.5M   2% /jffs

root@DD-WRT:/tmp/mnt/sda1# umount /tmp/mnt/sda1/	#取消挂载后才能格式化,需要切换出挂载的目录再取消挂载

root@DD-WRT:/tmp/mnt/sda1# mkfs.ext3 /dev/sda1 		#格式化为ext3格式,windows下的 fat格式没有权限,不能建立软链接
mke2fs 1.45.4 (23-Sep-2019)
/dev/sda1 contains a vfat file system labelled 'KINGSTON'
Proceed anyway? (y,N) y
/dev/sda1 is mounted; will not make a filesystem here!

在这里插入图片描述

三、安装Entware

然后按这个页面的详细介绍安装Entware
https://wiki.dd-wrt.com/wiki/index.php/Installing_Entware
可以大致按以下几个步骤:
1、如果没有自动挂载,则手动挂载
2、根据自己的CPU架构,选择下面的方式获取安装脚本:在这里插入图片描述

For MIPS based devices (Atheros, not dual core), this will be:

cd /opt (click enter)
wget http://bin.entware.net/mipssf-k3.4/installer/generic.sh (click enter)
sh generic.sh (click enter)

然后就可以看到安装与下载包的进度了
在这里插入图片描述
看到这样的,基本上就代表安装成功了。
在这里我要抒发一下我的个人感情了:很幸运,在经过9981难后,没有放弃,终于成功了,差一点点我就玩不下去了,百度都被我搜烂了, 找到的安装cups方式都不成功,不是没有合适的包,就是安装不了,最后通过某个论坛里某个人一个简短的提点,知道了Entware的存在,说里面的包很全面, 我想总有cups吧,再一番狂搜后,一直没有安装成功,最后还是在https://wiki.dd-wrt.com官方网站里面通过搜索Entware才找到了正确安装步骤的。

最后一步,按介绍添加开机启动:

The Final Step is to add the following commands to the start-up script (Administration tab - then Commands). The sleep value can be adjusted, but 10 is long enough for most USB Harddrives/routers:

sleep 10
/opt/etc/init.d/rc.unslung start
在这里插入图片描述

四、安装CUPS

然后我就迫不及待的输入的命令,结果得到我我梦寐以求的结果了

root@DD-WRT:/opt# opkg install cups
Installing cups (2.2.12-2a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/cups_2.2.12-2a_mips-3.4.ipk
Installing zlib (1.2.13-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/zlib_1.2.13-1_mips-3.4.ipk
Installing libpng (1.6.39-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libpng_1.6.39-1_mips-3.4.ipk
Installing libjpeg-turbo (2.1.4-2) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libjpeg-turbo_2.1.4-2_mips-3.4.ipk
Installing libatomic (8.4.0-11) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libatomic_8.4.0-11_mips-3.4.ipk
Installing libusb-1.0 (1.0.26-3) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libusb-1.0_1.0.26-3_mips-3.4.ipk
Installing libexpat (2.5.0-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libexpat_2.5.0-1_mips-3.4.ipk
Installing libdbus (1.13.18-12) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libdbus_1.13.18-12_mips-3.4.ipk
Installing dbus (1.13.18-12) to root...
Downloading http://bin.entware.net/mipssf-k3.4/dbus_1.13.18-12_mips-3.4.ipk
Installing libintl-full (0.21.1-2) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libintl-full_0.21.1-2_mips-3.4.ipk
Installing libavahi-dbus-support (0.8-7a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libavahi-dbus-support_0.8-7a_mips-3.4.ipk
Installing libdaemon (0.14-5) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libdaemon_0.14-5_mips-3.4.ipk
Installing avahi-dbus-daemon (0.8-7a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/avahi-dbus-daemon_0.8-7a_mips-3.4.ipk
Installing libavahi-client (0.8-7a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libavahi-client_0.8-7a_mips-3.4.ipk
Installing libiconv-full (1.17-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libiconv-full_1.17-1_mips-3.4.ipk
Installing libcups (2.2.12-2a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libcups_2.2.12-2a_mips-3.4.ipk
Configuring libexpat.
Configuring libdbus.
Configuring dbus.
Configuring libintl-full.
Configuring libavahi-dbus-support.
Configuring libdaemon.
Configuring avahi-dbus-daemon.
Configuring zlib.
Configuring libpng.
Configuring libjpeg-turbo.
Configuring libatomic.
Configuring libusb-1.0.
Configuring libavahi-client.
Configuring libiconv-full.
Configuring libcups.
Configuring cups.

没有报错,顺利安装完成,感觉实在是太兴奋了,几天的时间终于没有白费,接下来就是配置一下就可以安装打印机了。

本想着下面就顺利了, 没想到一个又一个坑在等着我,cups服务启不来。
明明提示启动ok,但找不到进程。
本想查日志,但无论你怎么重启,log里面毛都没一根。
后来通过查系统日志才找到原因:先在【服务】里面开启系统日志,再次重启下cups服务,再到【状态】-【系统日志】里面查看,标红的就是报错。提示已经很显示了,就是用户组不对。
在这里插入图片描述

在这里插入图片描述
简单介绍一下CUPS相关的配置,以下是引用地址:https://it.cha138.com/tech/show-138757.html

.在cups服务器中,进入/etc/cups
目录下,可以看到如图4所示的cupsd.conf和cupsd.conf.default两个文件cupsd.conf和cupsd.conf.default的内容其实是一样的,我把cupsd.conf.default文件理解为cupsd.conf文件的备份。
在上述代码中:

a.把"Listen localhost:631"前加"#"注释掉。然后在下面另起一行,写上:Listen 0.0.0.0:631

意思为:请在631端口监听所有的主机连接。

b.把"Browsing off"前加"#"注释掉。然后在下面另起一行,写上:Browsing on

意思为:打开局域网共享。

c.在"BrowseOrder allow,deny"中另起一行,写上:allow 172.16.54.*(这里写上你共享任务的网段)

意思为:设定共享任务的网段

在上述代码中:

a.在" Order allow,deny"后,另起一行,写上:allow 172.16.54.*

意思为:设定只有IP为 172.16.54.* 的客户机才能访问此服务器

b.在"<Location /admin> Order allow,deny"后,另起一行,写上:allow 172.16.54.88

意思为:设定只有IP为 172.16.54.88 的客户机才能访问此服务器的管理界面

在" Order
allow,deny"后,另起一行, 写上:allow 172.16.54.*

意思为:设定IP为 172.16.54.* 的客户机只能进行 Create-Job Print-Job Print-URI
Validate-Job的任务。

使用以下命令重启cups服务
sudo restart cups

五、修改CUPS配置

找到 /opt/etc/cups/cups-files.conf

这个文件的19行,
把SystemGroup lpadmin sys root改成SystemGroup root root root
在这里插入图片描述

六、启动CUPS服务

再重启OK了,ps一下终于看到了可爱的cups进程。
在这里插入图片描述

还是访问不了页面,应该是权限问题了,因为我通过netstat可以看到631端口已开启监听。
在这里插入图片描述
在cupsd.conf文件里面,需要修改以下内容
1、Listen localhost:631改为Listen 0.0.0.0:631

2、在以下Location 等标签里面添加一行: Allow all

# Restrict access to the server...
<Location />
  Order allow,deny
  Allow all
</Location>

# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
  Allow all
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow all
</Location>

# Restrict access to log files...
<Location /admin/log>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow all
</Location>

修改保存后,重启一下服务,即可通过任意网段访问到界面了
在这里插入图片描述

以前在openwrt下面可以查看usb设备的,现在lsusb命令用不了,需要安装一个包usbutils

root@DD-WRT:~# opkg install usbutils
Installing usbutils (014-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/usbutils_014-1_mips-3.4.ipk
Installing libevdev (1.13.0-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libevdev_1.13.0-1_mips-3.4.ipk
Installing libudev-zero (0.4.8-3) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libudev-zero_0.4.8-3_mips-3.4.ipk
Configuring libevdev.
Configuring libudev-zero.
Configuring usbutils.
root@DD-WRT:~# lsusb
Bus 001 Device 007: ID 03f0:042a Hewlett-Packard HP LaserJet Professional M1136 MFP
Bus 001 Device 006: ID 1ba0:1131 Jolimark USBPrinter
Bus 001 Device 005: ID 1a40:0101  USB 2.0 Hub
Bus 001 Device 004: ID 6868:0500 Printer Printer
Bus 001 Device 003: ID 0951:1666 Kingston DataTraveler 3.0
Bus 001 Device 002: ID 1a40:0101  USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux 3.18.140-d5 ehci_hcd Atheros AR91xx built-in EHCI controller

其它查找usb设备的方式可以按这个链接来操作:https://www.cnblogs.com/zongzi10010/p/10764125.html

root@DD-WRT:~# dmesg | grep usb
<6>[   47.480000] usbcore: registered new interface driver usbfs
<6>[   47.480000] usbcore: registered new interface driver hub
<6>[   47.490000] usbcore: registered new device driver usb
<6>[   47.920000] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
<6>[   47.930000] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
<6>[   47.940000] usb usb1: Product: Atheros AR91xx built-in EHCI controller
<6>[   47.940000] usb usb1: Manufacturer: Linux 3.18.140-d5 ehci_hcd
<6>[   47.950000] usb usb1: SerialNumber: platform
<6>[   48.320000] usb 1-1: new high-speed USB device number 2 using ar71xx-ehci
<6>[   48.470000] usb 1-1: New USB device found, idVendor=1a40, idProduct=0101
<6>[   48.470000] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
<6>[   48.480000] usb 1-1: Product: USB 2.0 Hub
<6>[   48.810000] usb 1-1.1: new high-speed USB device number 3 using ar71xx-ehci
<6>[   48.940000] usb 1-1.1: New USB device found, idVendor=0951, idProduct=1666
<6>[   48.940000] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[   48.950000] usb 1-1.1: Product: DataTraveler 3.0
<6>[   48.960000] usb 1-1.1: Manufacturer: Kingston
<6>[   48.960000] usb 1-1.1: SerialNumber: 049226C3104121916914ICA9
<6>[   49.090000] usb 1-1.2: new full-speed USB device number 4 using ar71xx-ehci
<6>[   49.220000] usb 1-1.2: New USB device found, idVendor=6868, idProduct=0500
<6>[   49.220000] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[   49.230000] usb 1-1.2: Product: Printer
<6>[   49.240000] usb 1-1.2: Manufacturer: Printer
<6>[   49.240000] usb 1-1.2: SerialNumber: 0532E1228977
<6>[   49.400000] usb 1-1.4: new high-speed USB device number 5 using ar71xx-ehci
<6>[   49.530000] usb 1-1.4: New USB device found, idVendor=1a40, idProduct=0101
<6>[   49.530000] usb 1-1.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0
<6>[   49.540000] usb 1-1.4: Product: USB 2.0 Hub
<6>[   50.260000] usb 1-1.4.2: new full-speed USB device number 6 using ar71xx-ehci
<6>[   50.670000] usb 1-1.4.2: New USB device found, idVendor=1ba0, idProduct=1131
<6>[   50.680000] usb 1-1.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[   50.680000] usb 1-1.4.2: Product: USBPrinter
<6>[   50.690000] usb 1-1.4.2: Manufacturer: Jolimark
<6>[   50.690000] usb 1-1.4.2: SerialNumber: 18210087SF
<6>[   50.740000] usb-storage 1-1.1:1.0: USB Mass Storage device detected
<6>[   50.750000] scsi host0: usb-storage 1-1.1:1.0
<6>[   50.750000] usb-storage 1-1.2:1.1: USB Mass Storage device detected
<6>[   50.770000] scsi host1: usb-storage 1-1.2:1.1
<6>[   50.770000] usbcore: registered new interface driver usb-storage
<6>[   50.820000] usb 1-1.4.3: new high-speed USB device number 7 using ar71xx-ehci
<6>[   50.950000] usb 1-1.4.3: New USB device found, idVendor=03f0, idProduct=042a
<6>[   50.960000] usb 1-1.4.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[   50.960000] usb 1-1.4.3: Product: HP LaserJet Professional M1136 MFP
<6>[   50.970000] usb 1-1.4.3: Manufacturer: Hewlett-Packard
<6>[   50.980000] usb 1-1.4.3: SerialNumber: 000000000QH4HPPWSI1c
<6>[   51.010000] usb-storage 1-1.4.3:1.0: USB Mass Storage device detected
<6>[   51.020000] scsi host2: usb-storage 1-1.4.3:1.0
root@DD-WRT:~# lsusb 
Bus 001 Device 007: ID 03f0:042a Hewlett-Packard HP LaserJet Professional M1136 MFP
Bus 001 Device 006: ID 1ba0:1131 Jolimark USBPrinter
Bus 001 Device 005: ID 1a40:0101  USB 2.0 Hub
Bus 001 Device 004: ID 6868:0500 Printer Printer
Bus 001 Device 003: ID 0951:1666 Kingston DataTraveler 3.0
Bus 001 Device 002: ID 1a40:0101  USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux 3.18.140-d5 ehci_hcd Atheros AR91xx built-in EHCI controller

可以看到我的三台打印机都已经有了,但是我在管理界面里面还是发现不了打印机
在这里插入图片描述
原来是USB设备没有执行权限,那就给USB设备增加权限吧

root@DD-WRT:/dev# chmod -R 777 /dev/

七、添加打印机

再进入添加打印机页面,就可以看到两台打印机了,接下来的步骤就很简单不详细介绍了

在这里插入图片描述

八、显示不了HP打印机和其它问题

但还有一台怎么没有出现, 真是莫名其妙呀,坑也太多了吧, 我不由得叹一声命是真苦呀。

经过几天研究,那台HP 1136的打印机还是无法识别出来, 我也无奈,不知道什么原因引起的,如果哪位好心大佬能告知我一下, 将不胜感激。

附上我的摸索经过,用系统的lsusb可以看到我这台打印机,看看能不能分析出来一些问题

root@DD-WRT:/opt/lib/cups/backend# lsusb 
Bus 001 Device 012: ID 03f0:042a Hewlett-Packard HP LaserJet Professional M1136 MFP
Bus 001 Device 011: ID 1ba0:1131 Jolimark USBPrinter
Bus 001 Device 010: ID 1a40:0101  USB 2.0 Hub
Bus 001 Device 009: ID 6868:0500 Printer Printer
Bus 001 Device 008: ID 0951:1666 Kingston DataTraveler 3.0
Bus 001 Device 007: ID 1a40:0101  USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux 3.18.140-d5 ehci_hcd Atheros AR91xx built-in EHCI controller

可以看出来系统已经正常识别了吧,但用CUPS的后端程序USB执行一下看到能正常看到7个usb设备, 但是只识别出2台打印机来。

root@DD-WRT:/opt/lib/cups/backend# ls
dnssd   hp      http    ipp     lpd     snmp    socket  usb
root@DD-WRT:/opt/lib/cups/backend# ./usb 
DEBUG: Loading USB quirks from "/opt/share/cups/usb".
DEBUG: Loaded 95 quirks.
DEBUG: list_devices
DEBUG: libusb_get_device_list=7
DEBUG2: Printer found with device ID: MFG:Jolimark ;CMD:ESC/P2K;MDL:FP-630K+;CLS:PRINTER;DES:Jolimark FP-630K+;CID:Jolimark DMP24;SN:1 Device URI: usb://Jolimark/FP-630K+?serial=18210087SF
direct usb://Jolimark/FP-630K+?serial=18210087SF "Jolimark FP-630K+" "Jolimark FP-630K+" "MFG:Jolimark ;CMD:ESC/P2K;MDL:FP-630K+;CLS:PRINTER;DES:Jolimark FP-630K+;CID:Jolimark DMP24;SN:  1" ""
DEBUG2: Printer found with device ID:  Device URI: usb://Unknown/Printer?serial=0532E1228977
direct usb://Unknown/Printer?serial=0532E1228977 "Unknown" "Unknown" "" ""

root@DD-WRT:/opt/lib/cups/backend# ll /dev/usb*
crwxrwxrwx    1 root     root      189,   1 Jan  1 08:00 /dev/usbdev1.2
crwxrwxrwx    1 root     root      189,   0 Jan  1 08:00 /dev/usbdev1.1
crwxrwxrwx    1 root     root      189,   0 Jan  1 08:00 /dev/usb1
crwxrwxrwx    1 root     root      189,   2 Jan  1 08:00 /dev/usbdev1.3
crwxrwxrwx    1 root     root      189,   4 Jan  1 08:00 /dev/usbdev1.5
crwxrwxrwx    1 root     root      189,   3 Jan  1 08:00 /dev/usbdev1.4
crwxrwxrwx    1 root     root      189,   5 Jan  1 08:00 /dev/usbdev1.6
crwxrwxrwx    1 root     root      189,   6 Jan  1 08:25 /dev/usbdev1.7
crwxrwxrwx    1 root     root      189,   7 Jan  1 08:25 /dev/usbdev1.8
crwxrwxrwx    1 root     root      189,   9 Jan  1 08:25 /dev/usbdev1.10
crwxrwxrwx    1 root     root      189,  11 Jan  1 08:25 /dev/usbdev1.12
crwxrwxrwx    1 root     root      189,   8 Jan  1 09:48 /dev/usbdev1.9
crwxrwxrwx    1 root     root      189,  10 Jan  1 09:48 /dev/usbdev1.11




root@DD-WRT:/opt/lib/cups/backend# dmesg | grep usb
<6>[   39.390000] usbcore: registered new interface driver usblp
<6>[   39.600000] usb 1-1.4: New USB device found, idVendor=1a40, idProduct=0101
<6>[   39.600000] usb 1-1.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0
<6>[   39.610000] usb 1-1.4: Product: USB 2.0 Hub
<6>[   39.970000] usb 1-1.4.2: new full-speed USB device number 6 using ar71xx-ehci
<6>[   40.100000] usb 1-1.4.2: New USB device found, idVendor=1ba0, idProduct=1131
<6>[   40.110000] usb 1-1.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[   40.110000] usb 1-1.4.2: Product: USBPrinter
<6>[   40.120000] usb 1-1.4.2: Manufacturer: Jolimark
<6>[   40.120000] usb 1-1.4.2: SerialNumber: 18210087SF
<6>[   40.270000] usblp 1-1.4.2:1.0: usblp1: USB Bidirectional printer dev 6 if 0 alt 0 proto 2 vid 0x1BA0 pid 0x1131
<6>[ 1533.940000] usb 1-1: USB disconnect, device number 2
<6>[ 1533.940000] usb 1-1.1: USB disconnect, device number 3
<6>[ 1534.010000] usb 1-1.2: USB disconnect, device number 4
<6>[ 1534.010000] usblp0: removed
<6>[ 1534.020000] usb 1-1.4: USB disconnect, device number 5
<6>[ 1534.030000] usb 1-1.4.2: USB disconnect, device number 6
<6>[ 1534.030000] usblp1: removed
<6>[ 1534.540000] usb 1-1: new high-speed USB device number 7 using ar71xx-ehci
<6>[ 1534.690000] usb 1-1: New USB device found, idVendor=1a40, idProduct=0101
<6>[ 1534.690000] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
<6>[ 1534.700000] usb 1-1: Product: USB 2.0 Hub
<6>[ 1535.040000] usb 1-1.1: new high-speed USB device number 8 using ar71xx-ehci
<6>[ 1535.170000] usb 1-1.1: New USB device found, idVendor=0951, idProduct=1666
<6>[ 1535.170000] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[ 1535.180000] usb 1-1.1: Product: DataTraveler 3.0
<6>[ 1535.190000] usb 1-1.1: Manufacturer: Kingston
<6>[ 1535.190000] usb 1-1.1: SerialNumber: 049226C3104121916914ICA9
<6>[ 1535.280000] usb-storage 1-1.1:1.0: USB Mass Storage device detected
<6>[ 1535.290000] scsi host2: usb-storage 1-1.1:1.0
<6>[ 1535.390000] usb 1-1.2: new full-speed USB device number 9 using ar71xx-ehci
<6>[ 1535.930000] usb 1-1.2: New USB device found, idVendor=6868, idProduct=0500
<6>[ 1535.940000] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[ 1535.950000] usb 1-1.2: Product: Printer
<6>[ 1535.950000] usb 1-1.2: Manufacturer: Printer
<6>[ 1535.950000] usb 1-1.2: SerialNumber: 0532E1228977
<6>[ 1535.970000] usblp 1-1.2:1.0: usblp0: USB Bidirectional printer dev 9 if 0 alt 0 proto 2 vid 0x6868 pid 0x0500
<6>[ 1535.980000] usb-storage 1-1.2:1.1: USB Mass Storage device detected
<6>[ 1536.270000] scsi host3: usb-storage 1-1.2:1.1
<6>[ 1536.380000] usb 1-1.4: new high-speed USB device number 10 using ar71xx-ehci
<6>[ 1536.980000] usb 1-1.4: New USB device found, idVendor=1a40, idProduct=0101
<6>[ 1536.990000] usb 1-1.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0
<6>[ 1537.000000] usb 1-1.4: Product: USB 2.0 Hub
<6>[ 1537.330000] usb 1-1.4.2: new full-speed USB device number 11 using ar71xx-ehci
<6>[ 1537.810000] usb 1-1.4.2: New USB device found, idVendor=1ba0, idProduct=1131
<6>[ 1537.820000] usb 1-1.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[ 1537.820000] usb 1-1.4.2: Product: USBPrinter
<6>[ 1537.830000] usb 1-1.4.2: Manufacturer: Jolimark
<6>[ 1537.830000] usb 1-1.4.2: SerialNumber: 18210087SF
<6>[ 1538.040000] usblp 1-1.4.2:1.0: usblp1: USB Bidirectional printer dev 11 if 0 alt 0 proto 2 vid 0x1BA0 pid 0x1131
<6>[ 1538.130000] usb 1-1.4.3: new high-speed USB device number 12 using ar71xx-ehci
<6>[ 1538.260000] usb 1-1.4.3: New USB device found, idVendor=03f0, idProduct=042a
<6>[ 1538.260000] usb 1-1.4.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[ 1538.270000] usb 1-1.4.3: Product: HP LaserJet Professional M1136 MFP
<6>[ 1538.280000] usb 1-1.4.3: Manufacturer: Hewlett-Packard
<6>[ 1538.280000] usb 1-1.4.3: SerialNumber: 000000000QH4HPPWSI1c
<6>[ 1538.430000] usb-storage 1-1.4.3:1.0: USB Mass Storage device detected
<6>[ 1538.450000] scsi host4: usb-storage 1-1.4.3:1.0
<6>[ 6508.480000] usblp1: removed
<6>[ 6508.490000] usblp 1-1.4.2:1.0: usblp1: USB Bidirectional printer dev 11 if 0 alt 0 proto 2 vid 0x1BA0 pid 0x1131
<6>[ 6508.500000] usblp0: removed
<6>[ 6508.510000] usblp 1-1.2:1.0: usblp0: USB Bidirectional printer dev 9 if 0 alt 0 proto 2 vid 0x6868 pid 0x0500

root@DD-WRT:/opt/lib/cups/backend# lpinfo -v
network ipp
network http
network socket
network lpd
direct hp
direct usb://Jolimark/FP-630K+?serial=18210087SF
direct usb://Unknown/Printer?serial=0532E1228977

偶尔还会出现一些问题,突然添加打印机页面显示服务异常,有可能是动了USB设备,按道理应该USB打印机支持插拔的吧,打开日志显示以下内容:

W [01/Jan/1970:08:01:16 +0800] CreateProfile failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files
W [01/Jan/1970:08:01:16 +0800] CreateProfile failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files
W [01/Jan/1970:08:01:16 +0800] CreateDevice failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files

但是cupsd的进程与631端口还在,必须要重启服务才能恢复。

九、放弃dd-wrt

以上两个问题无法解决,在考虑是否要更换一个固件了,要是有谁能帮忙搞定,万分感谢。

十、重刷openwrt

第一次没有刷openwrt不是我不喜欢它, 而是一拿到这个花40块钱在闲鱼上买的4300我就已经刷过了,而且刷了很多个openwrt版本,但有一个问题是,找不到cups包,当你信心满满地输入,opkg install cups时, 会提示你根本就找不到这个包,后来几番搜索才知道,openwrt已经放弃了cups的支持了, 转而推荐用p910d做打印服务,我在8年前就用过那玩意,对多台打印机支持不好,不知道现在解决了没有,关键是对外网直接开放9100端口后,会被外网扫描端口,导致打印机经常打印出来一些莫名其妙的乱码,头疼不已,纸张也错乱,浪费一大包纸不说, 后面也不好继续打,所以坚决不再碰p910d了。反观cups对USB打印机的支持也好,可以随意插拔不用重启服务,也可以对外网开放631端口不会乱打印出乱码,因为我有远程打印的需求我才特意搞了个这个打印服务器。
当我重新转回openwrt时,首先要面对的是cups包的问题,我当时找到过网上放出来已经编译出来的包,也试过了安装不上去,我想着再试下看看,实在不行就下载源码自己编译一个吧, 应该不是什么多难的事情了。
当我再次重新下载好一个包,放上去安装时,诶, 他可以了,提示安装说缺少什么包,那就简单了,直接全部下载下来给他放上去,竟然安装成功了。这把我给高兴坏了,也不知道为什么第一次没有安装成功,难道下错架构了,不应该呀, 我看着来了,不管了,这下反正是可以了,省得去自己编译。

openwrt版本的固件包是:openwrt-19.07.0-ar71xx-nand-wndr4300-ubi-factory
下载地址:https://archive.openwrt.org/releases/19.07.0/targets/ar71xx/nand/openwrt-19.07.0-ar71xx-nand-wndr4300-ubi-factory.img
在这里插入图片描述

打开WNDR4300路由openwrt主页面可以看到的CUP是Atheros AR9344 rev 2,属于mips架构的,所以下载的包要选mips下面的
下载的CUPS包地址:https://gitee.com/ytwl333/openwrt-musl-cups/tree/master/mips
在这里插入图片描述
要注意作者的说明只适应于 LEDE / OPENWRT 18.06 / OPENWRT 19.07 的版本,所以openwrt版本不能太新了。

最后刷回OPENWRT后,刚开始也识别不了,但要安装一些包,安装包如下:

root@OpenWrt:/dev/usb# opkg install kmod-usb-ohci kmod-usb-uhci kmod-usb2 kmod-usb-uhci usbutils hotplug2

再试试看, HP1136的打印机终于识别出来了,泪漰呀, 再次感叹一下还是OPENWRT方便点,要什么包基本都有,dd-wrt下面很多包都没有,得依赖于entware。
在这里插入图片描述

还有一个因为我把打印机重启了一下, 有可能也是关键吧,暴汗了!

最后提醒一下:kmod-usb-core 这个包千万不能安装,如果系统有安装要卸载掉,有网友曾经在帖子里面提过这个包与cups会有冲突,经过我的实际使用,会不断的在/dev/下面创建一个usb的目录,然后在里面生成lp0、lp1、 lp2。。。 这就是这个包识别出来的打印机

root@OpenWrt:~# ll /dev/usb/
crw-------    1 root     root      189,   3 Aug 30 09:40 lp0
crw-------    1 root     root      189,   5 Aug 30 09:33 lp1
crw-------    1 root     root      189,   6 Aug 30 09:40 lp2

同时会在dmesg里面不断的remove 这些lp0 lp1,造成CUPS的打印任务很不稳定,有时可以有时不行。

root@OpenWrt:~# dmesg | grep usb
。。。。。。中间省略。。。。。。。
<6>[ 6508.480000] usblp1: removed
<6>[ 6508.490000] usblp 1-1.4.2:1.0: usblp1: USB Bidirectional printer dev 11 if 0 alt 0 proto 2 vid 0x1BA0 pid 0x1131
<6>[ 6508.500000] usblp0: removed
<6>[ 6508.510000] usblp 1-1.2:1.0: usblp0: USB Bidirectional printer dev 9 if 0 alt 0 proto 2 vid 0x6868 pid 0x0500

用下面的命令卸载掉之后,dmesg 里面就不再有usblp1: removed 的记录了, /dev下面也没有usb这个目录了。

root@OpenWrt:~# opkg remove kmod-usb-core
No packages removed.

以下内容是关于包冲突的与usb权限问题的详细介绍,引用自:https://oldwiki.archive.openwrt.org/doc/howto/cups.server?s%5B%5D=cups
在这里插入图片描述

USB printers notes and throubleshooting
Backfire: There may be a problem interfacing with USB printers if usb-printers kernel module is also loaded. These conflict with the cups-provided USB support. There are plenty of bugs and one working solution is as follows:
Remove usblp support: opkg remove kmod-usb-printer
Edit user and group in /etc/cups/cupsd.conf from User Nobody/Group Nogroup to User root/Group root
Change ACL on /usr/lib/cups/backend/usb to 700 (chmod 700 /usr/lib/cups/backend/usb). This changes the behaviour of cups, which normally tries to execute the backend through a user account other than root. This forces the backend to run as root from cups.
Finally, it should be possible to add printers through the web page http://host:631/admin or manually. The USB device name cannot be displayed through lpinfo but can instead be listed by running /usr/lib/cups/backend/usb as root.
There is a problem with the permissions on USB printers not being writable by nobody, which is what CUPS expects. An alternative is to make a wrapper backend that executes a sudo script which does find /proc/bus/usb -type f -exec chmod +rw {} ;. Point being, there is a permission problem between USB/udev and CUPS preventing USB-printers from working. Also, CUPS is removing support or has a lot of issues currently with usblp support.
In Attitude Adjustment, you just need to change ACL on /usr/lib/cups/backend/usb to 700 (chmod 700 /usr/lib/cups/backend/usb). This changes the behaviour of cups, which normally tries to execute the backend through a user account other than root. This forces the backend to run as root from cups, the reason have been said above.

这可能就是引起我之前DD-WRT下查看不到HP打印机的原因,当然还有包的原因。

为了避免打印任务空间不足,按如下方法可以修改存放目录,
以下引用自:http://mattie47.com/getting-cups-working-on-openwrt/

Configure CUPs to use your USB device for print jobs

Time to re-edit your CUPs config. Either use VI or your text editor of
choice and edit your cupsd.conf file:

nano /etc/cups/cupsd.conf

Change: RequestRoot /var/cups TempDir /var/cups

I changed both to /usb/cups/ since as you can see in the above screen
cap I mounted my usb drive as /usb

You probably should restart CUPs now.Do this by: root@OpenWrt:~#
/etc/init.d/cupsd restart

查看一下系统磁盘空间情况,cups是默认是存放在/var/cups里面的,只有6.5M了,发现/tmp里面的空间比较充足,但重启后会清空掉,我想应该也问题不大,很少会去重启路由器吧, 基本上是全年7*24的。

root@OpenWrt:/tmp# df -hT
Filesystem           Type            Size      Used Available Use% Mounted on
/dev/root            squashfs        2.5M      2.5M         0 100% /rom
tmpfs                tmpfs          60.7M      1.8M     58.9M   3% /tmp
/dev/ubi0_1          ubifs          13.8M      6.5M      6.6M  50% /overlay
overlayfs:/overlay   overlay        13.8M      6.5M      6.6M  50% /
tmpfs                tmpfs         512.0K         0    512.0K   0% /dev

把cupsd.conf里的 RequestRoot /var/cups与TempDir /var/cups参数两个参数都改成 /tmp/cups

RequestRoot /tmp/cups
User root
Group root
RIPCache auto
TempDir /tmp/cups

/etc/init.d/cupsd restart

十一、部署FTP服务

原来的openwrt系统上是没有【挂载点】的这个菜单的
在这里插入图片描述
为了让他出现这个菜单,需要安装以下包,有好些包前面都已经安装过的,为了单独只部署FTP服务就一起放上来了

opkg update
opkg install block-mount

opkg install kmod-usb-ohci #安装usbohci控制器驱动
opkg install kmod-usb-uhci  #UHCI USB控制器
opkg install kmod-usb2 #安装usb2.0
opkg install kmod-usb-storage #安装usb存储设备驱动
opkg install usbutils #安装了这个后可以用lsusb


opkg install mount-utils #挂载卸载工具,使系统可以通过 UUID 进行挂载
opkg install ntfs-3g #挂载NTFS
opkg install kmod-fs-vfat #挂载FAT
opkg install kmod-fs-ext4:支持访问 ext4、ext3 分区
opkg install fdisk #硬盘分区管理工具
opkg install e2fsprogs
opkg install kmod-fs-ext4

opkg install lsblk:用于查看块设备
opkg install blockd:用于自动挂载

reboot  #重启一下很重要

执行完后发现还是没有, 不要着急,重启一下路由器,你再打开就会发现了。

再插上U盘,到【挂载点】的页面下面,点这上新增按钮,
在这里插入图片描述

我的U盘是exFAT格式的,必须要在高级设置里面选一下对应的文件系统,不然,上面已挂载的文件系统里面显示不出来,如果再显示不出来可以重启一下试试看。
在这里插入图片描述

重新换了一个SSD固态硬盘配个硬盘盒,发现识别不了
用以下命令查看下USB设备

root@OpenWrt:~# block info
/dev/mtdblock8: UUID="1189284585" VERSION="1" TYPE="ubi"
/dev/sda: UUID="6068-1A4B" VERSION="FAT12" TYPE="vfat"
/dev/ubi0_1: UUID="e4803315-fd88-4c8e-b475-1dd4320804f3" VERSION="w4r0" MOUNT="/overlay" TYPE="ubifs"
/dev/ubiblock0_0: UUID="cacf3d41-5a41d84f-a33d6f0c-1030920e" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"

root@OpenWrt:~# lsusb 
Bus 001 Device 004: ID 03f0:042a HP, Inc LaserJet M1132 MFP
Bus 001 Device 006: ID 152d:0578 JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 SATA 6Gb/s bridge
Bus 001 Device 003: ID 1ba0:1131  
Bus 001 Device 005: ID 6868:0500  
Bus 001 Device 002: ID 214b:7250  
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

root@OpenWrt:~# dmesg | grep usb
[    4.732708] usbcore: registered new interface driver usbfs
[    4.738356] usbcore: registered new interface driver hub
[    4.743902] usbcore: registered new device driver usb
[    5.292079] usb 1-1: new high-speed USB device number 2 using ehci-platform
[    5.832048] usb 1-1.1: new full-speed USB device number 3 using ehci-platform
[    6.082046] usb 1-1.2: new high-speed USB device number 4 using ehci-platform
[    6.332044] usb 1-1.3: new full-speed USB device number 5 using ehci-platform
[    6.582112] usb 1-1.4: new high-speed USB device number 6 using ehci-platform
[    9.746414] usb-storage 1-1.3:1.1: USB Mass Storage device detected
[    9.753623] scsi host0: usb-storage 1-1.3:1.1
[    9.758706] usbcore: registered new interface driver usb-storage


root@OpenWrt:~# fdisk -l

Disk /dev/sda: 3.26 MiB, 3407872 bytes, 832 sectors
Disk model: Disk 1.0        
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x6f20736b

Device     Boot      Start        End    Sectors  Size Id Type
/dev/sda1        778135908 1919645538 1141509631  4.3T 72 unknown
/dev/sda2        168689522 2104717761 1936028240  7.2T 65 Novell Netware 386
/dev/sda3       1869881465 3805909656 1936028192  7.2T 79 unknown
/dev/sda4                0 3637226495 3637226496 13.6T  d unknown

Partition table entries are not in disk order.


root@OpenWrt:~# cat /sys/kernel/debug/usb/devices 

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  1, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 4.14
S:  Manufacturer=Linux 4.14.162 ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=ehci-platform
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 4
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=214b ProdID=7250 Rev= 1.00
S:  Product=USB2.0 HUB
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=256ms

T:  Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=1ba0 ProdID=1131 Rev= 1.00
S:  Manufacturer=Jolimark
S:  Product=USBPrinter
S:  SerialNumber=18210087SF
C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=  2mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=07(print) Sub=01 Prot=02 Driver=(none)
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms

T:  Bus=01 Lev=02 Prnt=02 Port=01 Cnt=02 Dev#=  4 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=03f0 ProdID=042a Rev= 1.00
S:  Manufacturer=Hewlett-Packard
S:  Product=HP LaserJet Professional M1136 MFP
S:  SerialNumber=000000000QH4HPPWPR1a
C:* #Ifs= 3 Cfg#= 1 Atr=c0 MxPwr= 98mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=07(print) Sub=01 Prot=02 Driver=(none)
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=10 Driver=(none)
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=83(I) Atr=03(Int.) MxPS=   8 Ivl=256ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

T:  Bus=01 Lev=02 Prnt=02 Port=02 Cnt=03 Dev#=  5 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=6868 ProdID=0500 Rev= 1.00
S:  Manufacturer=Printer
S:  Product=Printer
S:  SerialNumber=0532E1228977
C:* #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=07(print) Sub=01 Prot=02 Driver=(none)
E:  Ad=84(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=04 Dev#=  6 Spd=480  MxCh= 0
D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=152d ProdID=0578 Rev= 2.15
S:  Manufacturer=JMicron
S:  Product=USB to ATA/ATAPI Bridge
S:  SerialNumber=0123456789ABCDEF
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none)
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:  If#= 0 Alt= 1 #EPs= 4 Cls=08(stor.) Sub=06 Prot=62 Driver=(none)
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

中间安装了几个包, 都起没起来作用

始终找不到我的那个移动硬盘,悲催了。。

待续

找了个群,在里面请教了一个名叫MK的大佬给我请了一条光辉大道
在这里插入图片描述
按照这个把包一装,立马药到病除,搞定了,真是神人也,膜拜一下大佬吧
在这里插入图片描述
如果不是windows下的磁盘格式的话, 挂载时不用加这个选项-o iocharset=utf8,不然会提示命令失败,挂载不上去,如果在界面上操作的话, 填了这个参数也会挂载不上。

root@OpenWrt:/mnt# mount -o iocharset=utf8 /dev/sda1 /mnt/sda1/
mount: /mnt/sda1: wrong fs type, bad option, bad superblock on /dev/sda1, missing codepage or helper program, or other error.
root@OpenWrt:/mnt# mount /dev/sda1 /mnt/sda1/

如果是NFTS\exfat\vfat等windows下的格式,必须要加这个iocharset=utf8参数,不然中文会乱码,并且要指定文件系统,不能用auto。
在这里插入图片描述

换了个U盘,又无法正常识别了,找不到我的新U盘

root@OpenWrt:/mnt# block info
/dev/mtdblock8: UUID="1189284585" VERSION="1" TYPE="ubi"
/dev/sda: UUID="6068-1A4B" VERSION="FAT12" TYPE="vfat"
/dev/ubi0_1: UUID="e4803315-fd88-4c8e-b475-1dd4320804f3" VERSION="w4r0" MOUNT="/overlay" TYPE="ubifs"
/dev/ubiblock0_0: UUID="cacf3d41-5a41d84f-a33d6f0c-1030920e" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"

运行dmesg可以看到以下错误

[57751.256373] sd 0:0:0:0: [sdb] Unaligned partial completion (resid=64, sector_sz=512)
[57751.264282] sd 0:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[57751.272636] sd 0:0:0:0: [sdb] tag#0 Sense Key : 0x2 [current] 
[57751.278575] sd 0:0:0:0: [sdb] tag#0 <<vendor>>ASC=0xff <<vendor>>ASCQ=0xff 
[57751.285668] sd 0:0:0:0: [sdb] tag#0 CDB: opcode=0x28 28 00 00 00 10 00 00 00 08 00
[57751.293360] print_req_error: I/O error, dev sdb, sector 4096
[57751.301133] sd 0:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[57751.309512] sd 0:0:0:0: [sdb] tag#0 Sense Key : 0x2 [current] 
[57751.315450] sd 0:0:0:0: [sdb] tag#0 <<vendor>>ASC=0xff <<vendor>>ASCQ=0xff 
[57751.322543] sd 0:0:0:0: [sdb] tag#0 CDB: opcode=0x28 28 00 00 00 10 00 00 00 08 00
[57751.330258] print_req_error: I/O error, dev sdb, sector 4096
[57751.336022] Buffer I/O error on dev sdb, logical block 512, async page read
[57751.791162]  sdb: sdb1 sdb2
[57753.410371] print_req_error: I/O error, dev mtdblock4, sector 88
[57753.455091] print_req_error: I/O error, dev mtdblock4, sector 1008
[57753.461695] print_req_error: I/O error, dev mtdblock4, sector 1008
[57753.467979] Buffer I/O error on dev mtdblock4, logical block 126, async page read

在windows下发现这个U盘其实是个GENERIC SD/MMC USB设备,个人觉得也就是SD卡吧,是不是U盘跟SD卡需要的驱动不一样的呢, 我尝试安装一个驱动看看,查下看看有没有关于SD、MMC的驱动。在包管理里面输入MMC就可以看到以下两个包,关于MMC/SD的,不管它,装上试试
在这里插入图片描述
果然装上就OK了,输入block info 可以看到显示出正常的分区了。

root@OpenWrt:~# block info
/dev/mtdblock8: UUID="1189284585" VERSION="1" TYPE="ubi"
/dev/sda: UUID="6068-1A4B" VERSION="FAT12" TYPE="vfat"
/dev/sdb1: UUID="FEC2DC11C2DBCC51" LABEL="大白菜" MOUNT="/mnt/sdb" TYPE="ntfs"
/dev/sdb2: UUID="0CFF-180C" LABEL="EFI" VERSION="FAT32" TYPE="vfat"
/dev/ubi0_1: UUID="e4803315-fd88-4c8e-b475-1dd4320804f3" VERSION="w4r0" MOUNT="/overlay" TYPE="ubifs"
/dev/ubiblock0_0: UUID="cacf3d41-5a41d84f-a33d6f0c-1030920e" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"

挂载也出现问题

The disk contains an unclean file system (0, 0).
The file system wasn't safely closed on Windows. Fixing.
ntfs_attr_pread_i: ntfs_pread failed: I/O error
Failed to read NTFS $Bitmap: I/O error
NTFS is either inconsistent, or there is a hardware fault, or it's a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the 'dmraid' documentation
for more details.
Failed to sync device /dev/sdb1: I/O error
Failed to close volume /dev/sdb1: I/O error

换到页面上挂载再试试,发现可以了,新增挂载点后记得点保存执行哦。
在这里插入图片描述

安装与配置FTP服务

opkg install vsftpd

防火墙开启21端口,如果有需要,可以进行端口转发

vi /etc/vsftpd.conf

做出如下修改

anonymous_enable=YES    #允许匿名用户访问(必须)
anon_root=/mnt/sda1/anymous   	#匿名用户根目录(必须)
ftp_username=nobody     #定义匿名用户名(必须,否则用浏览器打开匿名时会一直要求输入用户名密码)
local_enable=YES        #允许本地用户登录(必须,否则会不让root账户登陆)
local_root=/            #本地用户主目录(必须,否则手机播放器登陆FTP会显示目录为空)

chown root:nogroup /mnt/anymous
chmod 557 /mnt/anymous

重启 vsftpd

/etc/init.d/vsftpd restart

FTP详细步骤请看这个链接:http://www.senlt.cn/article/121857261.html

如果文件名前面有空格,记得处理一下,把前面的空格删除再上传, 不然到时候用FTP有的软件取文件会有问题,但是samba却没有问题,以防万一, 要删除掉文件名最前面的空格。
部署完了在本地映射一下
在这里插入图片描述
当匿名访问时,往上放东西会提示这个, 我们需要看下怎么配置匿名访问权限
以下转自:https://www.python100.com/html/119296.html
在这里插入图片描述
在这里插入图片描述

十二、部署samba

1、安装三个包(samba36-server、 luci-app-samba 、luci-i18n-samba-zh-cn)
root@OpenWrt:/tmp# opkg install samba36-server luci-app-samba luci-i18n-samba-zh-cn

2、编辑配置文件
Samba服务的配置由两个文件组成,一是/etc/config/samba,二是/etc/samba/smb.conf.template,服务启动后会先读取一号文件,然后读取二号文件,生成/etc/samba/smb.conf文件,最后运行服务。

根据Samba服务读取配置的方法,需要更改上述的一、二号文件。这里直接给出模板配置,将模板直接覆盖原配置即可。操作如下。

在ssh窗口中输入vi /etc/config/samba,编辑一号文件。

config samba
        option name 'OpenWrt'
        option workgroup 'WORKGROUP'
        option description 'OpenWrt'
        option homes '1'

config sambashare
        option read_only 'no'
        option create_mask '777'
        option dir_mask '777'
        option guest_ok 'yes'
        option browseable 'yes'
        option name 'root'
        option users 'root'
        option path '/mnt/'		#这个为共享目录,根据具体情况来修改

在ssh窗口中输入vi /etc/config/smb.conf.template,编辑二号文件。

root@OpenWrt:/tmp# vi /etc/samba/smb.conf.template

可以直接复制以下内容到文件里面去即可,无需修改任何配置

[global]
        netbios name = |NAME|
        display charset = |CHARSET|
        interfaces = |INTERFACES|
        server string = |DESCRIPTION|
        unix charset = |CHARSET|
        workgroup = |WORKGROUP|
        browseable = yes
        deadtime = 30
        domain master = yes
        encrypt passwords = true
        enable core files = no
        guest account = nobody
        guest ok = yes
        #invalid users = root
        local master = yes
        load printers = no
        map to guest = Bad User
        max protocol = SMB2
        min receivefile size = 8192
        null passwords = yes
        obey pam restrictions = yes
        os level = 20
        passdb backend = smbpasswd
        preferred master = yes
        printable = no
        security = user
        smb encrypt = disabled
        smb passwd file = /etc/samba/smbpasswd
        socket options = TCP_NODELAY SO_RCVBUF=960000 SO_SNDBUF=960000
        syslog = 2
        use sendfile = yes
        use mmap = yes
        writeable = yes
        disable spoolss = yes
        host msdfs = no
        strict allocate = No

3、启动服务

root@OpenWrt:/tmp# /etc/init.d/samba restart

4、配置账号密码
/etc/samba/smb.conf.template文件中#invalid users = root,若取消该行注释,将不能使用root账号添加密码,这样就需要为samba服务单独添加账号,对个人用户来说比较麻烦,所以我直接使用root账号为samba服务添加密码

root@OpenWrt:/mnt/sdb# smbpasswd -a root
New SMB password:

5、配置访问目录与权限,可以直接在页面上进行管理,比较直观了
在这里插入图片描述

十三、将程序安装到外置U盘或硬盘

因为内存不够用了,所以要把程序安装到硬盘里面。
mkdir /mnt/sda1/packages/
echo dest usb /mnt/sda1/packages/ >> /etc/opkg.conf
opkg --dest usb install python
ln -s /mnt/sda1/packages/usr/bin/python /usr/bin/python

记住安装软件时不要漏了–dest usb,这样才会安装到U盘或硬盘上。

十四、部署Syncthing文件同步程序

首先要安装一些依赖包

opkg update
opkg install ca-bundle ca-certificates wget openssl-util

到下面网址下载对应的安装程序,要选择mips的
https://github.com/syncthing/syncthing/releases/latest

这是我下载的安装包链接
https://github.com/syncthing/syncthing/releases/download/v1.26.1/syncthing-linux-mips-v1.26.1.tar.gz
用FTP传上去后,解压到当前目录下面,要到放外置硬盘或U盘上面,内置空间已经不够用了。

部署Syncthing

1、解压下载的Syncthing软件包

root@OpenWrt:/mnt/sda1/packages# tar -xzvf syncthing-linux-mips-v1.26.1.tar.gz   //解压
root@OpenWrt:/mnt/sda1/packages# mv syncthing-linux-mips-v1.26.1 syncthing  		 //重新命名安装目录

2、将启动文件软链接到系统环境变量下

root@OpenWrt:~# ln -s /mnt/sda1/packages/syncthing/syncthing /usr/bin/syncthing 

3、运行Syncthing生成配置文件

root@OpenWrt:~# syncthing     //由于上一步已经将启动文件链接到了环境变量,这里直接执行即可,会在root的home目录下面创建一些配置,后期会以这些配置文件来启动程序
root@OpenWrt:~/.config/syncthing# ls
cert.pem          config.xml        config.xml.v0     csrftokens.txt    https-cert.pem    https-key.pem     index-v0.14.0.db  key.pem

要注意的是,用/etc/init.d/syncthing脚本启动时,创建配置文件的目录与直接输入syncthing来运行时生成的配置文件目录不一致,所以需要在/etc/init.d/syncthing脚本里面指定-home目录。

5、编辑配置文件

修改配置文件将127.0.0.1修改为0.0.0.0即可,默认只允许本地访问

root@OpenWrt:~#  vi ~/.config/syncthing/config.xml

十五、Openwrt设置syncthing开启自启动

1.在/etc/init.d/下编写service脚本

#!/bin/sh /etc/rc.common
START=99
STOP=15
 
start() {
  echo start
  #commands to launch syncthing, such as above
  syncthing -home="/root/.config/syncthing" >/dev/null &		#必须要指定-home目录,启动时如果没有的话会自动生成一些配置文件,用自启动时,默认的home目录会更改,所以必须要指定-home目录。
}
 
stop() {
  echo stop
  #commands to kill syncthing
  killall syncthing
}

这个脚本由sh来解释,/etc/rc.common做包装器,提供一些默认的命令。START=99,STOP=15指的是开机自启动的优先级,数字越大优先级越低,开机时优先级高的程序会先启动。

如果启动在boot期间,可以实现boot方法

rc.common模板,init脚本可用的命令有:

/etc/init.d/syncthing start         #启动脚本
/etc/init.d/syncthing stop          #停止服务
/etc/init.d/syncthing restart     #重启服务
/etc/init.d/syncthing reload         #重新加载配置文件,如果失败,重启服务
/etc/init.d/syncthing enable         #开启开机自启动
/etc/init.d/syncthing disable      #关闭开机自启动

2.添加权限

chmod +x /etc/init.d/syncthing

3.开机启动

 /etc/init.d/syncthing enable

十六、部署远程下载服务 远程下载工具

root@OpenWrt:~# opkg --dest usb install transmission-daemon-openssl
Installing transmission-daemon-openssl (3.00-4) to usb…
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/packages/transmission-daemon-openssl_3.00-4_mips_24kc.ipk
Installing libmbedtls12 (2.16.12-1) to usb…
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/base/libmbedtls12_2.16.12-1_mips_24kc.ipk
Installing libcurl4 (7.66.0-3) to usb…
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/base/libcurl4_7.66.0-3_mips_24kc.ipk
Installing libevent2-7 (2.1.11-1) to usb…
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/base/libevent2-7_2.1.11-1_mips_24kc.ipk
Installing libminiupnpc (2.1.20190408-2) to usb…
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/packages/libminiupnpc_2.1.20190408-2_mips_24kc.ipk
Installing libnatpmp (20150609-1) to usb…
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/packages/libnatpmp_20150609-1_mips_24kc.ipk
Configuring libmbedtls12.
Configuring libcurl4.
Configuring libevent2-7.
Configuring libminiupnpc.
Configuring libnatpmp.
Configuring transmission-daemon-openssl.
root@OpenWrt:~# opkg --dest usb install transmission-web-openssl
Unknown package ‘transmission-web-openssl’.
Collected errors:

  • opkg_install_cmd: Cannot install package transmission-web-openssl.
    root@OpenWrt:~# opkg --dest usb install transmission-web
    Installing transmission-web (3.00-4) to usb…
    Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/packages/transmission-web_3.00-4_all.ipk
    Configuring transmission-web.
    root@OpenWrt:~# opkg --dest usb install transmission-cli-openssl
    Installing transmission-cli-openssl (3.00-4) to usb…
    Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/packages/transmission-cli-openssl_3.00-4_mips_24kc.ipk
    Configuring transmission-cli-openssl.
    root@OpenWrt:~# opkg --dest usb install transmission-remote-openssl
    Installing transmission-remote-openssl (3.00-4) to usb…
    Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/packages/transmission-remote-openssl_3.00-4_mips_24kc.ipk
    Configuring transmission-remote-openssl.
    root@OpenWrt:~# opkg --dest usb install luci-app-transmission
    Installing luci-app-transmission (git-22.115.68448-712bc8e-1) to usb…
    Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/luci/luci-app-transmission_git-22.115.68448-712bc8e-1_all.ipk
    Installing luci-lib-ipkg (git-22.115.68448-712bc8e-1) to usb…
    Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/luci/luci-lib-ipkg_git-22.115.68448-712bc8e-1_all.ipk
    Configuring luci-lib-ipkg.
    Configuring luci-app-transmission.
    root@OpenWrt:~# opkg --dest usb install luci-i18n-transmission-zh-cn
    Installing luci-i18n-transmission-zh-cn (git-22.115.68448-712bc8e-1) to usb…
    Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/luci/luci-i18n-transmission-zh-cn_git-22.115.68448-712bc8e-1_all.ipk
    Configuring luci-i18n-transmission-zh-cn.
    root@OpenWrt:~# /etc/init.d/transmission enable
    -ash: /etc/init.d/transmission: not found
    root@OpenWrt:~# cd /mnt/sdb/
    21BLathe_W32_10.116.54N/ Android/ DCIM/ Movies/ Notifications/ Podcasts/ packages/
    Alarms/ DBC/ Download/ Music/ Pictures/ Ringtones/ public/
    root@OpenWrt:~# cd /mnt/sdb/packages/
    etc/ usr/
    root@OpenWrt:~# cd /mnt/sdb/packages/etc/
    config/ init.d/ sysctl.d/ uci-defaults/
    root@OpenWrt:~# cd /mnt/sdb/packages/etc/init.d/
    root@OpenWrt:/mnt/sdb/packages/etc/init.d# ls
    transmission
    root@OpenWrt:/mnt/sdb/packages/etc/init.d# /mnt/sdb/packages/etc/init.d/transmission enable
    root@OpenWrt:/mnt/sdb/packages/etc/init.d# /mnt/sdb/packages/etc/init.d/transmission start

root@OpenWrt:~# opkg install transmission-cli-mbedtls transmission-daemon-mbedtls transmission-remote-mbedtls transmission-web transmission-web-control luci-app-transmission luci-i18n-transmission-zh-cn
安装完进程页面提示错误
在这里插入图片描述

/usr/lib/lua/luci/template.lua:97: Failed to execute template ‘sysauth’.
A runtime error occurred: /usr/lib/lua/luci/template.lua:97: Failed to execute template ‘header’.
A runtime error occurred: /usr/lib/lua/luci/template.lua:97: Failed to execute template ‘themes/bootstrap/header’.
A runtime error occurred: [string “/usr/lib/lua/luci/view/themes/bootstrap/hea…”]:20: attempt to call field ‘node_childs’ (a nil value)
stack traceback:
[string “/usr/lib/lua/luci/view/themes/bootstrap/hea…”]:20: in main chunk
stack traceback:
[C]: in function ‘error’
/usr/lib/lua/luci/template.lua:97: in function ‘render’
/usr/lib/lua/luci/dispatcher.lua:755: in function ‘include’
[string “/usr/lib/lua/luci/view/header.htm”]:3: in main chunk
stack traceback:
[C]: in function ‘error’
/usr/lib/lua/luci/template.lua:97: in function ‘render’
/usr/lib/lua/luci/dispatcher.lua:755: in function ‘include’
[string “/usr/lib/lua/luci/view/sysauth.htm”]:1: in main chunk
stack traceback:
[C]: in function ‘error’
/usr/lib/lua/luci/template.lua:97: in function </usr/lib/lua/luci/template.lua:85>
(tail call): ?
(tail call): ?
/usr/lib/lua/luci/dispatcher.lua:984: in function ‘dispatch’
/usr/lib/lua/luci/dispatcher.lua:478: in function </usr/lib/lua/luci/dispatcher.lua:477>

网上搜索了一下可按如下来解决
opkg update
opkg install luci-theme-bootstrap
rm -r /tmp/luci-*

修改这个配置文件
在这里插入图片描述

root@OpenWrt:~# vi /root/.config/transmission-daemon/settings.json 

    "rpc-whitelist": "0.0.0.0,::1",
    "rpc-whitelist-enabled": false,

再重启一下服务

/etc/init.d/transmission stop
killall -9 transmission-daemon
transmission-daemon

十七、部署aria2远程下载

安装transmission完后,发现根本没速度,不知道什么原因,换个aria2试试看

root@OpenWrt:/etc/init.d# opkg install aria2 luci-app-aria2 luci-i18n-aria2-zh-cn ariang ca-bundle ca-certificates

重进管理页面,按如下配置一下,记得保存并应用。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
填写完F5刷新下页面,就可以连接上了

如果下载没有速度的话,需要配置一下列表
在【Aria2 - 设置】-【bt选项】- 【附加的 BT Tracker】里面填入https://trackerslist.com/#/zh?id=aria2这个链接里面的内容
在这里插入图片描述
这里面选一个点开后,把里面的内容复制过去填上就可以。然后就可以看到慢慢有速度了。

在PandoraBox下面,没有安装AriaNg的插件,软件包里也没有可以下载的
我们就在https://github.com/mayswind/AriaNg/releases/tag/1.3.7页面下载的最新版在这里插入图片描述
然后解压到路由器的/www/AriaNg目录下面,然后访问Pandorabox管理页面地址后面加上AriaNg就可以了,例如:http://192.168.1.1/AriaNg,即可打开管理页面。
在这里插入图片描述

十八、安装lnyx,更新3322动态域名

root@OpenWrt:~# opkg install lynx
root@OpenWrt:~# vi updateDNS #创建一个命令文件
lynx -mime_header -auth=用户名:密码 "http://members.3322.net/dyndns/update?system=dyndns&hostname=域名"
root@OpenWrt:~# chmod u+x updateDNS #添加执行权限
root@OpenWrt:~# crontab -e	#加入定时任务
* * * * * /root/updateDNS > /root/DNS.txt  #add by 3322DynDns
root@OpenWrt:~# /etc/init.d/cron restart #重启cron服务

简单写一下重置固件后的部署步骤

1、把主路由器的网线断了,把IP地址改成192.168.3.2,改完后发现路由器本身上不了网, 可能要把DNS与网关都要配一下,改完后要立马用192.168.3.2的地址去访问,否则会新修改的配置会回滚。
在这里插入图片描述

2、Ping下百度,能通的话就进行软件更新。

root@OpenWrt:~# ping www.baidu.com
PING www.baidu.com (183.2.172.42): 56 data bytes
64 bytes from 183.2.172.42: seq=0 ttl=52 time=10.141 ms
64 bytes from 183.2.172.42: seq=1 ttl=52 time=9.740 ms
^C
--- www.baidu.com ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 9.740/9.940/10.141 ms
root@OpenWrt:~# opkg update

3、安装中文界面包

root@OpenWrt:~# opkg install luci-i18n-base-zh-cn

4、安装FTP,

root@OpenWrt:~# opkg install vsftpd

5、安装完后什么配置都不用动, 但不要用SFTP协议, 改用FTP协议,21号端口连接上去,就可以传输文件了,把CUPS的包全部传上去。
在这里插入图片描述

在这里插入图片描述
后来发现要在配置文件中加入一行内容

root@OpenWrt:/mnt# vi /etc/vsftpd.conf
local_root=/   #要加入这一行,否则手机客户端连不上

安装cups,可能后面会有些报错,可以不用理会。

root@OpenWrt:~# cd cups/
root@OpenWrt:~/cups# ll -h
drwxr-xr-x    2 root     root        1.8K Dec  8 06:06 ./
drwxr-xr-x    1 root     root         224 Dec  8 06:06 ../
-rw-r--r--    1 root     root       15.9K Dec  8 06:06 cups-bjnp_2.0-1_mips_24kc.ipk
-rw-r--r--    1 root     root       10.9K Dec  8 06:06 cups-bsd_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root       88.8K Dec  8 06:06 cups-client_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root      143.4K Dec  8 06:06 cups-filters_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root       40.9K Dec  8 06:06 cups-locale-zh_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root       12.9K Dec  8 06:06 cups-ppdc_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root      803.5K Dec  8 06:06 cups_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root      567.7K Dec  8 06:06 libcups_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root       70.3K Dec  8 06:06 libcupscgi_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root       39.3K Dec  8 06:06 libcupsimage_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root       27.3K Dec  8 06:06 libcupsmime_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root      135.5K Dec  8 06:06 libcupsppdc_2.1.4-1_mips_24kc.ipk
-rw-r--r--    1 root     root       80.0K Dec  8 06:06 libpng_1.6.37-2_mips_24kc.ipk
-rw-r--r--    1 root     root         877 Dec  8 06:06 libpthread_1.1.24-2_mips_24kc.ipk
-rw-r--r--    1 root     root      376.1K Dec  8 06:06 libstdcpp6_7.4.0-2_mips_24kc.ipk
-rw-r--r--    1 root     root       25.2K Dec  8 06:06 libusb-1.0-0_1.0.22-2_mips_24kc.ipk
-rw-r--r--    1 root     root      238.7K Dec  8 06:06 usbutils_007-10_mips_24kc.ipk
-rw-r--r--    1 root     root       37.7K Dec  8 06:06 zlib_1.2.11-3_mips_24kc.ipk
root@OpenWrt:~/cups# opkg install *.ipk

安装完以上包, 修改cups配置,加入Allow all

root@OpenWrt:~/cups# vi /etc/cups/cupsd.conf

WebInterface yes  #这里改为yes

<Location /> 
Order Allow,Deny
#Allow From 127.0.0.1
#Allow From 192.168.1.0/24
Allow all        #加入这行
</Location>
                    
<Location /admin>      
AuthType Basic     
AuthClass System     
Order Allow,Deny     
#Allow From 127.0.0.1     
#Allow From 192.168.1.0/24
Allow all        #加入这行
</Location>

到页面上去重启一下服务,就可以访问到http://192.168.3.2:631/管理页面了,到添加打印机页面,可以正常看到三台打印机,添加进去,名称与以前的保持一致即可。
在这里插入图片描述
安装挂载点

root@OpenWrt:~# opkg install block-mount
root@OpenWrt:~# opkg install mount-utils  #挂载卸载工具,使系统可以通过 UUID 进行挂载
root@OpenWrt:~# opkg install blockd   #用于自动挂载

完了退出openwrt操作界面,Ctrl+F5刷新后,重新登入后,就可以看到挂载点了
在这里插入图片描述

安装包支持USB U盘

root@OpenWrt:~# opkg install kmod-usb-storage #安装usb存储设备驱动
root@OpenWrt:~# opkg install kmod-mmc #安装MMC驱动,有一种SD卡的U盘需要安装这个驱动

页面上发现了U盘,但是无法挂载上去,手工挂载一下看看, 提示以下错误
在这里插入图片描述

root@OpenWrt:~# mount -o iocharset=utf8 /dev/sdb1  /mnt/sda/
mount: /mnt/sda: unknown filesystem type 'ntfs'.

看来需要安装个支持NTFS格式的包,安装一个ntfs-3g的包后,再试试看

root@OpenWrt:~# opkg install ntfs-3g
Installing ntfs-3g (2017.3.23-3-fuseint) to root...
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/packages/ntfs-3g_2017.3.23-3-fuseint_mips_24kc.ipk
Installing kmod-fuse (4.14.162-1) to root...
Downloading http://downloads.openwrt.org/releases/19.07.0/targets/ar71xx/nand/kmods/4.14.162-1-3487e40b92bc4840fe01ec6a7fc6943b/kmod-fuse_4.14.162-1_mips_24kc.ipk
Configuring kmod-fuse.
Configuring ntfs-3g.
Create '/etc/filesystems'.
Add 'ntfs-3g' to known filesystems.
root@OpenWrt:~# mount -o iocharset=utf8 /dev/sdb1  /mnt/sda/
root@OpenWrt:~# df -hT
Filesystem           Type            Size      Used Available Use% Mounted on
/dev/root            squashfs        2.5M      2.5M         0 100% /rom
tmpfs                tmpfs          60.7M      1.0M     59.7M   2% /tmp
/dev/ubi0_1          ubifs          13.8M      5.6M      7.4M  43% /overlay
overlayfs:/overlay   overlay        13.8M      5.6M      7.4M  43% /
tmpfs                tmpfs         512.0K         0    512.0K   0% /dev
/dev/sdb1            fuseblk       118.8G    116.6G      2.2G  98% /mnt/sda

现在可以正常挂载了并识别了U盘了。

安装SAMBA服务

root@OpenWrt:~# opkg install samba36-server luci-app-samba luci-i18n-samba-zh-cn
Installing samba36-server (3.6.25-14) to root...
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/base/samba36-server_3.6.25-14_mips_24kc.ipk
Installing luci-app-samba (git-22.115.68448-712bc8e-1) to root...
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/luci/luci-app-samba_git-22.115.68448-712bc8e-1_all.ipk
Installing luci-compat (git-22.115.68448-712bc8e-1) to root...
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/luci/luci-compat_git-22.115.68448-712bc8e-1_all.ipk
Installing luci-i18n-samba-zh-cn (git-22.115.68448-712bc8e-1) to root...
Downloading http://downloads.openwrt.org/releases/19.07.0/packages/mips_24kc/luci/luci-i18n-samba-zh-cn_git-22.115.68448-712bc8e-1_all.ipk
Installing luci-app-samba (git-22.115.68448-712bc8e-1) to root...
Configuring samba36-server.
Configuring luci-app-samba.
Configuring luci-i18n-samba-zh-cn.
Collected errors:
 * check_data_file_clashes: Package luci-compat wants to install file /usr/lib/lua/luci/tools/webadmin.lua
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/add.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/apply.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/arrow.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/down.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/download.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/edit.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/fieldadd.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/file.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/find.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/folder.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/help.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/key.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/link.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/reload.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/remove.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/reset.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/save.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/up.gif
        But that file is already provided by package  * luci-base
 * check_data_file_clashes: Package luci-compat wants to install file /www/luci-static/resources/cbi/user.gif
        But that file is already provided by package  * luci-base
 * opkg_install_cmd: Cannot install package luci-app-samba.

在这里插入图片描述

luci-app-samba安装时有报错,页面也使用不了,但不影响服务正常运行,就不用界面了吧,好像luci-app-samba与luci-base有冲突,不知道怎么解决。

可以先去页面里面升级一下luci-base,再去页面里面安装luci-app-samba,发现好使了。

再按上面的教程修改两个配置文件,添加密码,即可正常访问了。

十九、PPTP客户端配置

从单位退役后,拿回家里继续发光发热。
用它建立从单位到家里的VPN,实现可以在外网访问家里与厂里的所有服务。
厂里有公网IP地址,好办,家里没有公网IP,只能做个内网穿透,方案有frp等等,但这个路由器内存有限, 又没有多余的U盘去扩容,不想插个U盘上去。
我想既然建立了VPN,应该可以相互相互访问了吧,我从厂里建立个端口进行映射到家里的路由器上不就也一样的,PPTP VPN速度还是很快的,那么试试看看。

步骤

opkg update
opkg install ppp-mod-pptp
opkg install luci-proto-ppp

在OpenWRT安裝PPTP Client端
首先用ssh登陆到路由器
安装pptp软件包

opkg update
opkg install pptpd

配置接口 vi /etc/config/network 在末行添加如下代码:

config 'interface' 'vpn' 
option 'ifname'    'pptp-vpn' 
option 'proto'     'pptp'  
option 'username'  'vpnusername'
option 'password'  'vpnpassword'  
option 'server'    'vpn.example.org or ipaddress' 
option 'buffering' '1'  

第四行vpnuesrname换为自己的VPN帐号
第五行vpnpassword换来自己的VPN密码
第六行vpn.example.org or ipaddress换为自己的VPN地址,最好是用IP 第七行的beffering是VPN缓冲,1为开启,0为禁止
第八行如果你的VPN不需要加密可以不要。 4. 完成以上动作后reboot路由器。重启完成后登陆到路由器内,在网络-接口中会多了一个VPN接 口,现在可以直接在LUCI中进行配置了。

如果发现VPN还是连接不上,有可能需要安装一个包:
kmod-nf-nathelper-extra
旧版的openwrt要安装kmod-ipt-nethelper这个包
对于新版,如3.18或4.xx内核的ROM,要安装kmod-nf-nathelper-extra这个包。

现在能连上厂里的VPN了
在这里插入图片描述
但是发现路由器的所有IP都转向VPN了,导致WNDR4300下面的终端都上不了外网。查看一上路由表,发现多了一条记录:
在这里插入图片描述
那么只需要把这里取消一下配置即可
在这里插入图片描述
把勾取消后,那条路由就会消失了。路由器下面的PC可以正常访问外网了。

外网现在是可以正常访问了, 但是发现路由器下面的PC还是访问不了厂里的网络,在路由器里面ping一下厂里的网关 192.168.3.1 还是通的。那是为什么呢?
是不是缺少转发的规则,那么新建一个VPN的区域
在这里插入图片描述
在这里插入图片描述

再试下,发现已经可以从PC上ping通192.168.3.1了。

但3网段的其它IP还是不通,需要再加条静态路由。
在这里插入图片描述
在这里插入图片描述
这样把厂里的几个网段都加进来了,再试试看果然可以了。

然后再从厂里访问我家里的看看,竟然也通了。

[root@PandoraBox_4455:/mnt/sda5/frp]#traceroute 192.168.3.200
traceroute to 192.168.3.200 (192.168.3.200), 30 hops max, 38 byte packets
 1  192.168.4.2 (192.168.4.2)  0.480 ms  0.420 ms  *
 2  192.168.3.200 (192.168.3.200)  8.580 ms  7.940 ms  7.760 ms
[root@PandoraBox_4455:/mnt/sda5/frp]#ping 192.168.3.200
PING 192.168.3.200 (192.168.3.200): 56 data bytes
64 bytes from 192.168.3.200: seq=0 ttl=63 time=8.520 ms
64 bytes from 192.168.3.200: seq=1 ttl=63 time=8.320 ms
64 bytes from 192.168.3.200: seq=2 ttl=63 time=8.280 ms
64 bytes from 192.168.3.200: seq=3 ttl=63 time=8.260 ms

之前是不通的,不知道现在为什么又通了,有点奇怪, 难道是因为我把两边路由器的这个勾上了? 我有点懵!
关于这两个选项,我查了一下相关资料,这个博主介绍得比较详细。 https://www.jianshu.com/p/e7ccb32c0462
在这里插入图片描述
到了最后一步,做个端口映射看一下
在这里插入图片描述
试试看看,一举成功,确实通了,搞定。
在这里插入图片描述
后来发现有一个问题:从PPTP客户端访问服务端时,发现返回的数据只有一部分,然后就卡死断开连接了。
经过摸索,发现是MTU值不匹配,经过测试,改成1400正好合适,这个值也是查出来的,因为我之前用WIN7系统直接连的时候是没有问题的
在这里插入图片描述
在微软官网上查到MTU值=1400
在这里插入图片描述
所以我设置为1400后,效果立马有了,不会再出现数据只返回一半的情况了。

最后写一下使用感受

本人一般是本着物尽其用的理念,不铺张浪费,够用就行。原来我的飞鱼星VW1200主路由端口只有3个LAN口不够用,就使用了一个4口百兆光猫当交换机用了一年, 现在我买了这个打印服务器, 顺便把原来百兆光猫给替换下来, 毕竟4300有千兆端口*4, 再不够用还可以把WAN口也改成LAN来使用,这下一个4300解决了两大问题, 还是很满意的,百兆换千兆也算是个小小的升级了。

优点:
1、再也不用开着一台电脑共享打印服务了,有时我下班关机了,或请假或出差,别的同事还要加班打单,那又得开机,这是最大的优点了
2、可以不受限制的远程打印,不用忍受龟速的内网穿透了,也不会被扫描端口打印出乱码,尤其是针式打印机连打的情况下,被扫描端口简直就是恶梦。
3、USB口可以随意插拔,不用时打印机甚至可以断电,都不会影响服务。
4、可以统一管理打印任务,在后台还可以看到历史打印任务:http://192.168.3.2:631/admin/log/page_log?

缺点:
唯一的缺点就是打印起来没有那么丝滑、流畅,当点开打印时,会有那么1秒钟的卡顿,不知道是什么原因引起的,我怀疑有可能受路由器的性能影响,以前用台式机打印共享,用起来那是非常流畅,豪无卡顿,不知道有没有解决办法。
用了半个月发现刚开始安装好时会卡,后面再也没有出现过,丝滑流畅得很,是不是刚开始初始化时才有的卡顿,现在真是太完美了。

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值