Linux ifconfig命令:顯示或設(shè)置網(wǎng)絡(luò)設(shè)備參數(shù)信息
ifconfig命令來自于英文詞組”network interfaces configuring“的縮寫,其功能是用于顯示或設(shè)置網(wǎng)絡(luò)設(shè)備參數(shù)信息。在Windows系統(tǒng)中與之類似的命令叫做ipconfig,同樣的功能可以使用ifconfig去完成。
通常不建議使用ifconfig命令配置網(wǎng)絡(luò)設(shè)備的參數(shù)信息,因為一旦服務(wù)器重啟,配置過的參數(shù)會自動失效,還是編寫到配置文件中更穩(wěn)妥。
語法格式:ifconfig [參數(shù)] [網(wǎng)卡設(shè)備]
常用參數(shù):
add<地址> 設(shè)置網(wǎng)絡(luò)設(shè)備IPv6的IP地址
del<地址> 刪除網(wǎng)絡(luò)設(shè)備IPv6的IP地址
down 關(guān)閉指定的網(wǎng)絡(luò)設(shè)備
up 啟動指定的網(wǎng)絡(luò)設(shè)備
IP地址 指定網(wǎng)絡(luò)設(shè)備的IP地址
參考實例
顯示系統(tǒng)的網(wǎng)絡(luò)設(shè)備信息:
[root@linuxcool ~]# ifconfig
ens160: flags=4163<up,broadcast,running,multicast> mtu 1500
inet 192.168.10.30 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::4d16:980c:e0fe:51c2 prefixlen 64 scopeid 0x20
ether 00:0c:29:60:cd:ee txqueuelen 1000 (Ethernet)
RX packets 407 bytes 34581 (33.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 59 bytes 6324 (6.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
………………省略部分輸出信息………………</up,broadcast,running,multicast>
對指定的網(wǎng)卡設(shè)備依次進行關(guān)閉和啟動操作:
[root@linuxcool ~]# ifconfig ens160 down
[root@linuxcool ~]# ifconfig ens160 up
對指定的網(wǎng)卡設(shè)備執(zhí)行修改IP地址操作:
[root@linuxcool ~]# ifconfig ens160 192.168.10.20 netmask 255.255.255.0
對指定的網(wǎng)卡設(shè)備執(zhí)行修改MAC地址操作:
注意Linux系統(tǒng)中的MAC地址間隔符為冒號(:),而在Windows系統(tǒng)中間隔符為減號(-)。
[root@linuxcool ~]# ifconfig ens160 hw ether 00:aa:bb:cc:dd:ee
對指定的網(wǎng)卡設(shè)備依次進行ARP協(xié)議關(guān)閉和開啟操作:
[root@linuxcool ~]# ifconfig ens160 -arp
[root@linuxcool ~]# ifconfig ens160 arp
作者:大學生新聞網(wǎng) 來源:大學生新聞網(wǎng)