A Linux host with multiple IP addresses

Source: Internet
Author: User
For a Linux host with multiple IP addresses, first check the IP address of the host in linux: # ifconfigeth0Linkencap: EthernetHWaddr00: 16: 8d: B7: 6A: E0inetaddr: 192.168.1.111Bcast: 192.168.1.255Mask: 255.255.25 a Linux host with multiple IP addresses first, we can check the IP address of the host in linux: # ifconfigeth0 Link encap: Ethernet HWaddr 00: 16: 8d: B7: 6A: E0 inet addr: 192.168.1.111 Bcast: 192.168.1.255 Mask: 255.255.252.0 inet6 addr: fd80: 213: 8eff: feb7: 2ae0/64 Scope: Link up broadcast running multicast mtu: 1500 Metr Ic: 1 RX packets: 7077 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 54 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 1000 RX bytes: 654811 (639.4 KiB) TX bytes: 6229 (6.0 KiB) Interrupt: 10 Base address: 0xb800 here we only see that this host has only one IP address, we need to bind another IP address to the network adapter eth0, because the general machine has only one network adapter, so we can bind multiple IP addresses to the same network adapter. Okay. let's get started. 1. first enter the Nic configuration file # cd/etc/sysconfig/network-scripts2. copy the configuration file for the Nic eth0 # cp ifcfg-eth0 ifcfg-eth0: 03. modify ifcfg-eht0: 0 file # vi ifcfg-eth0: 0 Change the IP address to your other IP address, for example, my change is as follows: DEVICE = eth0: 0 # Nic setting name, to be consistent with the file name BOOTPROTO = staticHWADDR = 00: 16: 8d: B7: 6A: E0IPADDR = 192.168.1.20.netmask = 255.255.252.0GATEWAY = 192.168.0.0ONBOOT = yesTYPE = Ethernet, note that eth0: the physical Nic address of 0 must be the same as the physical Nic address of eth0d, that is, the HWaddr must be the same because multiple IP addresses are bound to the same Nic. After saving, we can restart the NIC. 4. restart the NIC/etc/init. d/network restart 5. after starting, check the IP address # ifconfigeth0 Link encap: Ethernet HWaddr 00: 16: 8d: B7: 6A: E0 inet addr: 192.168.1.111 Bcast: 192.168.1.255 Mask: 255.255.252.0 inet6 addr: fd80 :: 213: 8eff: feb7: 2ae0/64 Scope: Link up broadcast running multicast mtu: 1500 Metric: 1 RX packets: 7077 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 54 errors: 0 dropped: 0 overruns: 0 carrier: 0 colli Sions: 0 txqueuelen: 1000 RX bytes: 654811 (639.4 KiB) TX bytes: 6229 (6.0 KiB) Interrupt: 10 Base address: 0xb800 eth0: 0 Link encap: Ethernet HWaddr 00: 16: 8d: B7: 6A: E0 inet addr: 192.168.1.112 Bcast: 192.168.1.255 Mask: 255.255.252.0 up broadcast running multicast mtu: 1500 Metric: 1 Interrupt: 10 Base address: 0xb800, is there two IP addresses on the machine? Oh, you can try to ping it on another machine ~~~ # Ping 192.168.1.111PING 192.168.1.111 (192.168.1.111) 56 (84) bytes of data.64 bytes from 192.168.1.111: icmp_seq = 0 ttl = 64 time = 0.061 ms64 bytes from 192.168.1.111: icmp_seq = 1 ttl = 64 time = 0.048 ms64 bytes from 192.168.1.111: icmp_seq = 2 ttl = 64 time = 0.052 ms # ping 192.168.1.20.ping 192.168.1.112 (192.168.1.112) 56 (84) bytes of data.64 bytes from 192.168.1.112: icmp_seq = 0 ttl = 64 time = 0.063 ms64 bytes from 192.168.1.112: icmp_seq = 1 ttl = 64 time = 0.055 ms64 bytes from 192.168.1.112: icmp_seq = 2 ttl = 64 time = 0.055 MS
 
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.