LINUX.ORG.RU

А нельзя сразу в файле устройства прописать?

jackill ★★★★★
()

Дистрибутив какой?

Вообще, imho, все настроены на dhcp by default

Demetrio ★★★★★
()

никак. получением dhcp-ажреса занимается сторонняя userland-тулза (dhcp-клиент, в Линуксе обычно родной от ISC или pump)

Zulu ★★☆☆
()

######################
# ETHERNET FUNCTIONS #
######################

# Function to bring up an Ethernet interface.  If the interface is
# already up or does not yet exist (perhaps because the kernel driver
# is not loaded yet), do nothing.
eth_up() {
  # If the interface isn't in the kernel yet (but there's an alias for it in
  # modules.conf), then it should be loaded first:
  if ! grep eth${1}: /proc/net/dev 1> /dev/null ; then # no interface yet
    if /sbin/modprobe -c | grep -w "alias eth${1}" | grep -vw "alias eth${1} off" > /dev/null ; then
      echo "/etc/rc.d/rc.inet1:  /sbin/modprobe eth${1}" | $LOGGER
      /sbin/modprobe eth${1}
    fi
  fi
  if grep eth${1}: /proc/net/dev 1> /dev/null ; then # interface exists
    if ! /sbin/ifconfig | grep -w "eth${1}" 1>/dev/null || \
      ! /sbin/ifconfig eth${1} | grep "inet addr" 1> /dev/null ; then # interface not up or not configured
      if [ -x /etc/rc.d/rc.wireless ]; then
        . /etc/rc.d/rc.wireless eth${1} # Initialize any wireless parameters
      fi
      if [ "${USE_DHCP[$1]}" = "yes" ]; then # use DHCP to bring interface up
        if [ ! "${DHCP_HOSTNAME[$1]}" = "" ]; then
          echo "/etc/rc.d/rc.inet1:  /sbin/dhcpcd -d -t 10 -h ${DHCP_HOSTNAME[$1]} eth${1}" | $LOGGER
          /sbin/dhcpcd -d -t 10 -h ${DHCP_HOSTNAME[$1]} eth${1}
        else
          echo "/etc/rc.d/rc.inet1:  /sbin/dhcpcd -d -t 10 eth${1}" | $LOGGER
          /sbin/dhcpcd -d -t 10 eth${1}
        fi
      else # bring up interface using a static IP address
        if [ ! "${IPADDR[$1]}" = "" ]; then # skip unconfigured interfaces
          # Determine broadcast address from the IP address and netmask:
          BROADCAST=`/bin/ipmask ${NETMASK[$1]} ${IPADDR[$1]} | cut -f 1 -d ' '`
          # Set up the ethernet card:
          echo "/etc/rc.d/rc.inet1:  /sbin/ifconfig eth${1} ${IPADDR[$1]} broadcast ${BROADCAST} netmask ${NETMASK[$1]}" | $LOGGER
          /sbin/ifconfig eth${1} ${IPADDR[$1]} broadcast ${BROADCAST} netmask ${NETMASK[$1]}
        else
          if [ "$DEBUG_ETH_UP" = "yes" ]; then
            echo "/etc/rc.d/rc.inet1:  eth${1} interface is not configured in /etc/rc.d/rc.inet1.conf" | $LOGGER
          fi
        fi
      fi
    else
      if [ "$DEBUG_ETH_UP" = "yes" ]; then
        echo "/etc/rc.d/rc.inet1:  eth${1} is already up, skipping" | $LOGGER
      fi
    fi 
  else
    if [ "$DEBUG_ETH_UP" = "yes" ]; then
      echo "/etc/rc.d/rc.inet1:  eth${1} interface does not exist (yet)" | $LOGGER
    fi
  fi
}

# Function to take down an Ethernet interface:
eth_down() {
  if grep eth${1}: /proc/net/dev 1> /dev/null ; then
    if [ "${USE_DHCP[$1]}" = "yes" ]; then
      echo "/etc/rc.d/rc.inet1:  /sbin/dhcpcd -k -d eth${1}" | $LOGGER
      /sbin/dhcpcd -k -d eth${1} || /sbin/ifconfig eth${1} down
      sleep 1
    else
      echo "/etc/rc.d/rc.inet1:  /sbin/ifconfig eth${1} down" | $LOGGER
      /sbin/ifconfig eth${1} down
    fi
  fi
}

Neksys ★★★
()
Ответ на: комментарий от Neksys

насколько я понял ifconfigom DHCP непрописывается и правильнее будет править файл /etc/sysconfig/network-scripts/ifcfg-eth0

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.