工具/软件:Linux
目前、我有一个 BeagleBone 和一台 Windows 笔记本电脑通过开关连接在一起。
编辑了/etc/network/interfaces 以将静态 IP 地址分配给 eth0、即192.168.1.21。 文件的快照如下所示:
#/etc/network/interfaces -- ifup(8)、ifdown(8)的配置文件
编号
#环回接口
自动关闭
iface lo inet 环回
#无线接口
iface wlan0 inet DHCP
管理 Wireless_mode
Wireless_ESSID 任意
WPA 驱动程序 wext
wpa-conf /etc/wpa_supplicant.conf
iface tiwlan0 inet DHCP
管理 Wireless_mode
Wireless_ESSID 任意
iface atml0 inet DHCP
#有线或无线接口
auto-eth0
#iface eth0 inet DHCP
# pre-up /bin/grep -v -e "ip=[0-9]\+\.[0-9]\+.[0-9]\+.[0-9]\+"
#/proc/cmdline >/dev/null
# udhcpc_opts -R -b
#be ifcace eth0 (有线)
自动 eth0
#iface eth0 inet DHCP
iface eth0 inet static
地址192.168.1.21
子网掩码255.255.255.0
auto-eth0
#iface eth0 inet static
# 地址192.168.0.20
# 网络掩码255.255.255.0
# 网络192.168.0.0
#广播192.168.0.255
# 网关192.168.0.1
#pre-up /bin/grep -v -e "ip=[0-9]\+\.[0-9]\+.[0-9]\+.[0-9]\+"
iface eth1 inet DHCP
# EtherNet/RNDIS 小工具(g_ether)
#。 或者在主机端、usbnet 和随机 hwaddr
自动 usb0
iface usb0 inet static
地址192.168.7.2
子网掩码255.255.255.252
#蓝牙网络
iface bnep0 inet DHCP
++++++++++
然后修改/etc/udhcpd.conf 以从静态地址192.168.1.21 (下面的快照)运行 DHCP 服务器:
# udhcpd 配置文件示例(/etc/udhcpd.conf)
显示的#值为默认值
# IP 租用块的开始和结束
#start 192.168.0.20
结束 地址:192.168.0.254
启动 192.168.1.30
结束 192.168.1.254
# udhcpd 将使用的接口
接口 eth0
接口 wlan0
#租用的最大数目(包括保留的地址)
#(按报价、拒绝和 ARP 冲突)。 将被校正
#如果它大于 IP 租用块、则可以进行
#小于租用块。
#max_leases 254
Max_leases 100
#保留 IP 的时间(租给无人)
#如果收到 DHCP 拒绝消息(秒)
#decline time_3600
Decline time_3600
#保留 IP 的时间
#如果发生 ARP 冲突(秒)
Conflict_time 3600
#保留提供地址的时间(秒)
#Offer_Time 60.
Offer_Time 60.
#如果客户要求租赁低于此值,则将进行舍入
#至该值(秒)
#min_lease 60.
min_lease 60.
# pid 文件的位置
pidfile /var/run/udhcpd.pid
pidfile /var/run/udhcpd.pid
#租用文件的位置
#ley_file /var/lib/misc/udhcpd.leases
lear_file /var/lib/misc/udhcpd.leases
# udhcpd 将写出租约文件的时间段。
#如果这是0,udhcpd 将永远不会自动写入租用文件。
以秒为单位指定的#。
#auto_time 7200
AUTO_TIME 7200
#每次 udhcpd 写入租用文件时,将调用以下脚本
notify_file # default:无脚本
notify_file dumplebase #对于调试很有用
#notify_file #default:没有运行脚本
#以下是 BOOTP 特定选项
#引导中使用的下一个服务器
#siaddr 192.168.0.22# 默认值:0.0.0.0 (无)
# tftp 服务器名称
#sname zorak #默认值:无
要下载的# tftp 文件(例如内核映像)
boot_file /var/nfs_root # default:none
#静态租用映射
#static_lease 00:60:08:11:CE:4E 192.168.0.54
#static_lease 00:60:08:11:CE:3E 192.168.0.44
#其余的选项是 DHCP 选项,可通过指定
#关键字'opt'或'option'。 如果一个选项可以包含多个项目、例如
#作为 DNS 选项、它们可以列在同一行或多行中
#行。
#示例:
选择 DNS 8.8.8.8.8.8.4.4#public google DNS 服务器
子 网 255.255.255.0选项
#be:已注释掉 OPT 路由器 192.168.10.1
#opt 赢得 192.168.10.10
#option DNS 129.219.13.81 #附加到上述 DNS 服务器,总计3个
#option 域 本地
选项 租赁 864000 #默认值:10天
#十六进制形式的任意选项:
#be:Bashir 的评论
#option 0x08 01020304 #选项
8:
#"cookie
服务器 IP
地址:1.2.3.4"
#当前支持的选项(有关更多信息、请参阅 options.c):
#opt lease NUM
#opt 子网 IP
注意:已注释掉 OPT 路由器 192.168.10.1
#opt 赢得 192.168.10.10
#option DNS 129.219.13.81 #附加到上述 DNS 服务器,总计3个
#option 域 本地
选项 租赁 864000 #默认值:10天
#十六进制形式的任意选项:
#be:Bashir 的评论
#option 0x08 01020304 #选项
8:
#"cookie
服务器 IP
地址:1.2.3.4"
#当前支持的选项(有关更多信息、请参阅 options.c):
#opt lease NUM
#opt 子网 IP
#opt 广播 IP
#opt router IP_list
#optipttl NUM
#OPT MTU NUM
#opt hostname string # client 的 hostname
#opt 域 字符串 #客户端的域后缀
#opt search string_list # search domain
#opt nisdomain 字符串
#opt timezone NUM #(localtime - UTC_time)(以秒为单位)。 已签名
#opt tftp 字符串 # tftp 服务器名称
#opt bootfile string #要下载的 tftp 文件(例如内核映像)
#opt bootsize 该 文件的 NUM # size
#opt rootpath 字符串 #(NFS)路径,以根 FS 的形式装入
#OPT WPAD 字符串
#opt serverid ip # default:服务器的 IP
#opt 消息 字符串 #错误消息(udhcpd 也会在成功时发送)
#opt vlanid NUM # 802.1p VLAN ID
#opt vlanpriority NUM # 802.1Q VLAN priority
#个选项指定服务器
#opt DNS IP_list
#opt 赢得 IP_list
op#nissrv ip_list
#opt ntpsrv ip_list
#opt lprsrv ip_list
++++++++++++++++++++++++++++++++++++
如果在重新启动后我运行/etc/init.d/networking 重置、则 eth0获取静态 IP 地址。
ps -e 显示 udhcpd 正在运行:
root@AM335x-EVM:/etc/network ps -e | grep udhc
869? 00:00:00 udhcpd
++++++++++++++++++++++++++++++++++
我重新启动 Windows 笔记本电脑并检查 IP 地址。 我希望能看到192.168.1.30中的分配 --- 254范围。 但我看到的 是自动配置或192.168.56.1
希望获得解决方案或见解。
此致