Set a static IP address in Linux

Source: Internet
Author: User

Set a static IP address in Linux
1, enter in the terminal: Vi/etc/sysconfig/network-scripts/ifcfg-eth0

2, start editing, fill in IP address, subnet mask, gateway, DNS, etc.
[[Email protected] Desktop]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 #设备名称
Type=ethernet #网络类型
Uuid=bfafdad5-e1c9-4adf-864b-c772e4965ab7
Onboot=yes #开机自启动. Must have
Nm_controlled=yes
Bootproto=static #静态ip. Must have
Defroute=yes
Ipv4_failure_fatal=yes
Ipv6init=no
Name= "System eth0"
ipaddr=192.168.23.128 #ip地址. Must have
Prefix=24
gateway=192.168.23.2 #网关. Must have
netmask=255.255.255.0 #子网掩码. Must have
dns1=192.168.23.2 #dns. Must have
hwaddr=00:0c:29:10:ec:9d #mac地址
last_connect=1480146093

3. After editing, save and exit.

4, restart the network services. Service network restart or/etc/init.d/network restart

5, Ping the gateway, ping the outside network for testing. Can ping to indicate that the network is normal.

Set a static IP address in Linux

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.