Set up static IP in Linux

Source: Internet
Author: User

1: Enter in Terminal: cd/etc/sysconfig/network-scripts/

2: See if there is this file: Ifcfg-eth0, if there are then input edits, vi ifcfg-eth0:

3: Start editing, fill in the IP address, subnet mask, gateway, DNS and so on. Where "These are the ones that must be."

Device=eth0

Bootproto=static

Onboot=yes

ipaddr=198.1.102.140

netmask=255.255.224.0

gateway=198.1.96.1

Where: eth0 corresponding file name: Ifcfg-eth0

If you need to configure more than one IP, you need multiple files, each with one IP, with the file name: ifcfg-eth0_x,

And the file is device=eth0:x, where X can start from 1. For example file: Ifcfg-eth0_1 correspondence device=eth0:1
Other netmask and gateway are the same except that ipaddr needs to change.

4: When finished editing, save exit (: Wq).
5: Restart the network service. Service network restart or/etc/init.d/network restart
6:ping the gateway, ping the extranet for testing. Can ping to indicate that the network is normal.

Set up static IP 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.