Set a static IP address for the machine under Linux:
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Modify the contents of this file in the following form:
# Intel Corporation 82541GI Gigabit Ethernet Controller
Device=eth0
bootproto=static #为静态的
Hwaddr=00:15:17:b2:dc:b5
Onboot=yes
Ipaddr=10.20.134.199 #这个是设置的静态IP地址
netmask=255.255.254.0
gateway=10.20.134.1 #网关
After modification, the need to restart the network is the change to take effect:
/etc/init.d/network restart
Automatically get the dynamic IP address method:
Vim/etc/sysconfig/network-scripts/ifcfg-eth1
The contents are as follows:
# Intel Corporation 82566dm-2 Gigabit Network Connection
Device=eth1
bootproto=DHCP #动态获取IP
Hwaddr=00:15:17:b2:dc:b7
Onboot=no
To run the command:
Dhclient eth1
Get dynamic IP address automatically
You can view the assigned IP address by: ifconfig.
Vim/etc/resolv.conf
Used to define the following four items
NameServer #定义DNS服务器的IP地址, this is the most important
Domain #定义本地域名
Search #定义域名的搜索列表
Sortlist #对返回的域名进行排序
via:http://datalife.iteye.com/blog/888971
How to set up static IP and get dynamic IP under Linux