41. 命令: ifconfig
ifconfig用來配置常駐內核的網絡接口信息。在系統啟動必要時用來設置網絡適配器的信息。之後,它通常是只需要在調試時或當系統需要調整時使用。
檢查活動網絡適配器
- [avishek@tecmint ~]___FCKpd___0nbsp;ifconfig
- eth0 Link encap:Ethernet HWaddr 40:2C:F4:EA:CF:0E
- inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
- inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:163843 errors:0 dropped:0 overruns:0 frame:0
- TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:154389832 (147.2 MiB) TX bytes:65085817 (62.0 MiB)
- Interrupt:20 Memory:f7100000-f7120000
- 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:78 errors:0 dropped:0 overruns:0 frame:0
- TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
- RX bytes:4186 (4.0 KiB) TX bytes:4186 (4.0 KiB)
檢查所有的網絡適配器
“-a”參數用來顯示所有網絡適配器(網卡)的詳細信息,包括那些停用的適配器。
- [avishek@tecmint ~]___FCKpd___1nbsp;ifconfig -a
- eth0 Link encap:Ethernet HWaddr 40:2C:F4:EA:CF:0E
- inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
- inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:163843 errors:0 dropped:0 overruns:0 frame:0
- TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:154389832 (147.2 MiB) TX bytes:65085817 (62.0 MiB)
- Interrupt:20 Memory:f7100000-f7120000
- 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:78 errors:0 dropped:0 overruns:0 frame:0
- TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
- RX bytes:4186 (4.0 KiB) TX bytes:4186 (4.0 KiB)
- virbr0 Link encap:Ethernet HWaddr 0e:30:a3:3a:bf:03
- inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
- UP BROADCAST MULTICAST MTU:1500 Metric:1
- RX packets:0 errors:0 dropped:0 overruns:0 frame:0
- TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
- RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
停用網絡適配器
- [avishek@tecmint ~]___FCKpd___2nbsp;ifconfig eth0 down
啟用網絡適配器
- [avishek@tecmint ~]___FCKpd___3nbsp;ifconfig eth0 up
指定IP地址到網絡適配器
為網絡適配器eth0設定IP地址“192.168.1.12”.
- [avishek@tecmint ~]___FCKpd___4nbsp;ifconfig eth0 192.168.1.12
更改網絡適配器eth0的子網掩碼:
- [avishek@tecmint ~]___FCKpd___5nbsp;ifconfig eth0 netmask 255.255.255.
更改網絡適配器eth0的廣播地址:
- [avishek@tecmint ~]___FCKpd___6nbsp;ifconfig eth0 broadcast 192.168.1.255
為網絡適配器eth0指定IP地址,子網掩碼,廣播地址:
- [avishek@tecmint ~]___FCKpd___7nbsp;ifconfig eth0 192.168.1.12 netmask 255.255.255.0 broadcast 192.168.1.255
注Note: 如果你設置一塊無線網卡的信息,你可以使用的命令是“iwconfig”.欲知更多ifconfig命令的例子和使用方法。