wiki:TipAndDoc/network/alias

Version 8 (modified by mitty, 15 years ago) (diff)

--

NIC alias

  • 一つの物理NICに複数のIPを割り当てる

CentOS

設定

  • /etc/sysconfig/network-scripts/
    • ifcfg-eth?:? を作る
    • 書式は通常の ifcfg-eth? と同じ
      • dhcp (後述)
        DEVICE=eth0:0
        BOOTPROTO=dhcp
        ONBOOT=yes
        DHCP_HOSTNAME=centos5-test
        
      • static
        DEVICE=eth0:0
        BOOTPROTO=static
        IPADDR=192.168.40.250
        NETMASK=255.255.255.0
        GATEWAY=192.168.40.2
        ONBOOT=yes
        DHCP_HOSTNAME=centos5-test
        
  • ifconfig (static)
    eth0      Link encap:Ethernet  HWaddr 00:0C:29:XX:XX:XX
              inet addr:192.168.40.141  Bcast:192.168.40.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:102642 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1738 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:11384683 (10.8 MiB)  TX bytes:234313 (228.8 KiB)
              Interrupt:59 Base address:0x2000
    
    eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:XX:XX:XX
              inet addr:192.168.40.250  Bcast:192.168.40.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:59 Base address:0x2000
    

dhcpについて

  • 以下の問題は、BOOTPROTO=static の際には発生しない模様
  • ifup eth0:0 でエラーが出る
    Determining IP information for eth0:0...SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
     done.
    
  • IP自体は正常にassignされる
    • ifconfig
      eth0      Link encap:Ethernet  HWaddr 00:0C:29:XX:XX:XX
                inet addr:192.168.40.141  Bcast:192.168.40.255  Mask:255.255.255.0
                UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                RX packets:102862 errors:0 dropped:0 overruns:0 frame:0
                TX packets:1939 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:11403063 (10.8 MiB)  TX bytes:260163 (254.0 KiB)
                Interrupt:59 Base address:0x2000
      
      eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:XX:XX:XX
                inet addr:192.168.40.142  Bcast:192.168.40.255  Mask:255.255.255.0
                UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                Interrupt:59 Base address:0x2000
      
  • boot時のエラー
  • IPもassignされず
    • fconfig eth0:0
      eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:XX:XX:XX
                UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                Interrupt:59 Base address:0x2000
      
  • ifup eth0:0
    Determining IP information for eth0:0...SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
    SIOCGIFADDR: Cannot assign requested address
    SIOCSIFBROADCAST: Cannot assign requested address
    SIOCSIFBRDADDR: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
     done.
    
    • assignされず
  • ifup eth0:0
    Determining IP information for eth0:0...SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
     done.
    
    • assignされた
      • ifconfig eth0:0
        eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:XX:XX:XX
                  inet addr:192.168.40.141  Bcast:192.168.40.255  Mask:255.255.255.0
                  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                  Interrupt:59 Base address:0x2000
        
  • assignされたりされなかったりするため、不安定

Ubuntu

設定

  • 全て /etc/network/interfaces に記述
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto eth0
    iface eth0 inet dhcp
    
    • dhcp (後述)
      auto eth0:0
      iface eth0:0 inet dhcp
      
    • static
      auto eth0:0
      iface eth0:0 inet static
              address 192.168.40.250
              netmask 255.255.255.0
              gateway 192.168.40.2
      
  • ifconfig (static)
    eth0      Link encap:Ethernet  HWaddr 00:0c:29:YY:YY:YY
              inet addr:192.168.40.144  Bcast:192.168.40.255  Mask:255.255.255.0
              inet6 addr: fe80::20c:29ff:feb1:838a/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:1051 errors:0 dropped:0 overruns:0 frame:0
              TX packets:877 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:94083 (91.8 KB)  TX bytes:113925 (111.2 KB)
              Interrupt:17 Base address:0x2000
    
    eth0:0    Link encap:Ethernet  HWaddr 00:0c:29:YY:YY:YY
              inet addr:192.168.40.250  Bcast:192.168.40.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:17 Base address:0x2000
    

dhcp時の問題

  • CentOSと同様、dhcp時に問題が起きる
  • sudo /etc/init.d/networking restart
     * Reconfiguring network interfaces...
    There is already a pid file /var/run/dhclient.eth0.pid with pid 4361
    killed old client process, removed PID file
    Internet Systems Consortium DHCP Client V3.0.6
    Copyright 2004-2007 Internet Systems Consortium.
    All rights reserved.
    For info, please visit http://www.isc.org/sw/dhcp/
    
    Listening on LPF/eth0/00:0c:29:YY:YY:YY
    Sending on   LPF/eth0/00:0c:29:YY:YY:YY
    Sending on   Socket/fallback
    There is already a pid file /var/run/dhclient.eth0.pid with pid 134519072
    Internet Systems Consortium DHCP Client V3.0.6
    Copyright 2004-2007 Internet Systems Consortium.
    All rights reserved.
    For info, please visit http://www.isc.org/sw/dhcp/
    
    Listening on LPF/eth0/00:0c:29:YY:YY:YY
    Sending on   LPF/eth0/00:0c:29:YY:YY:YY
    Sending on   Socket/fallback
    DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
    DHCPOFFER of 192.168.40.144 from 192.168.40.254
    DHCPREQUEST of 192.168.40.144 on eth0 to 255.255.255.255 port 67
    DHCPACK of 192.168.40.144 from 192.168.40.254
    bound to 192.168.40.144 -- renewal in 855 seconds.
    SIOCSIFFLAGS: Cannot assign requested address
    Internet Systems Consortium DHCP Client V3.0.6
    Copyright 2004-2007 Internet Systems Consortium.
    All rights reserved.
    For info, please visit http://www.isc.org/sw/dhcp/
    
    SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
    Bind socket to interface: No such device
    Failed to bring up eth0:0.
                                                                             [ OK ]
    
  • sudo ifup eth0:0
    SIOCSIFFLAGS: Cannot assign requested address
    There is already a pid file /var/run/dhclient.eth0:0.pid with pid 134519072
    Internet Systems Consortium DHCP Client V3.0.6
    Copyright 2004-2007 Internet Systems Consortium.
    All rights reserved.
    For info, please visit http://www.isc.org/sw/dhcp/
    
    SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address
    Bind socket to interface: No such device
    Failed to bring up eth0:0.
    

Attachments (3)

Download all attachments as: .zip