最近 打算配开发板的socket通讯,打印环境变量发现却没有 127.0.0.1

/ # ifconfig -a
eth0      Link encap:Ethernet  HWaddr 86:43:C9:A1:DF:C8  
          inet addr:192.168.1.140  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:21 Base address:0x4000 


lo        Link encap:Local Loopback  
          LOOPBACK  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B) 


查阅资料得知 需要手动配置本地回环路由lo 【 ifconfig lo up 

http://blog.csdn.net/liwentao1091/article/details/8276532


/ # ifconfig lo up

/ # ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:7D:85:2C  
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:17 Base address:0x2024 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:10070 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10070 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:87913017 (83.8 MiB)  TX bytes:87913017 (83.8 MiB)


          本地回环路由lo作用:

            一是测试本机的网络配置,能PING通127.0.0.1说明本机的网卡和IP协议安装都没有问题;

            另一个作用是某些SERVER/CLIENT的应用程序在运行时需调用服务器上的资源,一般要指定SERVER的IP地址,但当该程序要在同一台机器上运行而没有别的SERVER时就可以把SERVER的资源装在本机,SERVER的IP地址设为127.0.0.1也同样可以运行。






posted on 2014-11-17 18:27  醉依危栏听松涛  阅读(1411)  评论(0编辑  收藏  举报