亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Linux ifconfig命令詳解和使用示例(Linux網(wǎng)絡(luò)參數(shù)配置和查看)

  發(fā)布時間:2014-04-10 15:17:39   作者:佚名   我要評論
許多windows非常熟悉ipconfig命令行工具,它被用來獲取網(wǎng)絡(luò)接口配置信息并對此進行修改。Linux系統(tǒng)擁有一個類似的工具,也就是ifconfig(interfaces config)

通常需要以root身份登錄或使用sudo以便在Linux機器上使用ifconfig工具。依賴于ifconfig命令中使用一些選項屬性,ifconfig工具不僅可以被用來簡單地獲取網(wǎng)絡(luò)接口配置信息,還可以修改這些配置。

1.命令格式:

ifconfig [網(wǎng)絡(luò)設(shè)備] [參數(shù)]

2.命令功能:

ifconfig 命令用來查看和配置網(wǎng)絡(luò)設(shè)備。當網(wǎng)絡(luò)環(huán)境發(fā)生改變時可通過此命令對網(wǎng)絡(luò)進行相應(yīng)的配置。

3.命令參數(shù):

up 啟動指定網(wǎng)絡(luò)設(shè)備/網(wǎng)卡。

down 關(guān)閉指定網(wǎng)絡(luò)設(shè)備/網(wǎng)卡。該參數(shù)可以有效地阻止通過指定接口的IP信息流,如果想永久地關(guān)閉一個接口,我們還需要從核心路由表中將該接口的路由信息全部刪除。

arp 設(shè)置指定網(wǎng)卡是否支持ARP協(xié)議。

-promisc 設(shè)置是否支持網(wǎng)卡的promiscuous模式,如果選擇此參數(shù),網(wǎng)卡將接收網(wǎng)絡(luò)中發(fā)給它所有的數(shù)據(jù)包

-allmulti 設(shè)置是否支持多播模式,如果選擇此參數(shù),網(wǎng)卡將接收網(wǎng)絡(luò)中所有的多播數(shù)據(jù)包

-a 顯示全部接口信息

-s 顯示摘要信息(類似于 netstat -i)

add 給指定網(wǎng)卡配置IPv6地址

del 刪除指定網(wǎng)卡的IPv6地址

<硬件地址> 配置網(wǎng)卡最大的傳輸單元

mtu<字節(jié)數(shù)> 設(shè)置網(wǎng)卡的最大傳輸單元 (bytes)

netmask<子網(wǎng)掩碼> 設(shè)置網(wǎng)卡的子網(wǎng)掩碼。掩碼可以是有前綴0x的32位十六進制數(shù),也可以是用點分開的4個十進制數(shù)。如果不打算將網(wǎng)絡(luò)分成子網(wǎng),可以不管這一選項;如果要使用子網(wǎng),那么請記住,網(wǎng)絡(luò)中每一個系統(tǒng)必須有相同子網(wǎng)掩碼。

tunel 建立隧道

dstaddr 設(shè)定一個遠端地址,建立點對點通信

-broadcast<地址> 為指定網(wǎng)卡設(shè)置廣播協(xié)議

-pointtopoint<地址> 為網(wǎng)卡設(shè)置點對點通訊協(xié)議

multicast 為網(wǎng)卡設(shè)置組播標志

address 為網(wǎng)卡設(shè)置IPv4地址

txqueuelen<長度> 為網(wǎng)卡設(shè)置傳輸列隊的長度

4.使用實例:

實例1:顯示網(wǎng)絡(luò)設(shè)備信息(激活狀態(tài)的)

命令:ifconfig

輸出:

 

復(fù)制代碼
代碼如下:

[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:20
inet addr:192.168.120.204 Bcast:192.168.120.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0
TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7 MiB)</p> <p>lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:68 errors:0 dropped:0 overruns:0 frame:0
TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2856 (2.7 KiB) TX bytes:2856 (2.7 KiB)

說明:

eth0 表示第一塊網(wǎng)卡, 其中 HWaddr 表示網(wǎng)卡的物理地址,可以看到目前這個網(wǎng)卡的物理地址(MAC地址)是 00:50:56:BF:26:20

inet addr 用來表示網(wǎng)卡的IP地址,此網(wǎng)卡的 IP地址是 192.168.120.204,廣播地址, Bcast:192.168.120.255,掩碼地址Mask:255.255.255.0 

lo 是表示主機的回壞地址,這個一般是用來測試一個網(wǎng)絡(luò)程序,但又不想讓局域網(wǎng)或外網(wǎng)的用戶能夠查看,只能在此臺主機上運行和查看所用的網(wǎng)絡(luò)接口。比如把 HTTPD服務(wù)器的指定到回壞地址,在瀏覽器輸入 127.0.0.1 就能看到你所架WEB網(wǎng)站了。但只是您能看得到,局域網(wǎng)的其它主機或用戶無從知道。

第一行:連接類型:Ethernet(以太網(wǎng))HWaddr(硬件mac地址)

第二行:網(wǎng)卡的IP地址、子網(wǎng)、掩碼

第三行:UP(代表網(wǎng)卡開啟狀態(tài))RUNNING(代表網(wǎng)卡的網(wǎng)線被接上)MULTICAST(支持組播)MTU:1500(最大傳輸單元):1500字節(jié)

第四、五行:接收、發(fā)送數(shù)據(jù)包情況統(tǒng)計

第七行:接收、發(fā)送數(shù)據(jù)字節(jié)數(shù)統(tǒng)計信息。

實例2:啟動關(guān)閉指定網(wǎng)卡

命令:

復(fù)制代碼
代碼如下:

ifconfig eth0 up
ifconfig eth0 down

說明:

ifconfig eth0 up 為啟動網(wǎng)卡eth0 ;ifconfig eth0 down 為關(guān)閉網(wǎng)卡eth0。ssh登陸linux服務(wù)器操作要小心,關(guān)閉了就不能開啟了,除非你有多網(wǎng)卡。

實例3:為網(wǎng)卡配置和刪除IPv6地址

命令:


復(fù)制代碼
代碼如下:

ifconfig eth0 add 33ffe:3240:800:1005::2/64
ifconfig eth0 del 33ffe:3240:800:1005::2/64

說明:

ifconfig eth0 add 33ffe:3240:800:1005::2/64 為網(wǎng)卡eth0配置IPv6地址;

ifconfig eth0 add 33ffe:3240:800:1005::2/64 為網(wǎng)卡eth0刪除IPv6地址;

練習的時候,ssh登陸linux服務(wù)器操作要小心,關(guān)閉了就不能開啟了,除非你有多網(wǎng)卡。

實例4:用ifconfig修改MAC地址

命令:ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE

輸出:


復(fù)制代碼
代碼如下:

[root@localhost ~]# ifconfig eth0 down //關(guān)閉網(wǎng)卡
[root@localhost ~]# ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //修改MAC地址
[root@localhost ~]# ifconfig eth0 up //啟動網(wǎng)卡
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:AA:BB:CC:DD:EE
inet addr:192.168.120.204 Bcast:192.168.120.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0
TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7 MiB)</p> <p>lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:68 errors:0 dropped:0 overruns:0 frame:0
TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2856 (2.7 KiB) TX bytes:2856 (2.7 KiB)
[root@localhost ~]# ifconfig eth0 hw ether 00:50:56:BF:26:20 //關(guān)閉網(wǎng)卡并修改MAC地址
[root@localhost ~]# ifconfig eth0 up //啟動網(wǎng)卡
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:20
inet addr:192.168.120.204 Bcast:192.168.120.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0
TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7 MiB)</p> <p>lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:68 errors:0 dropped:0 overruns:0 frame:0
TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2856 (2.7 KiB) TX bytes:2856 (2.7 KiB)

實例5:配置IP地址

命令:


復(fù)制代碼
代碼如下:

[root@localhost ~]# ifconfig eth0 192.168.120.56
[root@localhost ~]# ifconfig eth0 192.168.120.56 netmask 255.255.255.0
[root@localhost ~]# ifconfig eth0 192.168.120.56 netmask 255.255.255.0 broadcast 192.168.120.255

說明:

ifconfig eth0 192.168.120.56 

給eth0網(wǎng)卡配置IP地:192.168.120.56

ifconfig eth0 192.168.120.56 netmask 255.255.255.0 

給eth0網(wǎng)卡配置IP地址:192.168.120.56 ,并加上子掩碼:255.255.255.0

ifconfig eth0 192.168.120.56 netmask 255.255.255.0 broadcast 192.168.120.255

給eth0網(wǎng)卡配置IP地址:192.168.120.56,加上子掩碼:255.255.255.0,加上個廣播地址: 192.168.120.255

實例6:啟用和關(guān)閉ARP協(xié)議

命令:


復(fù)制代碼
代碼如下:

ifconfig eth0 arp
ifconfig eth0 -arp

輸出:


復(fù)制代碼
代碼如下:

[root@localhost ~]# ifconfig eth0 arp
[root@localhost ~]# ifconfig eth0 -arp

說明:

ifconfig eth0 arp 開啟網(wǎng)卡eth0 的arp協(xié)議;

ifconfig eth0 -arp 關(guān)閉網(wǎng)卡eth0 的arp協(xié)議;

實例7:設(shè)置最大傳輸單元

命令:ifconfig eth0 mtu 1500

輸出:


復(fù)制代碼
代碼如下:

[root@localhost ~]# ifconfig eth0 mtu 1480
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:1F
inet addr:192.168.120.203 Bcast:192.168.120.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1480 Metric:1
RX packets:8712395 errors:0 dropped:0 overruns:0 frame:0
TX packets:36631 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:597062089 (569.4 MiB) TX bytes:2643973 (2.5 MiB)</p> <p>lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:9973 errors:0 dropped:0 overruns:0 frame:0
TX packets:9973 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:518096 (505.9 KiB) TX bytes:518096 (505.9 KiB)</p> <p>[root@localhost ~]# ifconfig eth0 mtu 1500
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:1F
inet addr:192.168.120.203 Bcast:192.168.120.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8712548 errors:0 dropped:0 overruns:0 frame:0
TX packets:36685 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:597072333 (569.4 MiB) TX bytes:2650581 (2.5 MiB)</p> <p>lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:9973 errors:0 dropped:0 overruns:0 frame:0
TX packets:9973 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:518096 (505.9 KiB) TX bytes:518096 (505.9 KiB)</p> <p>[root@localhost ~]#

說明:

設(shè)置能通過的最大數(shù)據(jù)包大小為 1500 bytes

備注:用ifconfig命令配置的網(wǎng)卡信息,在網(wǎng)卡重啟后機器重啟后,配置就不存在。要想將上述的配置信息永遠的存的電腦里,那就要修改網(wǎng)卡的配置文件了。

相關(guān)文章

  • redhat linux enterprise 5 輸入ifconfig無效的解決方法

    在安裝完成linux后,進入終端,輸入命令行ifconfig,會提示bash: ifconfig: command not found。這是因為在我們的環(huán)境變量里,還沒有設(shè)置完整變量
    2012-10-13
  • solaris系統(tǒng)下更改IP地址

    1、ifconfig命令暫時修改   ifconfig用來配置網(wǎng)卡的IP地址,改動后即生效, 但并不保存,下次啟動后失效。   #ifconfig -a      &nbs
    2008-09-08
  • solaris網(wǎng)絡(luò)和IP設(shè)置基礎(chǔ)

    /etc/hostname.interface Interface是網(wǎng)卡的型號,有l(wèi)e、hme等。Le是十兆網(wǎng)卡,hme為百兆網(wǎng)卡等等。后面跟一個數(shù)字,第一個十兆網(wǎng)卡為le0,第二個為le1;第二個百兆網(wǎng)卡
    2008-09-08
  • 一些 freebsd 的常用命令

    1 man 在線查詢 man ls 2 ls 查看目錄與檔案 ls -la 3 ln 建立鏈接文件 ln -fs /usr/local/apache/etc/httpd.conf /etc/httpd.conf 4
    2008-09-08
  • Linux系統(tǒng)網(wǎng)絡(luò)配置詳細說明

    這篇文章主要介紹了Linux系統(tǒng)中網(wǎng)絡(luò)配置的介紹,需要的朋友可以參考下
    2014-04-02
  • Linux系統(tǒng)下ifconfig命令使用說明

    用Linux ifconfig命令配置的網(wǎng)卡信息,在網(wǎng)卡重啟后機器重啟后,配置就不存在。要想將下述的配置信息永遠的存的電腦里,那就要修改網(wǎng)卡的配置文件了
    2012-10-22

最新評論