Skip to main content

BOOTP

BOOTP (Boot Protocol)是一种IP/UDP引导协议,可以使一个无盘客户端获取自己的IP地址、服务器的主机地址和一个需要放在内存中运行的指定名称的引导文件。我们希望客户端在启动时可以有一种无须用户参与的完整的引导方式,即一种无人值守的上电启动方式,幸运的是,BOOTP帮我们做到了这一点。通过BOOTP协议,客户端可以自动获得IP地址、服务器地址和引导文件等,从而完成地址绑定和引导启动。文件传送一般使用TFTP协议,但BOOTP也能够与其它协议如SFTP或FTP一起工作。BOOTP协议报文被封装在UDP中。

报文格式

BOOTP报文格式

 0        7           15                31
 +------------------------------------------+
 | Op(1) | Htype(1) | Hlen(1) | Hops(1) |
 +------------------------------------------|
 |                   Xid(4)               |
 +------------------------------------------|
 |         Secs(2)       |                 |
 +------------------------------------------|
 |                 Ciaddr(4)               |
 +------------------------------------------|
 |                 Yiaddr(4)               |
 +------------------------------------------|
 |                 Siaddr(4)               |
 +------------------------------------------|
 |                 Giaddr(4)               |
 +------------------------------------------+
 |                 Chaddr(16)               |
 +------------------------------------------+
 |                 Sname(64)               |
 +------------------------------------------|
 |                 File(128)               |
 +------------------------------------------+
 |             Vendor(variable)             |
 +------------------------------------------+
字段 长度(字节) 含义
Op 1 操作码/消息类型,取值为1或2: 1 = BOOTREQUEST (引导请求) 2 = BOOTREPLY (引导应答)
Htype 1 Hardware address type,硬件地址类型,如为1时表示客户端的网络硬件是10M以太网类型。
Hlen 1 Hardware address length,硬件地址长度,如为6时表示客户端的网络硬件地址长度为6byte。
Hops 1 客户端设置成0,在跨越网关引导时网关可选择使用(加1)。
Xid 4 事务ID,一个随机数,用来匹配引用请求和应答。
Secs 2 客户端引导开始后的过去的秒数,由客户端填写。
-- 2 未使用
Ciaddr 4 Client IP address,客户端IP地址,如果客户端知道就在引导请求中填入。
Yiaddr 4 Your (client) IP address,你的(客户端)IP地址,如果客户端不知道它的地址(ciaddr是0),服务器填入。
Siaddr 4 Server IP address,服务器IP地址由服务器在引导应答返回。
Giaddr 4 Gateway IP address,网关IP地址,在跨越网关引导中可以选择使用。
Chaddr 16 Client hardware address,客户端硬件地址,由客户端填写。
Sname 64 Server host name,服务器主机名。可选的,如果填写,必须为一个以0结尾的字符串。
File 128 Boot file name,引导文件名,可选的,如果填写,必须为一个以0结尾的字符串。
Vendor 64 Vendor-specific area,可选的商家指定的区域。可以是请求硬件类型/序列、或应答的性能/远端文件系统配置。这些信息留给第三方分析引导或程序使用。 注:vendor字段,对于DHCP,又称为“option”字段。此字段采用“CLV”方式构成,即code:标识号,唯一标识后面的信息内容,占1bytes;length:长度,表示后面信息内容的长度,占1bytes;value:信息内容,其长度为length所指定,以bytes 为单位。

BOOTP报文示例

BOOTP请求报文

 Frame 1: 458 bytes on wire (3664 bits), 458 bytes captured (3664 bits)
    WTAP_ENCAP: 1
    Arrival Time: Feb 18, 2013 21:52:38.006796000
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1361195558.006796000 seconds
    [Time delta from previous captured frame: 0.000000000 seconds]
    [Time delta from previous displayed frame: 0.000000000 seconds]
    [Time since reference or first frame: 0.000000000 seconds]
    Frame Number: 1
    Frame Length: 458 bytes (3664 bits)
    Capture Length: 458 bytes (3664 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ip:udp:bootp]
    [Coloring Rule Name: UDP]
    [Coloring Rule String: udp]
 Ethernet II, Src: b9:20:0a (00:13:5f:b9:20:0a), Dst: IETF-VRRP-VRID_02 (00:00:5e:00:01:02)
    Destination: IETF-VRRP-VRID_02 (00:00:5e:00:01:02)
        Address: IETF-VRRP-VRID_02 (00:00:5e:00:01:02)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Source: b9:20:0a (00:13:5f:b9:20:0a)
        Address: b9:20:0a (00:13:5f:b9:20:0a)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: IP (0x0800)
 Internet Protocol Version 4, Src: 10.23.49.219 (10.23.49.219), Dst: 10.99.65.167 (10.99.65.167)
    Version: 4
    Header length: 20 bytes
    Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00: Not-ECT (Not ECN-Capable Transport))
        0000 00.. = Differentiated Services Codepoint: Default (0x00)
        .... ..00 = Explicit Congestion Notification: Not-ECT (Not ECN-Capable Transport) (0x00)
    Total Length: 444
    Identification: 0x39d6 (14806)
    Flags: 0x02 (Don't Fragment)
        0... .... = Reserved bit: Not set
        .1.. .... = Don't fragment: Set
        ..0. .... = More fragments: Not set
    Fragment offset: 0
    Time to live: 60
    Protocol: UDP (17)
    Header checksum: 0xbb5e [correct]
        [Good: True]
        [Bad: False]
    Source: 10.23.49.219 (10.23.49.219)
    Destination: 202.99.65.167 (202.99.65.167)
    [Source GeoIP: Unknown]
    [Destination GeoIP: Unknown]
 User Datagram Protocol, Src Port: bootpc (68), Dst Port: bootps (67)
    Source port: bootpc (68)
    Destination port: bootps (67)
    Length: 424
    Checksum: 0xf9ed [validation disabled]
        [Good Checksum: False]
        [Bad Checksum: False]
 Bootstrap Protocol
    Message type: Boot Request (1)
    Hardware type: Ethernet
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x5f100978
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
            0... .... .... .... = Broadcast flag: Unicast
                .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 0.0.0.0 (0.0.0.0)
    Your (client) IP address: 0.0.0.0 (0.0.0.0)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 0.0.0.0 (0.0.0.0)
    Client MAC address: 70:54:76:0e:03:3e (70:54:76:0e:03:3e)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Bootp vendor specific options

BOOTP响应报文

 Frame 3: 458 bytes on wire (3664 bits), 458 bytes captured (3664 bits)
    WTAP_ENCAP: 1
    Arrival Time: Feb 18, 2013 22:06:43.375424000
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1361196403.375424000 seconds
    [Time delta from previous captured frame: 0.000234000 seconds]
    [Time delta from previous displayed frame: 0.000234000 seconds]
    [Time since reference or first frame: 0.004930000 seconds]
    Frame Number: 3
    Frame Length: 458 bytes (3664 bits)
    Capture Length: 458 bytes (3664 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ip:udp:bootp]
    [Coloring Rule Name: UDP]
    [Coloring Rule String: udp]
 Ethernet II, Src: ComdaEnt_89:c4:0a (00:d0:03:89:c4:0a), Dst: IETF-VRRP-VRID_02 (00:00:5e:00:01:02)
    Destination: IETF-VRRP-VRID_02 (00:00:5e:00:01:02)
        Address: IETF-VRRP-VRID_02 (00:00:5e:00:01:02)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Source: ComdaEnt_89:c4:0a (00:d0:03:89:c4:0a)
        Address: ComdaEnt_89:c4:0a (00:d0:03:89:c4:0a)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: IP (0x0800)
 Internet Protocol Version 4, Src: 10.25.247.129 (10.25.247.129), Dst: 10.99.65.167 (202.99.65.167)
    Version: 4
    Header length: 20 bytes
    Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00: Not-ECT (Not ECN-Capable Transport))
        0000 00.. = Differentiated Services Codepoint: Default (0x00)
        .... ..00 = Explicit Congestion Notification: Not-ECT (Not ECN-Capable Transport) (0x00)
    Total Length: 444
    Identification: 0x1b7e (7038)
    Flags: 0x02 (Don't Fragment)
        0... .... = Reserved bit: Not set
        .1.. .... = Don't fragment: Set
        ..0. .... = More fragments: Not set
    Fragment offset: 0
    Time to live: 60
    Protocol: UDP (17)
    Header checksum: 0x140e [correct]
        [Good: True]
        [Bad: False]
    Source: 10.25.247.129 (10.25.247.129)
    Destination: 10.99.65.167 (10.99.65.167)
    [Source GeoIP: Unknown]
    [Destination GeoIP: Unknown]
 User Datagram Protocol, Src Port: bootpc (68), Dst Port: bootps (67)
    Source port: bootpc (68)
    Destination port: bootps (67)
    Length: 424
    Checksum: 0x84b6 [validation disabled]
        [Good Checksum: False]
        [Bad Checksum: False]
 Bootstrap Protocol
    Message type: Boot Reply (2)
 ​
    Hardware type: Unknown(Oxef)
    Hardware address length: 176
    Hops: 560
    Transaction ID: 0x00010300
    Seconds elapsed: 27802
    Bootp flags: 0xae38 (Broadcast)
              0... .... .... .... = Broadcast flag: Broadcast
        .000 0000 0000 0000 = Reserved flags: 0x2e38
    Client IP address: 10.127.0.0 (10.127.0.0)
    Your (client) IP address: 10.16.0.1 (10.16.0.1)
    Next server IP address: 10.16.0.2 (10.16.0.2)
    Relay agent IP address: 1.0.0.0 (1.0.0.0)
    Client address not given
    Server host name not given
    Boot file name not given
    Bootp vendor specific options

参考标准

标准 描述
RFC 951 Bootstrap Protocol (BOOTP)
RFC 1542 Clarifications and Extensions for the Bootstrap Protocol