WIKI使用導(dǎo)航
站長百科導(dǎo)航
站長專題
- 網(wǎng)站推廣
- 網(wǎng)站程序
- 網(wǎng)站賺錢
- 虛擬主機
- cPanel
- 網(wǎng)址導(dǎo)航專題
- 云計算
- 微博營銷
- 虛擬主機管理系統(tǒng)
- 開放平臺
- WIKI程序與應(yīng)用
- 美國十大主機
Ifconfig:修訂間差異
(→?參考來源) |
(→?語法) |
||
第2行: | 第2行: | ||
==Linux命令:ifconfig== | ==Linux命令:ifconfig== | ||
===語法=== | ===語法=== | ||
<pre> | |||
ifconfig [網(wǎng)絡(luò)設(shè)備][down up -allmulti -arp -promisc][add<地址>][del<地址>][<硬件地址>] [media<網(wǎng)絡(luò)媒介類型>][mem_start<[[內(nèi)存]]地址>][metric<數(shù)目>][mtu<字節(jié)>][netmask<[[子網(wǎng)掩碼]]>][tunnel<地址>][-broadcast<地址>] [-pointopoint<地址>] | ifconfig [網(wǎng)絡(luò)設(shè)備][down up -allmulti -arp -promisc][add<地址>][del<地址>][<硬件地址>] [media<網(wǎng)絡(luò)媒介類型>][mem_start<[[內(nèi)存]]地址>][metric<數(shù)目>][mtu<字節(jié)>][netmask<[[子網(wǎng)掩碼]]>][tunnel<地址>][-broadcast<地址>] [-pointopoint<地址>] | ||
</pre> | |||
? | |||
===補充說明=== | ===補充說明=== | ||
ifconfig可設(shè)置網(wǎng)絡(luò)設(shè)備的狀態(tài),或是顯示目前的設(shè)置。 | ifconfig可設(shè)置網(wǎng)絡(luò)設(shè)備的狀態(tài),或是顯示目前的設(shè)置。 |
2011年12月30日 (五) 11:57的版本
ifconfig是linux中用于顯示或配置網(wǎng)絡(luò)設(shè)備(網(wǎng)絡(luò)接口卡)的命令,英文全稱是network interfaces configuring。配置網(wǎng)卡的IP地址語法例:ifconfig eth0 192.168.0.1 netmask 255.255.255.0.
Linux命令:ifconfig
語法
ifconfig [網(wǎng)絡(luò)設(shè)備][down up -allmulti -arp -promisc][add<地址>][del<地址>][<硬件地址>] [media<網(wǎng)絡(luò)媒介類型>][mem_start<[[內(nèi)存]]地址>][metric<數(shù)目>][mtu<字節(jié)>][netmask<[[子網(wǎng)掩碼]]>][tunnel<地址>][-broadcast<地址>] [-pointopoint<地址>]
補充說明
ifconfig可設(shè)置網(wǎng)絡(luò)設(shè)備的狀態(tài),或是顯示目前的設(shè)置。
參數(shù)
- [網(wǎng)絡(luò)設(shè)備] 網(wǎng)絡(luò)設(shè)備的名稱。
- down 關(guān)閉指定的網(wǎng)絡(luò)設(shè)備。
- up 啟動指定的網(wǎng)絡(luò)設(shè)備。
- -arp 打開或關(guān)閉指定接口上使用的ARP協(xié)議。前面加上一個負號用于關(guān)閉該選項。
- -allmuti 關(guān)閉或啟動指定接口的無區(qū)別模式。前面加上一個負號用于關(guān)閉該選項。
- -promisc 關(guān)閉或啟動指定網(wǎng)絡(luò)設(shè)備的promiscuous模式。前面加上一個負號用于關(guān)閉該選項。
- add<地址> 設(shè)置網(wǎng)絡(luò)設(shè)備IPv6的IP地址。
- del<地址> 刪除網(wǎng)絡(luò)設(shè)備IPv6的IP地址。
- media<網(wǎng)絡(luò)媒介類型> 設(shè)置網(wǎng)絡(luò)設(shè)備的媒介類型。
- mem_start<內(nèi)存地址> 設(shè)置網(wǎng)絡(luò)設(shè)備在主內(nèi)存所占用的起始地址。
- metric<數(shù)目> 指定在計算數(shù)據(jù)包的轉(zhuǎn)送次數(shù)時,所要加上的數(shù)目。
- mtu<字節(jié)> 設(shè)置網(wǎng)絡(luò)設(shè)備的MTU。
- netmask<子網(wǎng)掩碼> 設(shè)置網(wǎng)絡(luò)設(shè)備的子網(wǎng)掩碼。
- tunnel<地址> 建立IPv4與IPv6之間的隧道通信地址。
- -broadcast<地址> 將要送往指定地址的數(shù)據(jù)包當成廣播數(shù)據(jù)包來處理。
- -pointopoint<地址> 與指定地址的網(wǎng)絡(luò)設(shè)備建立直接連線,此模式具有保密功能。
Linux中對網(wǎng)卡進行編輯的命令
無論是Linux 自動安裝還是我們手工安裝,Linux 都會向你詢問有關(guān)網(wǎng)絡(luò)的問題并配置相關(guān)的軟件。這個用于配置網(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 命令)可以用來查看當前系統(tǒng)的網(wǎng)絡(luò)配置情況。
在剛剛安裝完系統(tǒng)之后,實際上是在沒有網(wǎng)卡或者網(wǎng)絡(luò)連接的情況下使用Linux,但通過ifconfig 可以使用回繞方式工作,使計算機認為自己工作在網(wǎng)絡(luò)上。
現(xiàn)在我們運行一下ifconfig 命令,不帶參數(shù)的ifconfig 命令可以顯示當前啟動的網(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.1Mask: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ù),的設(shè)這里顯示了網(wǎng)卡的設(shè)備名/dev/eth0 和硬件的MAC 地址52:54:AB:DD:6F:61,MAC 地址是生產(chǎn)廠家定的,每個網(wǎng)卡擁有的唯一地址。
不過我們可以手工改動網(wǎng)卡的MAC 地址,只要我們在/etc/rc.d/init.d/中的network 中加入:
ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
注: eth0,eth1,eth2,代表網(wǎng)卡一,網(wǎng)卡二,網(wǎng)卡三
hw 代表hardware 硬件意思
ether 代表ethernet 以太網(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上配置上192.168.0.1 的IP地址及24位掩碼。若想再在eth0上在配置一個192.168.1.1/24 的IP地址怎么辦?用下面的命令
ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0
這時再用ifconifg命令查看,就可以看到兩個網(wǎng)卡的信息了,分別為:eth0和eth0:0.若還想再增加IP,那網(wǎng)卡的命名就接著是:eth0:1、eth0:2……想要幾個就填幾個。ok!
配置網(wǎng)卡的硬件地址
ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx就將網(wǎng)卡的硬件地址更改了,此時你就可以騙過局域網(wǎng)內(nèi)的IP地址邦定了。
將網(wǎng)卡禁用
ifconfig eth0 down
將網(wǎng)卡啟用
ifconfig eth0 up
ifconfig 命令的功能很強大,還可以設(shè)置網(wǎng)卡的MTU,混雜模式等。就不一一介紹了,用時間可以自己研究一下。