Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set static IP in Linux system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces you how to set static IP in the Linux system, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Set a static IP address for the machine under Linux:

The code is as follows:

Vim / etc/sysconfig/network-scripts/ifcfg-eth0

Modify the content of this file as follows:

The code is as follows:

# Intel Corporation 82541GI Gigabit Ethernet Controller

DEVICE=eth0

BOOTPROTO=static # is static

HWADDR=00:15:17:B2:DC:B5

ONBOOT=yes

IPADDR=10.20.134.199 # this is the set static IP address

NETMASK=255.255.254.0

GATEWAY=10.20.134.1 # Gateway

After modification, the network needs to be restarted if the change takes effect:

The code is as follows:

/ etc/init.d/network restart

How to obtain dynamic IP address automatically:

The code is as follows:

Vim / etc/sysconfig/network-scripts/ifcfg-eth2

The contents are as follows:

The code is as follows:

# Intel Corporation 82566DM-2 Gigabit Network Connection

DEVICE=eth2

BOOTPROTO=dhcp # dynamic acquisition of IP

HWADDR=00:15:17:B2:DC:B7

ONBOOT=no

Run the command:

The code is as follows:

Dhclient eth2

Automatic acquisition of dynamic IP addresses

You can view the assigned IP address at: ifconfig.

The code is as follows:

Vim / etc/resolv.conf

Used to define the following four items

Nameserver # defines the IP address of the DNS server, which is the most important

Domain # define a local domain name

Search # defines a search list for domain names

Sortlist # sorts the returned domain names

On how to set up static IP in the Linux system to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report