centos6.5圖形介面NetworkManager 配置ip檔案位置

來源:互聯網
上載者:User

標籤:

 請教一個關於網路設定的問題,


該網路連接圖形介面中 有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顯示內容如下:[[email protected] Desktop]# cd /root/.gconf/system/networking/connections/1 
[[email protected] 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等內容,內容如下:Xml代碼  
  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倒序的數值形式表示Xml代碼  
  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 計算代碼: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.     /** 
  14.      * 整數轉成ip地址. 
  15.      * @param ipLong 
  16.      * @return 
  17.      */  
  18.     public static String long2ip(long ipLong) {  
  19.         //long ipLong = 1037591503;  
  20.         long mask[] = {0x000000FF,0x0000FF00,0x00FF0000,0xFF000000};  
  21.         long num = 0;  
  22.         StringBuffer ipInfo = new StringBuffer();  
  23.         for(int i=0;i<4;i++){  
  24.             num = (ipLong & mask[i])>>(i*8);  
  25.             if(i>0) ipInfo.insert(0,".");  
  26.             ipInfo.insert(0,Long.toString(num,10));  
  27.         }  
  28.         return ipInfo.toString();  
  29.     }  
  30.     public static void main(String[] args) {  
  31.   //System.out.println(ip2long("219.239.110.138"));  
  32.      System.out.println(ip2long("192.168.1.200"));//3232235976  
  33.      System.out.println(ip2long("200.1.168.192"));//3355551936  
  34.      System.out.println(long2ip(16885952));//16885952 在ipv4//%gconf.xml中 dns的配置  
  35.         //列印結果:-56.1.168.192  
  36.      System.out.println(long2ip(-939415360));//939415360 在ipv4//%gconf.xml中 addresses的配置  
  37.         //列印結果 -56.1.168.192 (其中 256-56=200) 通過計算得到200.1.168.192  
  38.        
  39.  }  
  40. }  
  總結: 1、配置linuxip的時候,設定ifcfg-eh0就行了,這是系統層級的,在圖形介面手工配置的ip設定,是使用者層級的,且重啟後,系統會優先載入系統層級的配置 2、在分析過程中尋找命令功不可沒: grep "zhoucf" -rl /root find /root -type f -name "*" | xargs grep "zhoucf"  3、知道了NetworkManager 是怎麼存放ip配置的,就可以放心配置ifcfg-ech0來配置網路設定了

centos6.5圖形介面NetworkManager 配置ip檔案位置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.