How to set IP addresses in LINUX

Source: Internet
Author: User
Static method note: all operations use root user modify ip: edit File/etc/sysconfig/network-scripts/ifcfg-eth0DEVICEeth0 // device name, do not modify www.2cto. comBOOTPROTOstatic // do not modify BROADCAST10.10.22.255 //...
Static method note: all operations use root user modify ip: edit File/etc/sysconfig/network-scripts/ifcfg-eth0DEVICE = eth0 // device name, do not modify www.2cto.com BOOTPROTO = static // do not modify BROADCAST = 10.10.22.255 // BROADCAST address, generally, the last IPIPADDR = 10.10.22.145 // IP address NETMASK = 255.255.255.0 // subnet mask NETWORK = 10.10.22.0 // NETWORK segment address ONBOOT = yes // do not modify TYPE = Ethernet // do not modify note: ifcfg-eth0 is the first Nic, ifcfg-eth1 is the second Nic, and so on add ip: can re-compile a file, file name/etc/sysconfig/network-scripts/ifcfg-eth0: 0 can also be directly stored in /Etc/sysconfig/network-scripts/ifcfg-eth0 add (but the DEVICE eth0 must have) DEVICE = eth0: 0 // DEVICE name, do not modify BOOTPROTO = static // do not modify BROADCAST = 10.10.33.255 // BROADCAST address, generally, the last IPIPADDR = 10.10.33.145 // IP address NETMASK = 255.255.255.0 // subnet mask NETWORK = 10.10.33.0 // NETWORK segment address ONBOOT = yes // do not modify TYPE = Ethernet // do not modify and so on, if you add another ip address, add the following configuration: DEVICE = eth0: 1 // DEVICE name. do not modify BOOTPROTO = static // do not modify BROADCAST = 10.10.44.255 // BROADCAST address, this is generally the last IPIPADDR = 10.10.44.145 // IP address NETMASK = 255.255.255.0 // subnet mask NETWORK = 10.10.44.0 // CIDR block address ONBOOT = yes // do not modify TYPE = Ethernet // do not modify the same if the second Nic is located, add DEVICE = eth1: 0 // DEVICE name, do not modify BOOTPROTO = static // do not modify BROADCAST = 10.10.33.255 // BROADCAST address, generally, the last IPIPADDR = 10.10.33.145 // IP address NETMASK = 255.255.255.0 // subnet mask NETWORK = 10.10.33.0 // NETWORK segment address ONBOOT = yes // do not modify TYPE = Ethernet // do not modify use the following method to add a default gateway to www.2cto.com: note that only one machine can have one default gateway; otherwise, a specific routing method should be provided. Add one to the related device configuration. for example, in the above configuration, add a default gateway to the first IP address of the first Nic: DEVICE = eth0BOOTPROTO = staticBROADCAST = broadcast = 255.255.255.0NETWORK = 10.10.22.0ONBOOT = yesTYPE = EthernetGATEWAY = 10.10.22.3 after the modification is completed, restart the machine or restart the network. Restart the machine by reboot to restart the network: the service network restart method is the static ip adding method, that is, the method is still effective after the machine is restarted. Dynamic method note: all operations use the root user to modify the IP address: ifconfig eth0 10.10.22.145, then directly change the IP address of the first Nic to 10.10.22.145 to add the IP address: ifconfig eth0 add 10.10.33.145 // add an IPifconfig eth0: 0 broadcast 10.10.33.255 // modify the broadcast address www.2cto.com of the added IP address and add an IP address: ifconfig eth0: 0 add another eth0: 0: 1 broadcast 10.10.44.255 // do not perform the following operations to modify the broadcast address of the newly added IP address: ifconfig eth0 add 10.44.145 so that the newly added IP10.10.33.145 is changed to 10.10.44.145 and then an IP address: ifconfig ETH: 0: 1 add 10.10. 55.145 ifconfig eth0: 0: 1: 1 broadcast 10.10.55.255 // modify the broadcast address of the newly added IP address and so on. The added IP address takes effect immediately. However, after the machine is restarted, it becomes invalid. Author wwyu8901
Related Article

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.