zoukankan      html  css  js  c++  java
  • 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!)

  • 相关阅读:
    学习web前端怎样入门?初学者赶紧看过来!
    web前端教程:CSS 布局十八般武艺都在这里了
    [zhuan]arm中的汇编指令
    adb命令
    [zhuan]使用uiautomator做UI测试
    [zhuan]java发送http的get、post请求
    Android 关于“NetworkOnMainThreadException”出错提示的原因及解决办法
    android getpost代码
    [转]Android 如何根据网络地址获取网络图片方法
    Android Json解析与总结
  • 原文地址:https://www.cnblogs.com/dolphi/p/3315486.html
Copyright © 2011-2022 走看看