强曰为道
与天地相似,故不违。知周乎万物,而道济天下,故不过。旁行而不流,乐天知命,故不忧.
文档目录

CUPS 打印服务完全指南 / 第 6 章:IPP 协议深度解析

第 6 章:IPP 协议深度解析

IPP(Internet Printing Protocol)是 CUPS 的核心协议,也是现代打印技术的基石。本章将深入解析 IPP 协议的原理、版本演进、IPP Everywhere 标准以及移动打印技术。


6.1 IPP 协议概述

6.1.1 IPP 协议栈

┌─────────────────────────────────────────────────┐
│              IPP 应用层                           │
│  ┌───────────────────────────────────────────┐  │
│  │  IPP Operations (操作)                    │  │
│  │  - Print-Job, Create-Job, Cancel-Job      │  │
│  │  - Get-Printer-Attributes                 │  │
│  │  - Identify-Printer                       │  │
│  └───────────────────────────────────────────┘  │
│  ┌───────────────────────────────────────────┐  │
│  │  IPP Attributes (属性)                    │  │
│  │  - printer-uri, job-id, requesting-user   │  │
│  │  - media, sides, number-up                │  │
│  └───────────────────────────────────────────┘  │
├─────────────────────────────────────────────────┤
│              HTTP/1.1 传输层                      │
│  ┌───────────────────────────────────────────┐  │
│  │  Content-Type: application/ipp            │  │
│  │  POST /ipp/print HTTP/1.1                 │  │
│  └───────────────────────────────────────────┘  │
├─────────────────────────────────────────────────┤
│              TLS/SSL 加密层(可选)                │
│  ┌───────────────────────────────────────────┐  │
│  │  TLS 1.2/1.3                             │  │
│  │  端口: 443 或 631                         │  │
│  └───────────────────────────────────────────┘  │
├─────────────────────────────────────────────────┤
│              TCP/IP 网络层                        │
│  ┌───────────────────────────────────────────┐  │
│  │  TCP 端口: 631 (标准) / 443 (加密)        │  │
│  │  IPv4 / IPv6                              │  │
│  └───────────────────────────────────────────┘  │
└─────────────────────────────────────────────────┘

6.1.2 IPP 版本对比

版本年份核心特性CUPS 支持
IPP 1.01999基本打印操作CUPS 1.0+
IPP 1.12000安全增强、通知CUPS 1.1+
IPP 2.02005系统管理操作CUPS 1.3+
IPP 2.12010打印机发现CUPS 1.5+
IPP 2.22015IPP EverywhereCUPS 2.2+
IPP 2.32020增强系统管理CUPS 2.4+

6.1.3 IPP 消息格式

IPP 消息结构:
┌────────────────────────────────────┐
│ IPP 版本号 (2 字节)                │
│  - 主版本: 0x02                    │
│  - 次版本: 0x00/01/02              │
├────────────────────────────────────┤
│ 操作码/状态码 (2 字节)             │
│  - 请求: 操作码 (0x0002 = Print-Job)│
│  - 响应: 状态码 (0x0000 = OK)      │
├────────────────────────────────────┤
│ 请求 ID (4 字节)                   │
│  - 唯一标识符                       │
├────────────────────────────────────┤
│ 属性组 (多个)                      │
│  - operation-attributes-group      │
│  - job-attributes-group            │
│  - printer-attributes-group        │
├────────────────────────────────────┤
│ 打印数据 (可选)                    │
│  - 文档内容                         │
└────────────────────────────────────┘

6.2 IPP 核心操作

6.2.1 打印操作

# Print-Job: 提交单个文档
ipptool -tv ipp://localhost/printers/myprinter \
  -d file:///path/to/document.pdf \
  print-job.test

# Create-Job: 创建空任务
ipptool -tv ipp://localhost/printers/myprinter \
  create-job.test

# Send-Document: 向已创建的任务添加文档
ipptool -tv ipp://localhost/printers/myprinter \
  -d file:///path/to/document.pdf \
  -o job-id=123 \
  send-document.test

# 关闭任务(标记任务完成)
ipptool -tv ipp://localhost/printers/myprinter \
  -o job-id=123 \
  -o last-document=true \
  send-document.test

6.2.2 查询操作

# Get-Printer-Attributes: 查询打印机属性
ipptool -tv ipp://localhost/printers/myprinter \
  get-printer-attributes.test

# 输出示例:
# printer-uri-supported = ipp://localhost/printers/myprinter
# printer-name = myprinter
# printer-state = idle (3)
# printer-state-reasons = none
# printer-is-accepting-jobs = true
# queued-job-count = 0
# printer-make-model = HP LaserJet Pro M404

# Get-Job-Attributes: 查询任务属性
ipptool -tv ipp://localhost/printers/myprinter \
  -o job-id=123 \
  get-job-attributes.test

# Get-Jobs: 获取任务列表
ipptool -tv ipp://localhost/printers/myprinter \
  get-jobs.test

# 获取所有打印机列表
ipptool -tv ipp://localhost \
  cups-get-printers.test

6.2.3 管理操作

# Cancel-Job: 取消任务
ipptool -tv ipp://localhost/printers/myprinter \
  -o job-id=123 \
  cancel-job.test

# Hold-Job: 暂停任务
ipptool -tv ipp://localhost/printers/myprinter \
  -o job-id=123 \
  hold-job.test

# Release-Job: 恢复任务
ipptool -tv ipp://localhost/printers/myprinter \
  -o job-id=123 \
  release-job.test

# Pause-Printer: 暂停打印机
ipptool -tv ipp://localhost/printers/myprinter \
  pause-printer.test

# Resume-Printer: 恢复打印机
ipptool -tv ipp://localhost/printers/myprinter \
  resume-printer.test

# Purge-Jobs: 清除所有任务
ipptool -tv ipp://localhost/printers/myprinter \
  purge-jobs.test

6.2.4 使用 ipptool 测试文件

# 创建自定义测试文件
cat << 'EOF' > /tmp/ipp-test.test
{
  # 测试打印机状态
  NAME "Check Printer Status"
  OPERATION Get-Printer-Attributes
  GROUP operation-attributes-tag
  ATTR charset attributes-charset utf-8
  ATTR language attributes-natural-language en
  ATTR uri printer-uri $uri
  EXPECT printer-state WITH-VALUE >0
  EXPECT printer-is-accepting-jobs WITH-VALUE true
  STATUS successful-ok
}
EOF

# 运行测试
ipptool -tv ipp://localhost/printers/myprinter /tmp/ipp-test.test

6.3 IPP Everywhere

6.3.1 IPP Everywhere 概述

IPP Everywhere 是 PWG(打印工作组)制定的无驱动打印标准:

特性说明
标准PWG 5100.14
目的无需安装驱动即可打印
发现DNS-SD (Bonjour/mDNS)
格式PDF、JPEG、PWG-Raster、Apple Raster
安全支持 TLS 加密
兼容Windows、macOS、Linux、iOS、Android

6.3.2 IPP Everywhere 打印机要求

IPP Everywhere 打印机必须支持:
├── IPP 2.0 或更高版本
├── DNS-SD 服务发现
├── 至少一种文档格式:
│   ├── application/pdf
│   ├── image/jpeg
│   ├── application/vnd.cups-raster (PWG Raster)
│   └── image/urf (Apple Raster)
├── 基本打印属性:
│   ├── printer-uri-supported
│   ├── printer-name
│   ├── printer-state
│   ├── media-supported
│   └── sides-supported
└── TLS 加密(推荐)

6.3.3 发现 IPP Everywhere 打印机

# 方法 1: 使用 ippfind
ippfind
# 输出: ipp://HP-LaserJet-Pro.local:631/ipp/print

# 方法 2: 使用 avahi
avahi-browse -t -r _ipp._tcp
# 输出: + eth0 IPv4 HP LaserJet Pro M404 Internet Printer local

# 方法 3: 使用 nmap
nmap -p 631 192.168.1.0/24 --open

# 方法 4: 使用 cups-browsed
sudo systemctl status cups-browsed
# cups-browsed 会自动发现并添加 IPP Everywhere 打印机

6.3.4 配置 IPP Everywhere 打印机

# 方法 1: 使用 -m everywhere(推荐)
sudo lpadmin -p MyPrinter -E \
  -v "ipp://HP-LaserJet-Pro.local/ipp/print" \
  -m "everywhere"

# 方法 2: 使用 DNS-SD URI
sudo lpadmin -p MyPrinter -E \
  -v "dnssd://HP%20LaserJet%20Pro%20M404._ipp._tcp.local./" \
  -m "everywhere"

# 方法 3: 使用 ipptool 查询后手动添加
# 获取打印机支持的文档格式
ipptool -tv ipp://192.168.1.100/ipp/print get-printer-attributes.test | \
  grep "document-format-supported"

# 选择合适的格式
sudo lpadmin -p MyPrinter -E \
  -v "ipp://192.168.1.100/ipp/print" \
  -m "everywhere"

6.3.5 验证 IPP Everywhere 支持

# 检查打印机是否支持 IPP Everywhere
ipptool -tv ipp://192.168.1.100/ipp/print get-printer-attributes.test | \
  grep -E "ipp-features-supported|document-format-supported"

# 输出示例:
# ipp-features-supported = ...
# document-format-supported = application/pdf,image/jpeg,...

# 检查 URF 标签(Apple AirPrint 兼容)
ipptool -tv ipp://192.168.1.100/ipp/print get-printer-attributes.test | \
  grep "urf-supported"

# URF 标签含义:
# DM3  - 双面打印,3边距
# RS300 - 光栅,300 DPI
# RS600 - 光栅,600 DPI
# W8   - 基本功能

6.4 AirPrint

6.4.1 AirPrint 概述

AirPrint 是 Apple 的无线打印技术,基于 IPP 和 DNS-SD:

特性说明
协议IPP 2.0+ + DNS-SD
发现mDNS/Bonjour
文档格式PDF、URF (Apple Raster)
安全可选 TLS
兼容设备iPhone、iPad、Mac

6.4.2 在 Linux 上配置 AirPrint 服务

# 安装必要组件
sudo apt install -y cups avahi-daemon

# 确保 CUPS 启用共享
sudo cupsctl --share-printers

# 配置 CUPS 发布 DNS-SD 记录
# 编辑 cupsd.conf
sudo vim /etc/cups/cupsd.conf

# 添加或修改:
# BrowseLocalProtocols dnssd
# DefaultShared Yes

# 重启服务
sudo systemctl restart cups
sudo systemctl restart avahi-daemon

创建 AirPrint 服务文件

# 自动创建 AirPrint 服务文件
sudo tee /etc/avahi/services/airprint-myprinter.service << 'EOF'
<?xml version="1.0" standalone="no"?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">My Printer on %h</name>
  <service>
    <type>_ipp._tcp</type>
    <subtype>_universal._sub._ipp._tcp</subtype>
    <port>631</port>
    <txt-record>rp=ipp/print</txt-record>
    <txt-record>txtvers=1</txt-record>
    <txt-record>qtotal=1</txt-record>
    <txt-record>Transparent=T</txt-record>
    <txt-record>URF=DM3</txt-record>
    <txt-record>kind=document,envelope,photo</txt-record>
    <txt-record>product=(CUPS Printer)</txt-record>
    <txt-record>pdl=application/pdf,image/jpeg</txt-record>
    <txt-record>Color=T</txt-record>
    <txt-record>Duplex=T</txt-record>
  </service>
</service-group>
EOF

# 重启 Avahi
sudo systemctl restart avahi-daemon

6.4.3 AirPrint 自动发现脚本

#!/bin/bash
# 自动生成 AirPrint 服务文件

PRINTER_NAME="$1"
PRINTER_URI="$2"

if [ -z "$PRINTER_NAME" ] || [ -z "$PRINTER_URI" ]; then
    echo "用法: $0 <打印机名> <打印机URI>"
    echo "示例: $0 MyPrinter ipp://192.168.1.100/ipp/print"
    exit 1
fi

# 查询打印机能力
printer_info=$(ipptool -tv "$PRINTER_URI" get-printer-attributes.test 2>/dev/null)

# 检测颜色支持
color_support="F"
if echo "$printer_info" | grep -q "ColorModel.*RGB"; then
    color_support="T"
fi

# 检测双面支持
duplex_support="F"
if echo "$printer_info" | grep -q "sides-supported.*two-sided"; then
    duplex_support="T"
fi

# 获取支持的文档格式
pdl_formats="application/pdf,image/jpeg"

# 生成服务文件
cat << EOF | sudo tee /etc/avahi/services/airprint-${PRINTER_NAME}.service
<?xml version="1.0" standalone="no"?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">${PRINTER_NAME} on %h</name>
  <service>
    <type>_ipp._tcp</type>
    <subtype>_universal._sub._ipp._tcp</subtype>
    <port>631</port>
    <txt-record>rp=ipp/print</txt-record>
    <txt-record>txtvers=1</txt-record>
    <txt-record>qtotal=1</txt-record>
    <txt-record>Transparent=T</txt-record>
    <txt-record>URF=DM3</txt-record>
    <txt-record>pdl=${pdl_formats}</txt-record>
    <txt-record>Color=${color_support}</txt-record>
    <txt-record>Duplex=${duplex_support}</txt-record>
  </service>
</service-group>
EOF

echo "AirPrint 服务文件已创建: /etc/avahi/services/airprint-${PRINTER_NAME}.service"
sudo systemctl restart avahi-daemon

6.5 移动打印

6.5.1 Android Mopria 打印

# Mopria 是 Android 的打印标准
# 基于 IPP Everywhere

# 确保配置正确
# 1. 启用 CUPS 共享
sudo cupsctl --share-printers

# 2. 确保 Avahi 运行
sudo systemctl status avahi-daemon

# 3. 配置防火墙
sudo ufw allow 631/tcp
sudo ufw allow 5353/udp  # mDNS

# Android 设备配置:
# 设置 → 连接 → 打印 → 默认打印服务
# 系统会自动发现网络中的 IPP 打印机

6.5.2 Windows 移动打印

# Windows 使用 Mopria 或 IPP 协议
# 确保 CUPS 配置正确

# 在 Windows 上添加 IPP 打印机
# 设置 → 设备 → 打印机和扫描仪 → 添加打印机
# 选择 "我需要的打印机不在列表中"
# 选择 "按名称选择共享打印机"
# 输入: http://<服务器IP>:631/printers/<打印机名>

6.5.3 通用移动打印配置

# 创建移动打印配置脚本
cat << 'SCRIPT' > /usr/local/bin/setup-mobile-printing
#!/bin/bash

echo "=== 配置移动打印 ==="

# 安装必要组件
apt install -y avahi-daemon cups

# 启用 CUPS 共享
cupsctl --share-printers
cupsctl BrowseLocalProtocols=dnssd

# 配置防火墙
ufw allow 631/tcp
ufw allow 5353/udp

# 重启服务
systemctl restart cups
systemctl restart avahi-daemon

echo "=== 移动打印配置完成 ==="
echo "iOS/Android 设备现在可以发现并使用打印机"
SCRIPT

sudo chmod +x /usr/local/bin/setup-mobile-printing

6.6 远程打印

6.6.1 IPP 远程打印架构

┌──────────────┐          ┌──────────────┐          ┌──────────────┐
│  远程客户端   │  ──────▶ │  CUPS 服务器  │  ──────▶ │   打印机     │
│ (任意网络)    │  IPP/IPPS │ (中心节点)   │  USB/网络  │ (本地/远程)  │
└──────────────┘          └──────────────┘          └──────────────┘
      │                         │
      │                         │
      └───── IPSec/VPN ─────────┘
              (安全隧道)

6.6.2 配置远程 IPP 访问

# 在 CUPS 服务器上配置远程访问
sudo vim /etc/cups/cupsd.conf

# 修改监听地址
Listen 0.0.0.0:631
# 或指定 IP
# Listen 192.168.1.100:631

# 配置访问控制
<Location />
  Order allow,deny
  Allow localhost
  Allow 192.168.1.0/24
  Allow 10.0.0.0/8
</Location>

<Location /admin>
  Order allow,deny
  Allow localhost
  Allow 192.168.1.0/24
  AuthType Default
  Require user @SYSTEM
</Location>

# 共享所有打印机
DefaultShared Yes

# 重启 CUPS
sudo systemctl restart cups

6.6.3 客户端连接远程打印机

# 方法 1: 使用 lpadmin 连接
sudo lpadmin -p RemotePrinter -E \
  -v "ipp://192.168.1.100/printers/myprinter" \
  -m "everywhere"

# 方法 2: 使用 cups-browsed 自动发现
sudo apt install -y cups-browsed
sudo systemctl enable cups-browsed

# 编辑 cups-browsed 配置
sudo vim /etc/cups/cups-browsed.conf

# 添加远程 CUPS 服务器
BrowsePoll 192.168.1.100
BrowseRemoteProtocols cups

# 重启服务
sudo systemctl restart cups-browsed

# 方法 3: 使用 Web 界面
# 访问 http://localhost:631/admin
# 添加打印机 → Internet Printing Protocol (ipp)
# 输入: ipp://192.168.1.100/printers/myprinter

6.6.4 IPP over TLS (IPPS)

# 使用加密的 IPP 连接
sudo lpadmin -p SecurePrinter -E \
  -v "ipps://192.168.1.100/printers/myprinter" \
  -m "everywhere"

# 配置 CUPS 服务器支持 TLS
# 1. 生成 SSL 证书
sudo openssl req -new -x509 -keyout /etc/cups/ssl/server.key \
  -out /etc/cups/ssl/server.crt -days 365 -nodes

# 2. 配置 cupsd.conf
# ServerCertificate /etc/cups/ssl/server.crt
# ServerKey /etc/cups/ssl/server.key

# 3. 重启 CUPS
sudo systemctl restart cups

# 4. 强制使用 TLS
# DefaultEncryption Required

6.7 IPP 工具使用

6.7.1 ipptool 详解

# ipptool 是 IPP 协议的命令行测试工具

# 基本语法
ipptool [选项] ipp://URI 测试文件.test

# 常用选项
# -t        测试模式(不发送实际请求)
# -v        详细输出
# -d name=value  设置属性
# -f file   从文件读取数据

# 测试打印机是否在线
ipptool -tv ipp://192.168.1.100/ipp/print get-printer-attributes.test

# 获取打印机支持的格式
ipptool -tv ipp://192.168.1.100/ipp/print get-printer-attributes.test | \
  grep "document-format-supported"

# 测试打印作业
ipptool -tv ipp://192.168.1.100/ipp/print \
  -d file:///tmp/test.pdf \
  print-job.test

6.7.2 常用测试文件

# CUPS 自带的测试文件位置
ls /usr/share/cups/ipptool/

# 常用测试文件:
# get-printer-attributes.test  - 获取打印机属性
# print-job.test               - 测试打印
# create-job.test              - 创建任务
# cancel-job.test              - 取消任务
# get-jobs.test                - 获取任务列表
# cups-get-printers.test       - 获取打印机列表
# identify-printer.test        - 识别打印机(闪烁指示灯)

6.7.3 创建自定义 IPP 测试

# 创建完整的 IPP 测试套件
cat << 'EOF' > /tmp/ipp-comprehensive.test
{
  # 测试 1: 检查打印机是否在线
  NAME "Printer is online"
  OPERATION Get-Printer-Attributes
  GROUP operation-attributes-tag
  ATTR charset attributes-charset utf-8
  ATTR language attributes-natural-language en
  ATTR uri printer-uri $uri
  EXPECT printer-state WITH-VALUE >0
  EXPECT printer-is-accepting-jobs WITH-VALUE true
  STATUS successful-ok
}

{
  # 测试 2: 检查打印队列
  NAME "Check print queue"
  OPERATION Get-Jobs
  GROUP operation-attributes-tag
  ATTR charset attributes-charset utf-8
  ATTR language attributes-natural-language en
  ATTR uri printer-uri $uri
  STATUS successful-ok
}

{
  # 测试 3: 测试打印
  NAME "Test print job"
  OPERATION Print-Job
  GROUP operation-attributes-tag
  ATTR charset attributes-charset utf-8
  ATTR language attributes-natural-language en
  ATTR uri printer-uri $uri
  ATTR name requesting-user-name $user
  FILE "/usr/share/cups/data/testprint"
  STATUS successful-ok
  EXPECT job-id WITH-VALUE >0
}
EOF

# 运行测试
ipptool -tv ipp://localhost/printers/myprinter /tmp/ipp-comprehensive.test

6.8 IPP 通知和订阅

6.8.1 IPP 通知机制

# IPP 支持多种通知方式:
# - ipp-get: 轮询获取通知
# - in-band: 通过 IPP 连接接收
# - mailto: 邮件通知
# - rss: RSS 订阅

# 创建订阅
ipptool -tv ipp://localhost/printers/myprinter \
  -o notify-events=job-completed \
  -o notify-recipient-uri=mailto:admin@example.com \
  create-printer-subscription.test

# 查询订阅
ipptool -tv ipp://localhost/printers/myprinter \
  get-subscriptions.test

# 删除订阅
ipptool -tv ipp://localhost/printers/myprinter \
  -o subscription-id=1 \
  cancel-subscription.test

6.8.2 事件类型

事件说明
job-completed任务完成
job-created任务创建
job-state-changed任务状态变化
job-stopped任务停止
printer-restarted打印机重启
printer-shutdown打印机关闭
printer-state-changed打印机状态变化

6.9 IPP 安全

6.9.1 IPP 安全选项

# 安全级别配置
# cupsd.conf 配置

# 1. 基本认证
# DefaultAuthType Basic

# 2. 摘要认证(更安全)
# DefaultAuthType Digest

# 3. TLS 加密
# DefaultEncryption Required
# ServerCertificate /etc/cups/ssl/server.crt
# ServerKey /etc/cups/ssl/server.key

# 4. 客户端证书认证
# DefaultAuthType ClientCertificate

6.9.2 配置 IPP over TLS

# 步骤 1: 生成 CA 证书
openssl genrsa -out /etc/cups/ssl/ca.key 4096
openssl req -new -x509 -days 3650 -key /etc/cups/ssl/ca.key \
  -out /etc/cups/ssl/ca.crt

# 步骤 2: 生成服务器证书
openssl genrsa -out /etc/cups/ssl/server.key 2048
openssl req -new -key /etc/cups/ssl/server.key \
  -out /etc/cups/ssl/server.csr
openssl x509 -req -days 365 \
  -in /etc/cups/ssl/server.csr \
  -CA /etc/cups/ssl/ca.crt \
  -CAkey /etc/cups/ssl/ca.key \
  -out /etc/cups/ssl/server.crt

# 步骤 3: 配置 CUPS 使用 TLS
cat << 'EOF' >> /etc/cups/cupsd.conf
# TLS 配置
ServerCertificate /etc/cups/ssl/server.crt
ServerKey /etc/cups/ssl/server.key
DefaultEncryption Required
EOF

# 步骤 4: 重启 CUPS
sudo systemctl restart cups

# 步骤 5: 测试 TLS 连接
openssl s_client -connect localhost:631 -brief

6.10 业务场景

6.10.1 场景一:远程办公打印

# 需求:员工在家办公时能够打印到公司打印机

# 方案 1: VPN + IPP
# 1. 员工连接公司 VPN
# 2. 通过 VPN 访问 CUPS 服务器
sudo lpadmin -p OfficePrinter -E \
  -v "ipps://cups.company.com/printers/main" \
  -m "everywhere"

# 方案 2: 云打印
# 使用 Google Cloud Print 或类似服务
# 需要在公司 CUPS 服务器上配置云打印桥接

# 方案 3: SSH 隧道
ssh -L 631:localhost:631 user@cups.company.com
# 然后在本地添加打印机
sudo lpadmin -p OfficePrinter -E \
  -v "ipp://localhost:631/printers/main" \
  -m "everywhere"

6.10.2 场景二:多站点打印

# 需求:多个办公站点共享打印服务

# 在中心站点配置 CUPS 服务器
# /etc/cups/cupsd.conf
Listen 0.0.0.0:631

<Location />
  Order allow,deny
  Allow 192.168.1.0/24  # 站点 A
  Allow 192.168.2.0/24  # 站点 B
  Allow 10.0.0.0/8      # VPN
</Location>

# 在各站点配置 cups-browsed
# /etc/cups/cups-browsed.conf
BrowsePoll cups-central.company.com
BrowseRemoteProtocols cups

# 客户端自动发现所有打印机

6.10.3 场景三:安全打印环境

# 需求:高安全性打印环境

# 1. 强制 TLS
DefaultEncryption Required

# 2. 客户端证书认证
DefaultAuthType ClientCertificate

# 3. IP 白名单
<Location />
  Order deny,allow
  Deny all
  Allow 192.168.1.100
  Allow 192.168.1.101
</Location>

# 4. 审计日志
AccessLog /var/log/cups/access_log
LogLevel info

# 5. 限制管理操作
<Location /admin>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow 192.168.1.100
</Location>

6.11 扩展阅读

资源链接
IPP 协议规范https://www.pwg.org/ipp/
IPP Everywherehttps://www.pwg.org/ipp/everywhere.html
Apple AirPrinthttps://support.apple.com/en-us/HT201311
Mopria Alliancehttps://mopria.org/
ipptool 手册man ipptool
CUPS IPP 文档https://www.cups.org/doc/api-ipp.html

6.12 本章小结

主题关键要点
IPP 协议基于 HTTP/1.1,标准端口 631
IPP Everywhere无驱动打印标准,支持 PDF/JPEG/PWG-Raster
AirPrintApple 的无线打印技术,基于 IPP + DNS-SD
移动打印Mopria (Android)、AirPrint (iOS)、IPP (通用)
远程打印通过 IPP/IPPS 协议实现跨网络打印
安全TLS 加密、认证机制、IP 白名单

下一章预告:我们将学习打印共享与发现,包括 Browse 协议、Avahi、DNS-SD 以及跨网络打印共享配置。


6.13 练习题

  1. 协议题:解释 IPP 协议与 HTTP 协议的关系,以及 IPP 消息的结构。

  2. 发现题:使用 ippfindavahi-browse 命令发现网络中的 IPP 打印机。

  3. AirPrint 题:在 Linux 上配置 CUPS + Avahi,使 iOS 设备能够发现并使用打印机。

  4. 安全题:配置 IPP over TLS (IPPS),确保打印数据加密传输。

  5. 远程题:设计一个支持多办公站点的远程打印架构,说明需要哪些组件和配置。