Linux System IP Address

Source: Internet
Author: User

1. Overview of IP addresses

2. Configure IP Address

View IP Address

Bind an IP address on the NIC

Bind multiple IPs on the same NIC

Bind a piece of NIC device

Modify or delete an IP address

IP Address Overview

Here is not much to repeat, refer to the "Computer network" course.

Configure IP Address

[[email protected] ~]# ifconfig
eth0     Link EnCap: Ethernet HWaddr 00:0C:29:05:1D:AC Network card Physical Address
inet addr:192.168.80.110 bcast:192.168.80.255 Mask: 255.255.255.0 IP address, broadcast address, subnet mask
Inet6 addr:fe80::20c:29ff:fe05:1dac/64 scope:link
up broadcast RUNNIN           G Multicast mtu:1500 metric:1 up indicates that the network interface is initiated by the
RX packets:33148 errors:0 dropped:0 overruns:0 frame:0 Packet statistics on the network interface
TX packets:12115 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 Txqueuelen:
RX bytes:41678800 (39.7 MiB) TX bytes:2688713 (2.5 MiB)

Lo Link encap:local Loopback Internal network loopback address
inet addr:127.0.0.1 mask:255.0.0.0 Loopback IP address, subnet mask
Inet6 addr::: 1/128 scope:host
Up LOOPBACK RUNNING mtu:16436 metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:720 (720.0 b) TX bytes:720 (720.0 b)

[Email protected] ~]#

IFCONFIG-A display of all network interfaces including active and inactive

Ifconfig-s only displays summary information for the network interface

[Email protected] ~]# ifconfig eth0
Eth0 Link encap:ethernet HWaddr 00:0c:29:05:1d:ac
inet addr:192.168.80.110 bcast:192.168.80.255 mask:255.255.255.0
Inet6 ADDR:FE80::20C:29FF:FE05:1DAC/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:33308 errors:0 dropped:0 overruns:0 frame:0
TX packets:12143 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:41693344 (39.7 MiB) TX bytes:2692561 (2.5 MIB)

[Email protected] ~]#

[[email protected] ~]# ifconfig-a
eth0 Link encap:ethernet HWaddr 00 : 0c:29:05:1d:ac
 inet addr:192.168.80.110 bcast:192.168.80.255 mask:255.255.255.0
 in          Et6 addr:fe80::20c:29ff:fe05:1dac/64 scope:link
 up broadcast RUNNING multicast mtu:1500 Metric:1
 rx packets:33336 errors:0 dropped:0 overruns:0 frame:0
 tx packets:12160 errors:0 dropped: 0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
 rx bytes:4169 5906 (39.7 MiB) TX bytes:2694923 (2.5 MiB)

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:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:720 (720.0 b) TX bytes:720 (720.0 b)

[Email protected] ~]#

Bind an IP address on the NIC

[Email protected] ~]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 NIC Device Name
Hwaddr=00:0c:29:05:1d:ac
Type=ethernet
uuid=a36d5f1e-fa69-453f-ba2b-a0952b279936
Onboot=yes
Nm_controlled=yes
Bootproto=static

Defroute=yes
Peerdns=yes
Peerroutes=yes
Ipv4_failure_fatal=yes
Ipv6init=no
Name= "System eth0"
IPADDR=192.168.80.110 Bound IP Address
bcast=192.168.80.255
gateway=192.168.80.2
netmask=255.255.255.0

dns1=144.144.144.144
dns2=192.168.80.2
[Email protected] ~]#

[Email protected] network-scripts]# pwd
/etc/sysconfig/network-scripts
[[email protected] network-scripts]# ifdown eth0 close nic Eth0

[[email protected] network-scripts]# ifup eth0 open nic eth0

Or

[Email protected] network-scripts]# pwd
/etc/sysconfig/network-scripts
[[email protected] network-scripts]# ./ifdown eth0 close Nic Eth0

[[email protected] network-scripts]# ./ifup eth0 Open Nic eth0

Or

[[email protected] ~]# /etc/sysconfig/network-scripts/ifdown eth0 close nic Eth0

[[email protected] ~]# /etc/sysconfig/network-scripts/ifup eth0 open nic eth0

  

Bind multiple IPs on the same NIC

  In the actual work, especially on the server, you need to configure a large number of IP addresses on a net card. We can achieve this by leveraging the virtual network card technology .

Using the Virtual network card technology, set up some aliases for this network cards, and use the configuration file of these aliases to bind multiple IP addresses on this card.

If you need to bind multiple IP addresses on a network card, you need to manually set up a number of configuration files that start with ifcfg-and then follow the name of the NIC (logical name), in the following format

Ifcfg-ethx:yyy

where x is the first card device, YYY is the network card on the NIC device.

Here, I'll make a copy of it and demonstrate it.

[Email protected] network-scripts]# pwd
/etc/sysconfig/network-scripts
[email protected] network-scripts]# CP Ifcfg-eth0 IFCFG-ETH0-RANGE0
[Email protected] network-scripts]# vim IFCFG-ETH0-RANGE0

device=eth0-range0
Hwaddr=00:0c:29:05:1d:ac
Type=ethernet
uuid=a36d5f1e-fa69-453f-ba2b-a0952b279936
Onboot=yes
Nm_controlled=yes
Bootproto=static

Defroute=yes
Peerdns=yes
Peerroutes=yes
Ipv4_failure_fatal=yes
Ipv6init=no
Name= "System eth0"
ipaddr=192.168.80.110
ipaddr=192.168.80.115
bcast=192.168.80.255
gateway=192.168.80.2
netmask=255.255.255.0

dns1=144.144.144.144
dns2=192.168.80.2

After that, you cannot shut down and start the network card in the remote tool.

  

After the test, you can delete it.

Linux System 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.