嵌入式Linux网络配置(hisi arm glibc)

    技术2022-05-20  50

    1. ifconfig lo 127.0.0.1 如果ping 127.0.0.1不同,证明回环设置不正确。

    可以通过ifconfig -a(或ifconfig)查看其中的lo选项

     

    # ifconfig lo lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:176 (176.0 B) TX bytes:176 (176.0 B)

    此为正常,否则需要ifconfig lo 127.0.0.1进行设置即可ping 通127.0.0.1

     

     

    2. 新建/etc/hosts文件(如果存在则只需修改)

    内容如下:127.0.0.1   localhost

     

    3. 建立/etc/resolv.conf(DNS域名服务器IP配置)

    内容可以从PC Linux上面copy过来,因为PC Linux和开发板链接Internet所需要的DNS域名是一致的

    示例内容可以如下:

    # Generated by NetworkManager nameserver 192.168.1.211 nameserver 192.168.1.213 nameserver 192.168.1.1

     

    4. 建立/etc/nsswitch.conf

    内容从PC Linux进行copy。

    示例内容如下:

    # Example configuration of GNU Name Service Switch functionality. # If you have the `glibc-doc-reference' and `info' packages installed, try: # `info libc "Name Service Switch"' for information about this file. passwd: compat group: compat shadow: compat hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 networks: files protocols: db files services: db files ethers: db files rpc: db files netgroup: nis

     

     

    5. 配置路由

    首先使用route进行查看所需要的网关是否已经被添加进去

    #route

    Kernel IP routing table Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 192.168.6.0     *               255.255.255.0   U     0      0        0 eth0

    可以获知当前网关被未被添加进去

     

    添加路由:

    route add default gw 192.168.6.1

     

    此时

    #route

    Kernel IP routing table Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 192.168.6.0     *               255.255.255.0   U     0      0        0 eth0 default         192.168.6.1     0.0.0.0         UG    0      0        0 eth0

     

     

     

    通过以上设置,开发板应该可以上网了。

    当然也可以将其写入脚本中,那么每次开机就不需要这样进行设置啦

    例如可以在/etc/profile中进行添加

     

     

     


    最新回复(0)