Linux Dynamic IP address and static IP Address

Source: Internet
Author: User

In Linux, IP addresses are classified into "Dynamic IP" and "static IP". Dynamic IP addresses are automatically cleared when the machine restarts, while static IP addresses are always bound.

Static IP settings:Create a file ifcfg-eth0: 1 in/etc/sysconfig/network-scripts or by using a GUI tool with the following content:

Device = eth0: 1
Ipaddr = 139.24.214.82 # static IP Address
Netmask = 255.255.255.0
Onboot = Yes

How to Set Dynamic IP addresses:

/Sbin/ifconfig eth0: 1 139.24.214.22 netmask 255.255.255.0 # change to service IP Address

/Sbin/ifconfig eth0: 2 127.0.0.1 netmask resume 255.254.0 # restore to 127.0.0.1

Note: In the preceding command, eth0: 2 should be eth0: 1. Set it according to the above method and execute ifconfig,

[Root @ centosnetwork-Scripts] # ifconfig

Eth0 link encap: Ethernet hwaddr 00: 15: F2: 1f: A2: Ea

Inet ADDR: 10.130.16.141 bcast: 10.130.16.255 mask: 255.255.255.0

Inet6 ADDR: fe80: 215: f2ff: fe1f: a2ea/64 scope: Link

Up broadcast running Multicast MTU: 1500 Metric: 1

RX packets: 1892 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 901 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 FIG: 1000

RX Bytes: 188740 (184.3 kib) TX Bytes: 131190 (128.1 kib)

Interrupt: 193 base address: 0x6000

 

Eth0: 1 link encap: Ethernet hwaddr 00: 15: F2: 1f: A2: Ea

Inet ADDR: 10.130.16.131 bcast: 10.130.16.255 mask: 255.255.255.0

Up broadcast running Multicast MTU: 1500 Metric: 1

Interrupt: 193 base address: 0x6000

 

Lo link encap: local loopback

Inet ADDR: 127.0.0.1 mask: 255.0.0.0

Inet6 ADDR: 1/128 scope: Host

Up loopback running MTU: 16436 Metric: 1

RX packets: 1520 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 1520 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 txqueuelen: 0

RX Bytes: 2634807 (2.5 MIB) TX Bytes: 2634807 (2.5 MIB)

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.