掃二維碼與項(xiàng)目經(jīng)理溝通
我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢(xún)/運(yùn)營(yíng)咨詢(xún)/技術(shù)建議/互聯(lián)網(wǎng)交流
Linux ifconfig命令用于顯示或設(shè)置網(wǎng)絡(luò)設(shè)備。ifconfig可設(shè)置網(wǎng)絡(luò)設(shè)備的狀態(tài),或是顯示目前的設(shè)置。

成都地區(qū)優(yōu)秀IDC服務(wù)器托管提供商(成都創(chuàng)新互聯(lián)).為客戶(hù)提供專(zhuān)業(yè)的棕樹(shù)數(shù)據(jù)中心,四川各地服務(wù)器托管,棕樹(shù)數(shù)據(jù)中心、多線(xiàn)服務(wù)器托管.托管咨詢(xún)專(zhuān)線(xiàn):13518219792
ifconfig
如果網(wǎng)卡被關(guān)閉了則不會(huì)被顯示出來(lái)。
ifconfig -a
ifconfig -s
ifconfig [網(wǎng)卡名稱(chēng)]
//例:ifconfig enp0s3
hrx@@@:~$ ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:bd:61:3c
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::7035:2dfa:8d80:ea7e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:115 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:930 (930.0 B) TX bytes:14560 (14.5 KB)
Interrupt:19 Base address:0xd020
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:32 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2386 (2.3 KB) TX bytes:2386 (2.3 KB)
這里以 enp0s3 網(wǎng)卡為例。當(dāng)網(wǎng)卡被關(guān)閉后使用 ifconfig 是不會(huì)顯示出來(lái)的。
//啟動(dòng)enp0s3網(wǎng)卡
sudo ifconfig enp0s3 up
//關(guān)閉enp0s3網(wǎng)卡
sudo ifconfig enp0s3 down
這里以 enp0s3 網(wǎng)卡為例。 ARP協(xié)議是地址解析協(xié)議(Address Resolution Protocol),每臺(tái)主機(jī)或路由器都維護(hù)著一份ARP緩存表(ARP table),這個(gè)表包含IP地址到MAC地址的映射關(guān)系,表中記錄了 對(duì),從而實(shí)現(xiàn)IP地址與MAC地址的查詢(xún)與轉(zhuǎn)換。 詳細(xì)的查看:https://blog.csdn.net/jiejiemcu/article/details/88406088
//啟動(dòng)enp0s3網(wǎng)卡的ARP協(xié)議
sudo ifconfig enp0s3 arp
//關(guān)閉enp0s3網(wǎng)卡的ARP協(xié)議
sudo ifconfig enp0s3 -arp
這里以 enp0s3 網(wǎng)卡為例。 子網(wǎng)掩碼換算: 24 與 255.255.255.0 是相等的,24意思是按二進(jìn)制算,從左開(kāi)始的24位全部取1,其余為0。 即 11111111 11111111 11111111 00000000,也就是255.255.255.0
//修改網(wǎng)卡 enp0s3 的 IPv4地址
sudo ifconfig enp0s3 10.0.2.16
//修改網(wǎng)卡 enp0s3 的 IPv4地址及子網(wǎng)掩碼,方法一
sudo ifconfig enp0s3 10.0.2.16/24
//修改網(wǎng)卡 enp0s3 的 IPv4地址及子網(wǎng)掩碼,方法二
sudo ifconfig enp0s3 10.0.2.16 netmask 255.255.255.0
這里以 enp0s3 網(wǎng)卡為例。 相當(dāng)于給網(wǎng)卡再配置一個(gè)IP地址。
sudo ifconfig enp0s3:0 10.0.2.16/24
sudo ifconfig enp0s3:1 10.0.2.17/24
sudo ifconfig enp0s3:2 10.0.2.18/24
在這里插入圖片描述
這里以 enp0s3 網(wǎng)卡為例。 注意:需要將網(wǎng)卡down掉后才能設(shè)置,否則會(huì)提示 “SIOCSIFHWADDR: 設(shè)備或資源忙 – you may need to down the interface”
//修改網(wǎng)卡的MAC地址
sudo ifconfig enp0s3 hw ether 08:00:27:bd:61:3d
在這里插入圖片描述
這里以 enp0s3 網(wǎng)卡為例。 單位是字節(jié)。
//設(shè)置網(wǎng)卡的最大傳輸單元
sudo ifconfig enp0s3 mtu 1480
這里以 enp0s3 網(wǎng)卡為例。
//增加網(wǎng)卡的IPv6地址
sudo ifconfig enp0s3 add fe80::7035:2dfa:8d80:ea7d/64
//刪除網(wǎng)卡的IPv6地址
sudo ifconfig enp0s3 del fe80::7035:2dfa:8d80:ea7d/64

我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢(xún)/運(yùn)營(yíng)咨詢(xún)/技術(shù)建議/互聯(lián)網(wǎng)交流