eth0代表第一個網(wǎng)卡,eth1代表第二個網(wǎng)卡,以此類推。lo代表回環(huán)接口,即localhost。wlan0代表無線網(wǎng)卡。執(zhí)行ifconfig命令后,系統(tǒng)會在內(nèi)核表中設(shè)置必要的參數(shù),讓Linux能夠與網(wǎng)絡(luò)上的網(wǎng)卡進(jìn)行通信。ifconfig有兩種命令格式:1. ifconfig [interface]2. ifconfig interface [aftype] option | address …第一種格式(即ifconfig命令不帶任何參數(shù))用于查看當(dāng)前系統(tǒng)的網(wǎng)絡(luò)配置情況。在剛安裝完系統(tǒng)后,通常是沒有網(wǎng)卡或網(wǎng)絡(luò)連接的情況下使用Linux。但通過ifconfig命令,可以使用回環(huán)方式工作,使計算機認(rèn)為自己工作在網(wǎng)絡(luò)上。現(xiàn)在我們運行ifconfig命令,不帶參數(shù)的ifconfig命令會顯示當(dāng)前啟動的網(wǎng)絡(luò)接口,輸出結(jié)果如下: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開頭的部分是本機的以太網(wǎng)卡配置參數(shù)。顯示了網(wǎng)卡設(shè)備名/dev/eth0和硬件的MAC地址52:54:AB:DD:6F:61。每個網(wǎng)卡都有一個唯一的MAC地址,由生產(chǎn)廠家指定。然而,我們可以手動更改網(wǎng)卡的MAC地址。只需要在/etc/rc.d/init.d/的network文件中添加以下內(nèi)容:ifconfig eth0 hw ether xx:xx:xx:xx:xx:xxJiania解釋:eth0,eth1,eth2代表第一個網(wǎng)卡,第二個網(wǎng)卡,第三個網(wǎng)卡hw代表硬件ether代表以太網(wǎng)然后重啟后,再運行ifconfig命令查看,會發(fā)現(xiàn)網(wǎng)卡的MAC地址已經(jīng)變成xx:xx:xx:xx:xx:xx。ifconfig配置網(wǎng)卡配置網(wǎng)卡的IP地址ifconfig eth0 192.168.0.1 netmask 255.255.255.0這樣就在eth0上配置了IP地址192.168.0.1,子網(wǎng)掩碼為255.255.255.0。如果還想在eth0上配置一個IP地址為192.168.1.1/24,可以使用以下命令:ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0這樣再運行ifconfig命令,就可以看到兩個網(wǎng)卡的信息,分別為eth0和eth0:0。如果要再增加IP地址,可以使用命名為eth0:1、eth0:2...的方式進(jìn)行??梢愿鶕?jù)需求設(shè)置幾個網(wǎng)卡。配置網(wǎng)卡的硬件地址ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx可以更改網(wǎng)卡的硬件地址,這樣就可以欺騙局域網(wǎng)中的IP地址綁定。禁用網(wǎng)卡ifconfig eth0 down啟用網(wǎng)卡ifconfig eth0 upifconfig命令還可以設(shè)置網(wǎng)卡的MTU和混雜模式等其他功能。