Linux Configuration static IP address

Source: Internet
Author: User

Note: All red font labels are Linux operation commands!

1. Log in to the system using the root account

  2, you can first use ifconfig : Check the network card information eth0 as the default first network card, if there is a second will be displayed as eth1.

You can then see that the eth0 and Lo network cards lo are loopback address IP is 127.0.0.1 (this is also available on Windows). There will be an IP address and other information

If there is no command to execute

        dhclient #获取IP

        dhclient-r #释放IP

After acquiring the IP in the execution ifconfig This time you will see inet addr: ... Some IP addresses and other information

  3, then enter the vi edit mode edit eth0 network card IP address and other information eth0 location:/etc/sysconfig/network-scripts/ifcfg-eth0

Execute command: vi/etc/sysconfig/network-scripts/ifcfg-eth0

At this point, press I for edit mode to change "Onboot=on" to "Onboot=yes" to "bootproto=dhcp" to "bootproto=static" and add the following lines of configuration:

ipaddr=192.168.31.19 ----> This address can open the network and Sharing Center and then view the network details of the current PC connection to view

metmask=255.255.255.0

gateway=192.168.31.1  ----> The gateway address can also be viewed in the network and Sharing Center as

dns1=8.8.8.8

When you are finished editing, press ESC to enter: WQ Exit and SAVE!

  4, and then restart the Network Service Execution command: service network restart

This is the IP address you just configured when you enter the ifconfig command.

Now, after the network is set up, you can try to ping it if the ping pass proves that the configuration was successful. Enter Ping www.baidu.com directly on the command line

  

Linux Configuration static IP address

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.