beaglebone-black 在Angstrom系统中的网络配置方法

Beaglebone Linux 101: Assigning a Static IP Address with Connman

My article on configuring Angstrom Linux included instructions for setting a static IP address. Sometime after posting that article, I realized that the instructions work great unless you happen to reboot. Then, the settings reverted to the default of using a DHCP server.

Ooops!

It turns out that this sleight-of-hand is the work, aptly enough, of a package namedConnman.

This newfangled connection manager is, in some ways, a good fit for the Beaglebone, since it was designed to run on memory-constrained embedded Linux systems. It was originally developed for use on 2 Linux platforms that have struggled, Meego and Moblin, but we won’t hold that against it.

However, Connman presents one big problem for Beaglebone users: it’s rather difficult to configure from the command line.

It doesn’t come with a command line configuration tool, but it does provide some well documented APIs that command line applications can use. As such, the best command line interface right now can be found in a package intended to test that the APIs are working correctly: connman-tests.

To install the package:

opkg install connman-tests

This will install a set of Python scripts in /usr/lib/connman/test.

To check your current configuration:

cd /usr/lib/connman/test/
./get-services

The output should look like the following:

[ /net/connman/service/ethernet_405fc276b749_cable ]
 IPv6.Configuration = { Method=auto Privacy=disabled }
 AutoConnect = false
 Proxy.Configuration = { }
 Name = Wired
 Nameservers = [ 206.47.244.104 206.47.199.155 ]
 Provider = { }
 Favorite = true
 Domains.Configuration = [ ]
 State = online
 Proxy = { Method=direct }
 Nameservers.Configuration = [ ]
 LoginRequired = 0
 IPv6 = { }
 Domains = [ lan ]
 Ethernet = { Interface=eth0 MTU=1500 Method=auto 
Address=xx:xx:xx:xx:xx:xx }
 Security = [ ]
 IPv4.Configuration = { Method=dhcp }
 Type = ethernet
 Immutable = false
 IPv4 = { Netmask=255.255.255.0 Gateway=192.168.1.1 
Method=dhcp Address=192.168.1.161 }

The important thing to note here is the service ID at the top of the output, in my case  ethernet_405fc276b749_cable.  (Dumb name for an ethernet cable, if you ask me.)

You can also get the DNS nameserver and gateway IP addresses from this output, if you don’t already know them.

To change the configuration, you use 2 other scripts, set-ipv4-method and set-nameservers.

The syntax for set-ipv4-method is:

./set-ipv4-method <service> [off|dhcp|manual <address> [netmask] [gateway]]

The service parm is that long string that appears at the top of the output from the get-services script.

So, to set the Beaglebone to use a static IP address of 192.168.1.2, with a gateway of 192.168.1.1, I entered:

./set-ipv4-method ethernet_405fc276b749_cable manual 
192.168.1.2 255.255.255.0 192.168.1.1

To set the DNS nameservers, use set-nameservers.  The syntax is:

./set-nameservers <service> [nameserver*]

In my case, I entered

./set-nameservers ethernet_405fc276b749_cable 206.47.244.104 
206.47.199.155

That’s it: after entering those 2 commands, you’ll be running with the new network settings, no reboot required. (Though, if you plan to blog about it, a reboot is definitely recommended!)

转载于:https://www.cnblogs.com/dolphi/p/3315486.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值