技術(shù)員聯(lián)盟提供win764位系統(tǒng)下載,win10,win7,xp,裝機(jī)純凈版,64位旗艦版,綠色軟件,免費(fèi)軟件下載基地!

當(dāng)前位置:主頁 > 教程 > 服務(wù)器類 >

Linux操作系統(tǒng)Ifconfig命令詳細(xì)解析

來源:技術(shù)員聯(lián)盟┆發(fā)布時(shí)間:2019-03-08 00:23┆點(diǎn)擊:

  無論是Linux 自動(dòng)安裝還是我們手工安裝,Linux 都會(huì)向你詢問有關(guān)網(wǎng)絡(luò)的問題并配置相關(guān)的軟件。這個(gè)用于配置網(wǎng)卡的基本命令就是ifconfig。

  在執(zhí)行ifconfig 命令后,系統(tǒng)將在內(nèi)核表中設(shè)置必要的參數(shù),這樣Linux 就知道如何與網(wǎng)絡(luò)上的網(wǎng)卡通信。ifconfig 命令有以下兩種格式:

  ※ifconfig [interface]

  ※ifconfig interface [aftype] option | address …

  ifconfig 的第一種格式(或使用不帶任何參數(shù)的ifconfig 命令)可以用來查看當(dāng)前系統(tǒng)的網(wǎng)絡(luò)配置情況。

  在剛剛安裝完系統(tǒng)之后,實(shí)際上是在沒有網(wǎng)卡或者網(wǎng)絡(luò)連接的情況下使用Linux,但通過ifconfig 可以使用回繞方式工作,使計(jì)算機(jī)認(rèn)為自己工作在網(wǎng)絡(luò)上。

  現(xiàn)在我們運(yùn)行一下ifconfig 命令,不帶參數(shù)的ifconfig 命令可以顯示當(dāng)前啟動(dòng)的網(wǎng)絡(luò)接口,其輸出結(jié)果為:

  [root@machine1 /sbin]#ifconfig

  eth0 Link encap:Ethernet Hwaddr 52:54:AB:DD:6F:61

  inet addr:210.34.6.89 Bcast:210.34.6.127 Mask:255.255.255.128

  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

  RX packets:46299 errors:0 dropped:0 overruns:0 frame:189

  TX packets:3057 errors:0 dropped:0 overruns:0 carrier:0

  collisions:0 txqueuelen:100

  Interrupt:5 Base address:0xece0

  lo Link encap:Local Loopback

  inet addr:127.0.0.1 Mask:255.0.0.0

  UP LOOPBACK RUNNING MTU:3924 Metric:1

  RX packets:44 errors:0 dropped:0 overruns:0 frame:0

  TX packets:44 errors:0 dropped:0 overruns:0 carrier:0

  collisions:0 txqueuelen:0

  其中以eth0 為首的部分是本機(jī)的以太網(wǎng)卡配置參數(shù),這里顯示了網(wǎng)卡在下的設(shè)備名/dev/eth0 和硬件的MAC 地址52:54:AB:DD:6F:61,MAC 地址是生產(chǎn)廠家定的,每個(gè)網(wǎng)卡擁有的唯一地址。

  不過我們可以手工改動(dòng)網(wǎng)卡的MAC 地址,只要我們?cè)?etc/rc.d/init.d/中的network 中加入:

  ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx

  然后重啟,此時(shí)再用ifconfig 命令查看一下,我們就會(huì)發(fā)現(xiàn)網(wǎng)卡的MAC 地址已經(jīng)變成xx:xx:xx:xx:xx:xx了。

  后繼 常用網(wǎng)卡ip設(shè)置方法:

  直接通過setup 進(jìn)行設(shè)置。

  配置多個(gè)網(wǎng)卡 ifconfig -a 查看網(wǎng)絡(luò)設(shè)備 eth0 / eth1 / lo (回路)。

  ifconfig eth1 //設(shè)備1

  ifconfig eth1 192.168.1.10 netmask 255.255.255.0 //設(shè)置網(wǎng)卡子網(wǎng)及ip

  man ifconfig

  ifconfig --help(T002)