ifconfig命令可以用于查看Linux活动网卡与IP地址、子网掩码或者mac地址等信息

  1. [root@localhost ~]# ifconfig  
  2. eth0      Link encap:Ethernet  HWaddr 08:00:27:D4:71:2D    
  3.           inet addr:192.168.1.104  Bcast:255.255.255.255  Mask:255.255.255.0  
  4.           inet6 addr: fe80::a00:27ff:fed4:712d/64 Scope:Link  
  5.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  
  6.           RX packets:1693 errors:0 dropped:0 overruns:0 frame:0  
  7.           TX packets:255 errors:0 dropped:0 overruns:0 carrier:0  
  8.           collisions:0 txqueuelen:1000   
  9.           RX bytes:118346 (115.5 KiB)  TX bytes:53987 (52.7 KiB)  
  10.           Interrupt:10 Base address:0xd020   
  11.   
  12. lo        Link encap:Local Loopback    
  13.           inet addr:127.0.0.1  Mask:255.0.0.0  
  14.           inet6 addr: ::1/128 Scope:Host  
  15.           UP LOOPBACK RUNNING  MTU:16436  Metric:1  
  16.           RX packets:7 errors:0 dropped:0 overruns:0 frame:0  
  17.           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0  
  18.           collisions:0 txqueuelen:0   
  19.           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即可:)