Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to bind multiple IP to the next network card of CentOS

Shulou Source: shulou.com Published: 2022-06-01 12:15:41 10月03日 Update

This article mainly explains the "CentOS next network card how to bind multiple IP", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "CentOS next network card how to bind multiple IP" bar!

All devices in CentOS are files. The network card is also defined in the file.

The binding of IP only needs to change the file.

The files related to the network card are located in the directory: / etc/sysconfig/network-scripts

Query current IP information:

Ifconfig:

Eth0 Link encap:Ethernet HWaddr 00:50:56:AC:6B:0F

Inet addr:42.51.135.206 Bcast:42.51.135.255 Mask:255.255.255.0

Inet6 addr: fe80::250:56ff:fead:6b0f/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

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

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

Collisions:0 txqueuelen:1000

RX bytes:28759089 (27.4 MiB) TX bytes:4779278 (4.5 MiB)

There are files in the current directory:

Ifcfg-eth0

Create a new file in the directory:

Ifcfg-eth0:1

The contents are as follows:

DEVICE=eth0:1

IPADDR=42.51.138.1

NETMASK=255.255.255.0

HWADDR=00:50:56:AC:6B:0F

NM_CONTROLLED=yes

ONBOOT=yes

BOOTPROTO=dhcp

TYPE=Ethernet

IPV6INIT=no

USERCTL=no

Ifcfg-eth0:2

DEVICE=eth0:2

IPADDR=42.51.138.2

NETMASK=255.255.255.0

HWADDR=00:50:56:AC:6B:0F

NM_CONTROLLED=yes

ONBOOT=yes

BOOTPROTO=dhcp

TYPE=Ethernet

IPV6INIT=no

USERCTL=no

Ifcfg-eth0:3

DEVICE=eth0:3

IPADDR=42.51.138.3

NETMASK=255.255.255.0

HWADDR=00:50:56:AC:6B:0F

NM_CONTROLLED=yes

ONBOOT=yes

BOOTPROTO=dhcp

TYPE=Ethernet

IPV6INIT=no

USERCTL=no

Restart the network card:

Service network restart

At this point, check the IP:

Eth0 Link encap:Ethernet HWaddr 00:50:56:AC:6B:0F

Inet addr:42.51.135.206 Bcast:42.51.135.255 Mask:255.255.255.0

Inet6 addr: fe80::250:56ff:fead:6b0f/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

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

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

Collisions:0 txqueuelen:1000

RX bytes:29462159 (28.0 MiB) TX bytes:4791402 (4.5 MiB)

Eth0:1 Link encap:Ethernet HWaddr 00:50:56:AC:6B:0F

Inet addr:42.51.138.1 Bcast:42.51.138.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Eth0:2 Link encap:Ethernet HWaddr 00:50:56:AC:6B:0F

Inet addr:42.51.138.2 Bcast:42.51.138.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Eth0:3 Link encap:Ethernet HWaddr 00:50:56:AC:6B:0F

Inet addr:42.51.138.3 Bcast:42.51.138.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Test:

On other machines, ping the above several IP.

Thank you for your reading, the above is the content of "how to bind multiple IP on the next network card of CentOS". After the study of this article, I believe you have a deeper understanding of the problem of how to bind multiple IP to the next network card of CentOS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Network cards files multiple content directories learning next information that is ideas situations articles more machines knowledge knowledge points articles equipment follow questions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno Shulou Information vpn Apple