Bind two or more IP addresses to a network card

Source: Internet
Author: User
Article title: bind two or more IP addresses to a network card. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
This is explained by taking RedHat 7.3 as an example. The system versions may be different, but I think it is similar. Haha...
  
1. enter the directory:
[Root @ Linuxsir root] # cd/etc/sysconfig/network-scripts/
  
2: ifcfg-eh0: 0 in the eh0: 0 is the network card code, of course you can also use eh0: 1 and so on, as you like how to get, but in eh0: X must have ifcfg, this is the form below. We use eh0: 0 as an example.
  
[Root @ Linuxsir root] # cp ifcfg-eth0 ifcfg-eth0: 0
  
3, edit ifcfg-eth0: 0
[Root @ Linuxsir root] # ifcfg-eth0 vi: 0
  
Ifcfg-eth0: 0 contains such content, you can set it like this, and then the IP can be set by yourself. The same is true for settings like me.
  
# Please read/usr/share/doc/initscripts-*/sysconfig.txt
# For the documentation of these parameters.
USERCTL = 'no'
NETMASK = '2017. 255.255.0 '-"submask
BOOTPROTO = 'static '-protocol
DEVICE = 'eth0: 0'-"virtual Nic code
IPADDR = '1970. 168.0.9 '-"IP address set by myself
TYPE = 'ethernet'
OnBOOT = 'yes'-whether to activate the service after it is started
NETWORK = '1970. 168.0.0 '-"domain
BROADCAST = '1970. 168.0.255 '-"BROADCAST
  
4. save and exit, and then run the following command to activate the virtual Nic.
[Root @ Linuxsir root] # ifup eh0: 0
5. let's check if our virtual Nic is activated. use ifconfig, that is, the following.
  
[Root @ Linuxsir network-scripts] # ifconfig
Eth0 Link encap: Ethernet HWaddr 00: E0: 4C: 00: C9: 05
Inet addr: 192.168.0.1 Bcast: 192.168.0.255 Mask: 255.255.255.0
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 3 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 54 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 fig: 100
RX bytes: 180 (180.0 B) TX bytes: 7157 (6.9 Kb)
Interrupt: 11 Base address: 0x2000
  
Eth0: 0 Link encap: Ethernet HWaddr 00: E0: 4C: 00: C9: 05
Inet addr: 192.168.0.9 Bcast: 192.168.0.255 Mask: 255.255.255.0
Up broadcast running multicast mtu: 1500 Metric: 1
Interrupt: 11 Base address: 0x2000
  
Lo Link encap: Local Loopback
Inet addr: 127.0.0.1 Mask: 255.0.0.0
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: 846 (846.0 B) TX bytes: 846 (846.0 B)
  
6. ping the IP address to see if it is successful.
  
[Root @ Linuxsir network-scripts] # ping 192.168.0.9
PING 192.168.0.9 (192.168.0.9) from 192.168.0.9: 56 (84) bytes of data.
64 bytes from 192.168.0.9: icmp_seq = 1 ttl = 255 time = 0.097 MS
64 bytes from 192.168.0.9: icmp_seq = 2 ttl = 255 time = 0.043 MS
64 bytes from 192.168.0.9: icmp_seq = 3 ttl = 255 time = 0.043 MS
64 bytes from 192.168.0.9: icmp_seq = 4 ttl = 255 time = 0.044 MS
64 bytes from 192.168.0.9: icmp_seq = 5 ttl = 255 time = 0.043 MS
  
--- 192.168.0.9 ping statistics ---
14 packets transmitted, 14 bytes ed, 0% loss, time 12996 ms
Rtt min/avg/max/mdev = 0.039/0.046/0.097/0.016 MS
  
[Root @ Linuxsir network-scripts] # ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) from 192.168.0.1: 56 (84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq = 1 ttl = 255 time = 0.069 MS
64 bytes from 192.168.0.1: icmp_seq = 2 ttl = 255 time = 0.042 MS
64 bytes from 192.168.0.1: icmp_seq = 3 ttl = 255 time = 0.040 MS
64 bytes from 192.168.0.1: icmp_seq = 4 ttl = 255 time = 0.042 MS
  
--- 192.168.0.1 ping statistics ---
7 packets transmitted, 7 bytes ed, 0% loss, time 5995 ms
Rtt min/avg/max/mdev = 0.040/0.046/0.069/0.009 MS

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.