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 fixed IP for Linux

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to set fixed IP in Linux". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "how to set fixed IP in Linux" together!

ifconfig View network configuration, similar to ipconfig for windows

Linux network configuration files are generally located under/etc/sysconfig/network-scripts/. Use the command cd to switch to this path

ifcfg-eth0 is the network configuration of the virtual machine bridge. If there is a wireless driver, it is ifcfg-wlan0. This file uses the command vim to edit the file vim ifcfg-eth0. Its default configuration is as follows:

Parameter and meaning: DEVICE=eth0 #Set physical device aliases (except for dynamically assigned PPP devices, which are a logical name here) HWADDR=00:11:22:33:44:55 #Specify MAC address, cannot be used with MACADDR

MACADDR=AA:BB:CC:DD:EE:FF #Overrides physically assigned MAC addresses, cannot be used with HWADDR

TYPE=Ethernet #NIC protocol type UUID=9420c638-16e9-41a1-bf59-325c6f601871

UUIDONBOOT=no #Whether the network card is automatically loaded when the system starts yes/noNM_CONTROLLED=yes

Parameters of network manger, effective in real time. No need to restart the network card after modification. Effective immediately.

BOOTPROTO=dhcp #Get Address Protocol [static],[bootp protocol],[dhcp protocol]IPADDR=192.168.1.254

IP address NETMASK=255.255.255.0 #IP subnet mask GATEWAY=192.168.1.1

#IP address # DNS1=8.8.8.8

#Specify DNS1 address # DNS2=8.8.4.4 #Make DNS2 Address # BROADCAST=192.168.1.255

#IP address # NETWORK=192.168.1.0

#Corresponding network address # USERCTL=yes

#Is non-root allowed to control this device # SRCADDR=192.168.1.254

#Specify the source IP address for outgoing packets # PEERDNS=yes

#Do you want to modify [ /etc/resolv.conf ]# DHCP_HOSTNAME=hostname

#DHCP may specify host name before receiving IP address # MASTER=bond0

#Ethernet interface is connected to this interface # SLAVE=yes

#Is this device controlled by the channel binding interface specified in the MASTER field

If you want to set a fixed ip, just set the following configuration: DEVICE=eth0HWADDR=00:11:22:33:44:55TYPE=EthernetUUID=9420c638-16e9-41a1-bf59-325c6f601871ONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=staticIPADDR=192.168.1.254NETMASK=255.255.255.0GATEWAY=192.168.1.1DNS1=192.168.1.1 When we need to insert data, use vim to enter editing state, then press i to enter insert data state, press esc to exit editing after modification, and then (:q! No save exit; :wq! or shift+zz or ZZ for save exit)

After configuration, restart the network using the command service network restart

Check IP configuration again

See this description, we have configured it. Finally, we ping Baidu to check whether the network is available. ping www.baidu.com

Thank you for reading, the above is "Linux how to set fixed IP" content, after the study of this article, I believe that everyone on Linux how to set fixed IP this problem has a deeper experience, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

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

Development

Wechat

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

12
Report