맞춤형 시스템에서는 유동IP를 얻을 수 없나요?

맞춤형 시스템에서는 유동IP를 얻을 수 없나요?

커널 커스텀 시스템 6.4.0버전을 사용하고 있는데 파일시스템을 사용하고 있는데 왜 IP를 못얻는지 busybox모르겠습니다 . 사용하면 아이피를 얻을 수 있는 enp3s0것 같은데 , 사용해서 확인해 보면 여전히 작동하지 않습니다.udhcpcifconfig -a

# cat /etc/network/interfaces
auto enp3s0
iface enp3s0 inet dhcp

# dmesg |grep enp
[    1.140220] r8169 0000:02:00.0 enp2s0: renamed from eth0
[    1.166766] r8169 0000:03:00.0 enp3s0: renamed from eth1
[    1.985026] r8169 0000:02:00.0 enp2s0: Link is Down
[    2.206037] r8169 0000:03:00.0 enp3s0: Link is Down
[    4.969924] r8169 0000:03:00.0 enp3s0: Link is Up - 1Gbps/Full - flow control rx/tx
[    4.969958] IPv6: ADDRCONF(NETDEV_CHANGE): enp3s0: link becomes ready
[    5.202340] r8169 0000:02:00.0 enp2s0: Link is Up - 1Gbps/Full - flow control rx/tx
[    5.202375] IPv6: ADDRCONF(NETDEV_CHANGE): enp2s0: link becomes ready
# udhcpc -b -i enp3s0 -p /var/run/lan_udhcpc.pid -R
udhcpc: started, v1.36.1
udhcpc: broadcasting discover
udhcpc: broadcasting select for 192.168.50.76, server 192.168.50.254
udhcpc: lease of 192.168.50.76 obtained from 192.168.50.254, lease time 7200
# ifconfig -a
enp2s0    Link encap:Ethernet  HWaddr 00:E0:1A:D8:B0:E3
          inet addr:192.168.5.2  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::2e0:1aff:fed8:b0e3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:548 errors:0 dropped:0 overruns:0 frame:0
          TX packets:358 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:46441 (45.3 KiB)  TX bytes:61582 (60.1 KiB)

enp3s0    Link encap:Ethernet  HWaddr 00:E0:1A:D8:B0:E4
          inet6 addr: fe80::2e0:1aff:fed8:b0e4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6740 errors:0 dropped:56 overruns:0 frame:0
          TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:594227 (580.2 KiB)  TX bytes:4228 (4.1 KiB)

lo        Link encap:Local Loopback
          LOOPBACK  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

답변1

default.script내 문제는 ip를 추가하여 일시적으로 해결되었습니다 . 그러나 왜 udhcpc그러한 추가 작업이 필요한지 잘 이해하지 못합니다 . 저장하고 사용하기 위해 동적으로 IP를 얻습니다.

다음에 추가 -s /etc/udhcpc/default.script:

udhcpc -b -i enp3s0 -p /var/run/lan_udhcpc.pid -R -s /etc/udhcpc/default.script

기본 스크립트:

#!/bin/sh

[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1

RESOLV_CONF="/etc/resolv.conf"
[ -e $RESOLV_CONF ] || touch $RESOLV_CONF
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"
# Handle stateful DHCPv6 like DHCPv4
[ -n "$ipv6" ] && ip="$ipv6/128"

if [ -z "${IF_WAIT_DELAY}" ]; then
        IF_WAIT_DELAY=10
fi

wait_for_ipv6_default_route() {
        printf "Waiting for IPv6 default route to appear"
        while [ $IF_WAIT_DELAY -gt 0 ]; do
                if [ -z "$(ip -6 route list | grep default)" ]; then
                        printf "\n"
                        return
                fi
                sleep 1
                printf "."
                : $((IF_WAIT_DELAY -= 1))
        done
        printf " timeout!\n"
}

case "$1" in
        deconfig)
                /sbin/ifconfig $interface up
                /sbin/ifconfig $interface 0.0.0.0

                # drop info from this interface
                # resolv.conf may be a symlink to /tmp/, so take care
                TMPFILE=$(mktemp)
                grep -vE "# $interface\$" $RESOLV_CONF > $TMPFILE
                cat $TMPFILE > $RESOLV_CONF
                rm -f $TMPFILE

                if [ -x /usr/sbin/avahi-autoipd ]; then
                        /usr/sbin/avahi-autoipd -k $interface
                fi
                ;;

        leasefail|nak)
                if [ -x /usr/sbin/avahi-autoipd ]; then
                        /usr/sbin/avahi-autoipd -wD $interface --no-chroot
                fi
                ;;

        renew|bound)
                if [ -x /usr/sbin/avahi-autoipd ]; then
                        /usr/sbin/avahi-autoipd -k $interface
                fi
                /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
                if [ -n "$ipv6" ] ; then
                        wait_for_ipv6_default_route
                fi

                if [ -n "$router" ] ; then
                        echo "deleting routers"
                        while route del default gw 0.0.0.0 dev $interface 2> /dev/null; do
                                :
                        done

                        for i in $router ; do
                                route add default gw $i dev $interface
                        done
                fi

                # drop info from this interface
                # resolv.conf may be a symlink to /tmp/, so take care
                TMPFILE=$(mktemp)
                grep -vE "# $interface\$" $RESOLV_CONF > $TMPFILE
                cat $TMPFILE > $RESOLV_CONF
                rm -f $TMPFILE

                # prefer rfc3397 domain search list (option 119) if available
                if [ -n "$search" ]; then
                        search_list=$search
                elif [ -n "$domain" ]; then
                        search_list=$domain
                fi

                [ -n "$search_list" ] &&
                        echo "search $search_list # $interface" >> $RESOLV_CONF

                for i in $dns ; do
                        echo adding dns $i
                        echo "nameserver $i # $interface" >> $RESOLV_CONF
                done
                ;;
esac

HOOK_DIR="$0.d"
for hook in "${HOOK_DIR}/"*; do
    [ -f "${hook}" -a -x "${hook}" ] || continue
    "${hook}" "${@}"
done

exit 0

관련 정보