How to set up static IP and get dynamic IP under Linux

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.