Linux 教程
Linux ifconfig命令用于顯示或設(shè)置網(wǎng)絡(luò)設(shè)備。
ifconfig可設(shè)置網(wǎng)絡(luò)設(shè)備的狀態(tài),或是顯示目前的設(shè)置。
ifconfig [網(wǎng)絡(luò)設(shè)備][down up -allmulti -arp -promisc][add<地址>][del<地址>][<hw<網(wǎng)絡(luò)設(shè)備類型><硬件地址>][io_addr<I/O地址>][irq<IRQ地址>][media<網(wǎng)絡(luò)媒介類型>][mem_start<內(nèi)存地址>][metric<數(shù)目>][mtu<字節(jié)>][netmask<子網(wǎng)掩碼>][tunnel<地址>][-broadcast<地址>][-pointopoint<地址>][IP地址]
參數(shù)說(shuō)明:
顯示網(wǎng)絡(luò)設(shè)備信息
# ifconfig eth0 Link encap:Ethernet HWaddr 00:50:56:0A:0B:0C inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:fe0a:b0c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:172220 errors:0 dropped:0 overruns:0 frame:0 TX packets:132379 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:87101880 (83.0 MiB) TX bytes:41576123 (39.6 MiB) Interrupt:185 Base address:0x2024 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:16436 Metric:1 RX packets:2022 errors:0 dropped:0 overruns:0 frame:0 TX packets:2022 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2459063 (2.3 MiB) TX bytes:2459063 (2.3 MiB)
啟動(dòng)關(guān)閉指定網(wǎng)卡
# ifconfig eth0 down # ifconfig eth0 up
為網(wǎng)卡配置和刪除IPv6地址
# ifconfig eth0 add 33ffe:3240:800:1005::2/ 64 //為網(wǎng)卡設(shè)置IPv6地址 # ifconfig eth0 del 33ffe:3240:800:1005::2/ 64 //為網(wǎng)卡刪除IPv6地址
用ifconfig修改MAC地址
# ifconfig eth0 down //關(guān)閉網(wǎng)卡 # ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //修改MAC地址 # ifconfig eth0 up //啟動(dòng)網(wǎng)卡 # ifconfig eth1 hw ether 00:1D:1C:1D:1E //關(guān)閉網(wǎng)卡并修改MAC地址 # ifconfig eth1 up //啟動(dòng)網(wǎng)卡
配置IP地址
# ifconfig eth0 192.168.1.56 //給eth0網(wǎng)卡配置IP地址 # ifconfig eth0 192.168.1.56 netmask 255.255.255.0 // 給eth0網(wǎng)卡配置IP地址,并加上子掩碼 # ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255 // 給eth0網(wǎng)卡配置IP地址,加上子掩碼,加上個(gè)廣播地址
啟用和關(guān)閉ARP協(xié)議
# ifconfig eth0 arp //開啟 # ifconfig eth0 -arp //關(guān)閉
設(shè)置最大傳輸單元
# ifconfig eth0 mtu 1500 //設(shè)置能通過(guò)的最大數(shù)據(jù)包大小為 1500 bytes其他擴(kuò)展