请教一个关于网络配置的问题,如图:


该网络连接图形界面中 有2个配置,其中System eth0 有对应的配置文件/etc/sysconfig/network-scripts/ifcfg-eth0,但是zhoucf这个配置是我手工在图形界面里添加的,它的对应的配置文件在哪里呢? 
 
我想在初始化linux有个纯净的网络配置,用命令行删除上面图中zhoucf配置 怎么办呢?
 
-----------------------------
 
 
find /root -type f -name "*" | xargs grep "zhoucf"
 
找到
/root/.gconf/system/networking/connections/2/connection/%gconf.xml: <stringvalue>zhoucf22</stringvalue>
/root/.gconf/system/networking/connections/1/connection/%gconf.xml: <stringvalue>zhoucf</stringvalue>
 
 
路径中的数字1和2分别代表第1个和第2个手工配置的网络设置,
 
进入文件夹1,ll显示内容如下:
[root@localhost Desktop]# cd /root/.gconf/system/networking/connections/1 
[root@localhost 1]# ll 
total 16 
drwx------. 2 root root 4096 Sep 7 17:11 802-3-ethernet 
drwx------. 2 root root 4096 Sep 7 17:11 connection 
-rw-------. 1 root root 0 Sep 7 16:48 %gconf.xml 
drwx------. 2 root root 4096 Sep 7 17:11 ipv4 
drwx------. 2 root root 4096 Sep 7 17:11 ipv6 
 
其中connection/%gconf.xml中配置了链接的名称id、uuid、type等内容,内容如下:
  1. <?xml version="1.0"?>
  2. <gconf>
  3. <entry name="timestamp" mtime="1410081115" type="string">
  4. <stringvalue>1410081115</stringvalue>
  5. </entry>
  6. <entry name="type" mtime="1410081115" type="string">
  7. <stringvalue>802-3-ethernet</stringvalue>
  8. </entry>
  9. <entry name="uuid" mtime="1410081115" type="string">
  10. <stringvalue>c0a50c06-f281-48ca-b1d5-6499ffb98b48</stringvalue>
  11. </entry>
  12. <entry name="id" mtime="1410081115" type="string">
  13. <stringvalue>zhoucf</stringvalue>
  14. </entry>
  15. <entry name="name" mtime="1410081115" type="string">
  16. <stringvalue>connection</stringvalue>
  17. </entry>
  18. </gconf>

 ipv4//%gconf.xml 中配置了ip地址、dns等内容,其中地址以ip倒序的数值形式表示

  1. <?xml version="1.0"?>
  2. <gconf>
  3. <entry name="routes" mtime="1410081115" type="list" ltype="int">
  4. </entry>
  5. <entry name="address-labels" mtime="1410081115" type="list" ltype="string">
  6. <li type="string">
  7. <stringvalue></stringvalue>
  8. </li>
  9. </entry>
  10. <entry name="addresses" mtime="1410081115" type="list" ltype="int">
  11. <li type="int" value="-939415360"/>
  12. <li type="int" value="24"/>
  13. <li type="int" value="16885952"/>
  14. </entry>
  15. <entry name="dns" mtime="1410081115" type="list" ltype="int">
  16. <li type="int" value="16885952"/>
  17. </entry>
  18. <entry name="method" mtime="1410081115" type="string">
  19. <stringvalue>manual</stringvalue>
  20. </entry>
  21. <entry name="name" mtime="1410081115" type="string">
  22. <stringvalue>ipv4</stringvalue>
  23. </entry>
  24. </gconf>

 java 计算代码:

  1. public class IpLong {
  2. /**
  3. * ip地址转成整数.
  4. * @param ip
  5. * @return
  6. */
  7. public static long ip2long(String ip) {
  8. String[] ips = ip.split("[.]");
  9. long num = 16777216L*Long.parseLong(ips[0]) + 65536L*Long.parseLong(ips[1]) + 256*Long.parseLong(ips[2]) + Long.parseLong(ips[3]);
  10. return num;
  11. }
  12. /**
  13. * 整数转成ip地址.
  14. * @param ipLong
  15. * @return
  16. */
  17. public static String long2ip(long ipLong) {
  18. //long ipLong = 1037591503;
  19. long mask[] = {0x000000FF,0x0000FF00,0x00FF0000,0xFF000000};
  20. long num = 0;
  21. StringBuffer ipInfo = new StringBuffer();
  22. for(int i=0;i<4;i++){
  23. num = (ipLong & mask[i])>>(i*8);
  24. if(i>0) ipInfo.insert(0,".");
  25. ipInfo.insert(0,Long.toString(num,10));
  26. }
  27. return ipInfo.toString();
  28. }
  29. public static void main(String[] args) {
  30. //System.out.println(ip2long("219.239.110.138"));
  31. System.out.println(ip2long("192.168.1.200"));//3232235976
  32. System.out.println(ip2long("200.1.168.192"));//3355551936
  33. System.out.println(long2ip(16885952));//16885952 在ipv4//%gconf.xml中 dns的配置
  34. //打印结果:-56.1.168.192
  35. System.out.println(long2ip(-939415360));//939415360 在ipv4//%gconf.xml中 addresses的配置
  36. //打印结果 -56.1.168.192 (其中 256-56=200) 通过计算得到200.1.168.192
  37. }
  38. }

 

总结:
1、配置linuxip的时候,设置ifcfg-eh0就行了,这是系统级别的,在图形界面手工配置的ip设置,是用户级别的,且重启后,系统会优先加载系统级别的配置
2、在分析过程中查找命令功不可没:
grep "zhoucf" -rl /root
find /root -type f -name "*" | xargs grep "zhoucf"
 
3、知道了NetworkManager 是怎么存放ip配置的,就可以放心配置ifcfg-ech0来配置网络设置了

最新文章

  1. 使用js进行string和json之间转换的方法
  2. Django基础——Model篇(三)
  3. Python流程控制语句(Control Flow)
  4. [求助]谁能给我讲解一下,iOS编程要如何实时显示采集到的图像???
  5. Delphi中的GetEnumName和GetEnumValue的使用方法
  6. mybatis12 Usermapper.xml
  7. 使用VTemplate模板引擎动态生成订单流程图
  8. js 计算某年某周日期范围
  9. 【ThinkingInC++】2、输入和输出流
  10. IIS发布mvc程序遇到的HTTP错误 403.14-Forbidden解决办法
  11. NET应用——使用RSA构建相对安全的数据交互
  12. android 分享一个处理BaseAdapter,getView()多次加载的方法
  13. 《JAVA程序设计与实例》记录与归纳--继承与多态
  14. 阿里云服务器 无法连接svn
  15. Node入门教程(1)目录
  16. kubernets controller 和 CRD 具体组件分析
  17. python+selenium滑动式验证码解决办法
  18. python 在.py文件中调用其他.py内的函数
  19. java fastJson
  20. VisualSVN server 搭建SVN服务器

热门文章

  1. 在Yii框架中使用PHPExcel
  2. paul的cnblog,欢迎大家的光临
  3. [转]C语言的那些秘密之---函数返回局部变量
  4. shell全备份脚本(借鉴别人的,在其基础上修复完善了bug)
  5. C语言基础06
  6. UVA 10375 Choose and divide
  7. View, Activity, Window
  8. mysql 匹配update
  9. OpenStack securityGroup rule Set
  10. Linux内核中常见内存分配函数(二)