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 configure IP in non-graphical interface under CentOS6.8

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

Share

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

This article mainly explains "how to configure IP in a non-graphical interface under CentOS6.8". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to configure IP in a non-graphical interface under CentOS6.8".

Tips for operation:

Click inside the virtual machine or press Ctrl+G when directing input to the virtual machine

When directing input to the physical host, press Ctrl+Alt.

1 install CentOS6.8 system

2 View IP configuration information

Enter the command line: ifconfig to get the existing IP configuration information for the system as shown in figure 1.

Figure 1 existing IP configuration information of the system

As you can see from figure 1, the basic information of the network card device eth0 is not displayed in the IP configuration information.

3 check to see if the network card device eth0 exists in the system

Enter the command: ls / ect/sysconfig/network-scripts to get the file name information contained in this directory as shown in figure 2.

Figure 2 / filename information in the ect/sysconfig/network-scripts directory

4 activate the network card eth0

Enter the command: ifconfig-a to view the Nic status information. As shown in figure 3, the network card device eth0 in this system is not activated.

Figure 3 Nic status information

Enter the command: ifconfig eth0 up, activate the network card device eth0, enter ifconfig again at this time to view the basic information of eth0, but the network card has not yet configured the corresponding IP address. As shown in figure 4:

Figure 4 activating the network card device

Similarly, if we want a network card device to no longer work, we can also lock it with the command "ifconfig network card name down".

5 configure IP for eth0

When configuring the IP address, you need to choose the appropriate IP according to the network connection mode of the system. The network connection mode of the virtual machine can be set in the interface shown in figure 5.

Figure 5 sets the network connection mode of the virtual machine

If the network connection mode is set to "bridging mode", then you need to set an actual IP address on the same network segment as your physical host. The IP address will consume the actual network bandwidth resources and will be able to access the Internet.

If the network connection mode is set to "NAT mode", as shown in figure 6, look at the network IP address of VMnet8 in the physical host network device, and then set a virtual IP address in the same network segment as this IP address. The IP address will not consume the actual network bandwidth resources, if the physical host can access the Internet, then the virtual machine can also access the Internet.

In addition, another mode of network connection here is "host-only mode". The VMnet1 of the physical host corresponding to this mode is very similar to the "NAT mode", except that the IP address set in this mode can only communicate with the host and cannot access the Internet.

Figure 6 VMnet8 network connection details

5.1 configure temporary IP address

The command format for temporarily configuring IP addresses is "ifconfig Network Card name IP address netmask Subnet Mask" and is effective immediately.

For example: ifconfig eth0 192.168.12.2 netmask 255.255.255.0, the configuration result is shown in figure 7:

Figure 7 temporary IP address

5.2 configure permanent IP addr

To configure a permanent IP address, you need to modify the Nic configuration file.

Enter the command "vi / etc/sysconfig/network-scripts/ifcfg-eth0" to enter the network card configuration file shown in figure 8. Press the Insert key to enter the editing state.

Figure 8 Network Card profile

As shown in figure 8, modify the value of ONBOOT to yes;, modify BOOTPROTO and add basic information such as IP address IPADDR and subnet mask NETMASK to none;.

Note:

(1) DEVICE represents the name of the network card device. Its value must be the same as the name of the network card after "ifcfg-" in the file name entered above, otherwise the modification operation will not take effect.

(2) ONBOOT indicates whether eth0 takes effect when the network service is started. After installing the Linux system of CentOS series, ONBOOT defaults to no. When you modify the configuration file of the network card, you must change it to yes, otherwise the modification operation will not take effect.

(3) BOOTPROTO indicates the IP address acquisition method (none, static, dhcp). Both static and none mean manual allocation; dhcp means to obtain IP automatically, but only if there is a dhcp server in the local area network.

Press the "Esc" key to exit the editing state, enter ": wq" to save and exit. As shown in figure 9:

Figure 9 saves the modification of the network card configuration file

Restart the network service after saving the changes. Enter the command "service network restart" to restart the network service, as shown in figure 10:

Figure 10 restart the network service

After reboot, you can enter the command "ifconfig" to verify that the changes are in effect. As shown in figure 10:

Figure 11 verifies that the permanent IP configuration is in effect b

At this point, I believe you have a deeper understanding of "how to configure IP in a non-graphical interface under CentOS6.8". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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