ifconfig命令可以用於查看Linux活動網卡與IP地址、子網路遮罩或者mac地址等資訊
- [root@localhost ~]# ifconfig
- eth0 Link encap:Ethernet HWaddr 08:00:27:D4:71:2D
- inet addr:192.168.1.104 Bcast:255.255.255.255 Mask:255.255.255.0
- inet6 addr: fe80::a00:27ff:fed4:712d/64 Scope:Link
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:1693 errors:0 dropped:0 overruns:0 frame:0
- TX packets:255 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:118346 (115.5 KiB) TX bytes:53987 (52.7 KiB)
- Interrupt:10 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:16436 Metric:1
- RX packets:7 errors:0 dropped:0 overruns:0 frame:0
- TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
- RX bytes:672 (672.0 b) TX bytes:672 (672.0 b)
eth0 是Linux主機的一塊網卡,lo是本地迴環
ifconfig eth0 up #可以用於啟動網卡
ifconfig eth0 down #可以用于禁用網卡
ifconfig eth0 192.168.1.101 #可以給主機制定靜態地址
如果要使用DHCP分配,可以使用dhclient命令
在終端直接輸入dhclient即可:)