[讨论] X86学习之第一章以太网配置

fish001   2010-2-28 17:19 楼主


  1. 1.3.3 Network scripts
  2. Using the network scripts
  3. To be able to access the network functions, you need to include the necessary shell scripts by running:
  4. . /etc/functions.sh # common functions
  5. include /lib/network # include /lib/network/*.sh
  6. scan_interfaces # read and parse the network config
  7. Some protocols, such as PPP might change the configured interface names at run time (e.g. eth0 => ppp0 for PPPoE). That’s why you have to run scan_interfaces instead of reading the values from the config directly. After running scan_interfaces, the ’ifname’ option will always contain the effective interface name (which is used for IP traffic) and if the physical device name differs from it, it will be stored in the ’device’ option. That means that running config_get lan ifname after scan_interfaces might not return the same result as running it before.
  8. After running scan_interfaces, the following functions are available:
  9. find_config interface
  10. looks for a network configuration that includes the specified network interface.
  11. setup_interface interface [config] [protocol]
  12. will set up the specified interface, optionally overriding the network configuration name or the protocol that it uses.
  13. Writing protocol handlers
  14. You can add custom protocol handlers by adding shell scripts to /lib/network. They provide the following two shell functions:
  15. scan_() {
  16. local config="$1"
  17. # change the interface names if necessary
  18. }
  19. setup_interface_() {
  20. local interface="$1"
  21. local config="$2"
  22. # set up the interface
  23. }
  24. scan_protocolname is optional and only necessary if your protocol uses a custom device, e.g. a tunnel or a PPP device
by 南京老练

 

本帖最后由 paulhyde 于 2014-9-15 08:56 编辑

回复评论

暂无评论,赶紧抢沙发吧
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复