将Ubuntu 10.04 desktop系统做DHCP服务器的方法

        电脑上安装了Ubuntu 10.04 Desktop版的操作系统,但是现在需要用这台主机连接OMAP-L138的开发板,并给开发板分配IP地址。这是Server的活,桌面版系统无力。于是在系统上做了如下设置,成功在桌面版系统上实现了DHCP服务器。

1. 安装软件
使用dpkg –L dhcp-server查询软件是否安装,一般没有,我们如果可以上网就使用下列命令安装
sudo apt-get install dhcp3-server
如果不能上网就将系统光盘pool中的文件通过ssh复制到某目录后使用下列命令安装
sudo dpkg –i dhcp-server*.deb

2. 更改系统监听设备
使用命令
sudo cp /etc/default/dhcp3-server /etc/default/dhcp3-server_backup
做个备份
sudo chmod 646 /etc/default/dhcp3-server
更改权限
先用ifconfig查看你的网卡,一般是eth0
sudo vi /etc/default/dhcp3-server
搜寻这一行文字
...
INTERFACES=""
用下面这一行取代
INTERFACES="eth0"
保存编辑过的文件

3.3. 更改配置文件
系统规划:
假设 "eth0" 是我们的网卡编号,我们DHCP配置要求为:
IP Address Range: 192.168.0.100 to 192.168.0.200
Subnet Mask: 255.255.255.0
DNS Servers: 202.188.0.133, 202.188.1.5
Domai ns: main
Gateway Address: 192.168.0.1

具体步骤:
sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf_backup
做个备份
sudo chmod 646 /etc/dhcp3/dhcpd.conf
更改权限
sudo vi /etc/dhcp3/dhcpd.conf
搜寻这一段文字
...

# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;

...
用下面这几行取代
# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

#default-lease-time 600;
#max-lease-time 7200;
搜寻这一段文字
...

# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;

# default-lease-time 600;
# max-lease-time 7200;
#}

...
用下面这几行取代
# A slightly different configuration for an internal subnet.
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.200;
option domain-name-servers 192.168.0.2, 202.188.1.5;
option domain-name "main";
option routers 192.168.0.2;
option broadcast-address 192.168.0.255;
default-lease-time 6000;
max-lease-time 7200;
}
备注:默认default-lease-time 600标识600秒,太短,可以适当延长
保存编辑过的文件

4. 启动服务
sudo /etc/init.d/dhcp3-server restart
or
sudo service dhcp3-server restart
 
系统启动后出现错误,查看日志发现这样的信息:

No subnet declaration for eth0 (0.0.0.0).
** Ignoring requests on eth0. If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface eth0 is attached. **

查了资料,有人说是因为系统默认是DHCP自动分配IP,不是固定IP,所以产生这个问题。

于是设置本地网卡为固定IP地址。

sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0

重新启动服务,成功。

5. 验证

输入启动软件命令:minicom -w,进入minicom串口界面。

打开开发板电源,按任意键中止启动。输入请求dhcp配置命令:

u-boot $ dhcp

显示结果:

BOOTP broadcast 1

DHCP client bound to address 192.186.0.100

显示结果证明配置成功。

 

6. 题外记:OMAP-L138开发板出现的进一步问题

上面已经成果实现dhcp配置,继续进行如下操作:

u-boot :> dhcp

u-boot :> tftpboot 0xC0700000 ${bootfile}

u-boot :> sf probe 0

u-boot :> sf erase 0x080000 0x280000

u-boot :> sf write 0xC0700000 0x080000 0x280000

当执行到ftfpboot命令时,显示:“TFTP from server 192.168.0.1; our IP address is 192.168.0.100”,程序不能继续下载。

 

这时如果回到主机,执行ifconfig命令,会发现dhcp服务器也给主机自动分配了IP地址:192.168.0.101,这样之前的主机TFTP服务器地址与主机地址不一致,当然无法下载了。

 

解决方案是:在主机中重新执行脚本:host $ ${DVSDK}/bin/setup-uboot-env.sh,当提示输入TFTP的IP地址时,输入192.168.0.101。这样在目标板上就可以顺利下载了。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值