wiki:TipAndDoc/network/alias

Version 12 (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
    

static時の問題

  • /etc/network/interfaces
    auto eth0:0
    iface eth0:0 inet static
            address 192.168.40.250
            netmask 255.255.255.0
            gateway 192.168.40.2
    
  • sudo ifup eth0:0
    SIOCSIFFLAGS: Cannot assign requested address
    
  • 実際には正常にassign
    • ifconfig eth0:0
      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
      
    • rebootしても正常にassignされている
  • wireless-tools のバグ?
  • 対応
    • sudo chmod -x /etc/network/if-pre-up.d/wireless-tools
    • sudo aptitude -R remove wireless-tools (依存関係に問題があり非推奨?)
      The following packages are BROKEN:
        ubuntu-minimal
      The following packages will be REMOVED:
        wireless-tools
      0 packages upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
      Need to get 0B of archives. After unpacking 352kB will be freed.
      The following packages have unmet dependencies:
        ubuntu-minimal: Depends: wireless-tools but it is not installable
      Resolving dependencies...
      The following actions will resolve these dependencies:
      
      Remove the following packages:
      ubuntu-minimal
      
      Score is 115
      
      Accept this solution? [Y/n/q/?]
      

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.
    
  • boot時は特にエラー表示はないが、assignされない
  • 対応
    • dhcp3-clientの代わりにdhcpcdを入れる対策はHardyでは効果なし
    • https://bugs.launchpad.net/ubuntu/+source/dhcp3/+bug/351378/comments/12
      1. install dhcp3-client dummy package => attachment:dhcp3-client-dummy_3.0.6.dfsg-1ubuntu9_i386.deb
        • sudo dpkg -i dhcp3-client-dummy_3.0.6.dfsg-1ubuntu9_i386.deb
          (Reading database ... 15336 files and directories currently installed.)
          Preparing to replace dhcp3-client 3.0.6.dfsg-1ubuntu9 (using dhcp3-client-dummy_3.0.6.dfsg-1ubuntu9_i386.deb) ...
          Unpacking replacement dhcp3-client ...
          dpkg: warning - unable to delete old directory `/var/lib/dhcp3': Directory not empty
          dpkg: warning - unable to delete old directory `/etc/dhcp3/dhclient-enter-hooks.d': Directory not empty
          Setting up dhcp3-client (3.0.6.dfsg-1ubuntu9) ...
          
      2. hold dhcp3-client dummy package
        • sudo aptitude hold dhcp3-client
          The following packages have been kept back:
            dhcp3-client
          0 packages upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
          
      3. install udhcpc package
        • sudo aptitude install -R udhcpc
      4. add alias to /etc/network/interfaces
        • hostname, client-id は必須なのか不明。無くても手元では動作した
          auto eth0
          iface eth0 inet dhcp
          
          auto eth0:0
          iface eth0:0 inet dhcp
          
      5. restart NICs
        • sudo /etc/init.d/networking restart
           * Reconfiguring network interfaces...
          udhcpc (v0.9.9-pre) started
          Sending discover...
          Sending select for 192.168.40.146...
          Lease of 192.168.40.146 obtained, lease time 1800
          Resetting default routes
          adding dns 192.168.40.2
          SIOCSIFFLAGS: Cannot assign requested address
          udhcpc (v0.9.9-pre) started
          SIOCSIFFLAGS: Cannot assign requested address
          Sending discover...
          Sending select for 192.168.40.144...
          Lease of 192.168.40.144 obtained, lease time 1800
          Resetting default routes
          adding dns 192.168.40.2
                                                                                   [ OK ]
          

Attachments (3)

Download all attachments as: .zip