Linux single-NIC multi-IP configuration

Source: Internet
Author: User
Tags dns2


    One, mode one

    1. Modify/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ENP2S0 to: (Note: The file name must be the NIC device name)

        
       
    1. DEVICE=enp2s0
    2. BOOTPROTO=static
    3. ONBOOT=yes
    4. DNS1=10.0.10.10
    5. DNS2=8.8.8.8
    6. HWADDR=B8:88:E3:73:7A:7B
    7. IPADDR=10.0.57.114
    8. PREFIX=24
    9. GATEWAY=10.0.57.1

    2.CP Ifcfg-enp2s0 for Ifcfg-enp2s0:1, and fix the ifcfg-enp2s0:1 content as:

        
       
    1. DEVICE=enp2s0:1
    2. BOOTPROTO=static
    3. ONBOOT=yes
    4. DNS1=10.0.10.10
    5. DNS2=8.8.8.8
    6. HWADDR=B8:88:E3:73:7A:7B
    7. IPADDR=10.0.57.115
    8. PREFIX=24
    9. GATEWAY=10.0.57.1

    3. Restart the NIC, and then ifconfig to see it. ?

    Two, mode two

    1. Configure multiple network cards directly in the/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ENP2S0,

    However, to use IP addr to see multiple IP information, the configuration is as follows:
          
         
      1. TYPE=Ethernet
      2. BOOTPROTO=none
      3. DEFROUTE=yes
      4. IPV4_FAILURE_FATAL=no
      5. IPV6INIT=yes
      6. IPV6_AUTOCONF=yes
      7. IPV6_DEFROUTE=yes
      8. IPV6_FAILURE_FATAL=no
      9. NAME=za209
      10. UUID=7e917b8e-2d35-4630-b314-2d64a2f1f52f
      11. ONBOOT=no
      12. DNS1=10.0.10.10
      13. DOMAIN=10.0.15.11
      14. HWADDR=B8:88:E3:73:7A:7B
      15. IPADDR=10.0.57.230
      16. PREFIX=24
      17. GATEWAY=10.0.57.1
      18. IPADDR1=10.0.57.231
      19. PREFIX1=24
      20. GATEWAY1=10.0.57.1
      21. IPV6_PEERDNS=yes
      22. IPV6_PEERROUTES=yes

2. Restart the network card, using the IP addr command to view, shown as follows:

  
 
  1.      2 : Enp2s0 : < broadcast Span class= "pun", multicast up lower_up > MTU 1500 Qdisc pfifo_fast state up Qlen 1000
  2.      link / ether b8 : Span class= "lit" >88 : e3 : 73 : 7a : 7b BRD FF : ff : ff : ff : ff : ff
  3.     inet 10.0.57.230/24 brd 10.0.57.255 scope global enp2s0
  4.        valid_lft forever preferred_lft forever
  5.     inet 10.0.57.231/24 brd 10.0.57.255 scope global secondary enp2s0
  6.        valid_lft forever preferred_lft forever
  7.     inet6 fe80::ba88:e3ff:fe73:7a7b/64 scope link
  8.        valid_lft forever preferred_lft forever



From for notes (Wiz)

Linux single-NIC multi-IP configuration

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.