<![CDATA[Latest posts for the topic "Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network?"]]> /hvaonline/posts/list/24.html JForum - http://www.jforum.net Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network? Internet <-----> Modem <-----> LAN (chỉ gồm 1 máy duy nhất)  Tôi dùng Fedora 9, cấu hình địa chỉ IP tĩnh với thông số như sau: Code:
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Marvell Technology Group Ltd. 88E8036 PCI-E Fast Ethernet Controller
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:13:a9:4f:84:44
ONBOOT=yes
NM_CONTROLLED=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
DHCP_HOSTNAME=xx
DNS1=192.168.1.1
IPADDR=192.168.1.3
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
Thi thoảng, khi restart network, tôi gặp cảnh báo sau: Code:
# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Disabling IPv4 packet forwarding:  net.ipv4.ip_forward = 0
                                                           [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  RTNETLINK answers: File exists
Error adding address 192.168.1.3 for eth0.
                                                           [  OK  ]
Mọi người thử thảo luận xem tại sao lại xuất hiện cảnh báo này? Cách khắc phục như thế nào? ]]>
/hvaonline/posts/list/22679.html#134999 /hvaonline/posts/list/22679.html#134999 GMT
Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network? Code:
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Marvell Technology Group Ltd. 88E8036 PCI-E Fast Ethernet Controller
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:13:a9:4f:84:44
ONBOOT=yes
DNS1=192.168.1.1
SEARCH=xx
NM_CONTROLLED=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
DHCP_HOSTNAME=xx
thì khi restart network lại gặp cảnh báo sau (mặc dù sau đó vẫn truy cập Internet bình thường) Code:
# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface wlan0:                             [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  
Determining IP information for eth0...dhclient(28656) is already running - exiting. 

This version of ISC DHCP is based on the release available
on ftp.isc.org.  Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.

Please report for this software via the Red Hat Bugzilla site:
    http://bugzilla.redhat.com

exiting.
 failed.
                                                           [FAILED]
Có ai có hứng thú tìm hiểu nguyên nhân của mấy cái này không nhỉ?]]>
/hvaonline/posts/list/22679.html#135956 /hvaonline/posts/list/22679.html#135956 GMT
Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network /hvaonline/posts/list/22679.html#135974 /hvaonline/posts/list/22679.html#135974 GMT Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network? http://www.coreth.com/~mpearce/techref/workstation/dhcp.html Upgrade dhcpclient ver 2 lên ver 3 thử xem :) ]]> /hvaonline/posts/list/22679.html#135976 /hvaonline/posts/list/22679.html#135976 GMT Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network?

dabu wrote:
Hi quanta, Mình dạo quanh google tìm ra được cái này : http://www.coreth.com/~mpearce/techref/workstation/dhcp.html Upgrade dhcpclient ver 2 lên ver 3 thử xem :)  
Hì, đây anh: Code:
$ dhclient --version
isc-dhclient-4.0.0
Code:
$ dhclient -V
Internet Systems Consortium DHCP Client 4.0.0
Copyright 2004-2007 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Có vài chỗ cần phải tìm hiểu. Ở trường hợp 1 (private static IP): + RTNETLINK là cái gì? + Đoạn script nào sẽ chạy khi restart network và nó làm những gì? Ở trường hợp 2, khi dùng DHCP, /sbin/dhclient-script đóng vai trò gì, tại sao sau khi shutdown eth0, mà dhclient vẫn chạy?]]>
/hvaonline/posts/list/22679.html#135996 /hvaonline/posts/list/22679.html#135996 GMT
Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network? /hvaonline/posts/list/22679.html#136019 /hvaonline/posts/list/22679.html#136019 GMT Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network? /hvaonline/posts/list/22679.html#136213 /hvaonline/posts/list/22679.html#136213 GMT Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network?

FaL wrote:
Hi quanta, + Thằng RTNETLINK đọc và setup các route,... Nếu khi thiết lập cho thằng eth0, RTNETLINK thấy đã có route tồn tại rồi (192.168..1.3 -> 192.168.1.1) thì nó sẽ báo là file exists. Đây không phải là lỗi, và mạng vẫn làm việc bình thường.  
OK. Cảm ơn bác. Sẽ điều chế từng "em" một.

FaL wrote:
+ Thằng dhclient theo mặc định luôn chạy khi khởi động. Sau đó mới tìm đến tất cả Network interface, xem cái nào có hỗ trợ DHCP, BOOTP thì nó phun script ra. Bởi vậy nên có shutdown thằng eth0 rồi thì nó (dhclient) vẫn chạy như thường. (Kill chắc nó ko chạy nữa :D) + Cái script dhclient-script chỉ là hiện thực hóa những thiết lập trong dhclient.conf thôi.  
--> Cái này thì không đúng: Code:
[root@home ~]# ps aux | grep dhclient
root      2192  0.0  0.0   2576  1168 ?        S    16:22   0:00 /sbin/dhclient -d -sf /usr/libexec/nm-dhcp-client.action -pf /var/run/dhclient-eth0.pid -lf /var/run/dhclient-eth0.lease -cf /etc/dhclient-eth0.conf eth0
root      3265  0.0  0.0   4192   780 pts/1    S+   16:24   0:00 grep dhclient
[root@home ~]# ifdown eth0
[root@home ~]# ps aux | grep dhclient
root      3417  0.0  0.0   4188   760 pts/1    R+   16:25   0:00 grep dhclient
Như vậy là khi start (hoặc up) thì mới có vấn đề: Code:
# sh -x ifup eth0
+ unset WINDOW
+ . /etc/init.d/functions
++ TEXTDOMAIN=initscripts
++ umask 022
++ PATH=/sbin:/usr/sbin:/bin:/usr/bin
++ export PATH
++ '[' -z '' ']'
++ COLUMNS=80
++ '[' -z '' ']'
+++ /sbin/consoletype
++ CONSOLETYPE=pty
++ '[' -f /etc/sysconfig/i18n -a -z '' -a -z '' ']'
++ . /etc/profile.d/lang.sh
+++ sourced=0
+++ '[' -n en_US.UTF-8 ']'
+++ saved_lang=en_US.UTF-8
+++ '[' -f /root/.i18n ']'
+++ LANG=en_US.UTF-8
+++ unset saved_lang
+++ '[' 0 = 1 ']'
+++ unset sourced
+++ unset langfile
++ unset LANGSH_SOURCED
++ '[' -z '' ']'
++ '[' -f /etc/sysconfig/init ']'
++ . /etc/sysconfig/init
+++ BOOTUP=color
+++ GRAPHICAL=yes
+++ RES_COL=60
+++ MOVE_TO_COL='echo -en \033[60G'
+++ SETCOLOR_SUCCESS='echo -en \033[0;32m'
+++ SETCOLOR_FAILURE='echo -en \033[0;31m'
+++ SETCOLOR_WARNING='echo -en \033[0;33m'
+++ SETCOLOR_NORMAL='echo -en \033[0;39m'
+++ LOGLEVEL=3
+++ PROMPT=yes
+++ AUTOSWAP=no
++ '[' pty = serial ']'
++ '[' color '!=' verbose ']'
++ INITLOG_ARGS=-q
++ __sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
+ cd /etc/sysconfig/network-scripts
+ . ./network-functions
++ PATH=/sbin:/usr/sbin:/bin:/usr/bin
++ export PATH
++ '[' -z '/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d' ']'
+ '[' -f ../network ']'
+ . ../network
++ NETWORKING=yes
++ NETWORKING_IPV6=no
++ HOSTNAME=home.kitty.com
+ CONFIG=eth0
+ '[' -z eth0 ']'
+ need_config eth0
+ local nconfig
+ CONFIG=ifcfg-eth0
+ '[' -f ifcfg-eth0 ']'
+ return
+ '[' -f ifcfg-eth0 ']'
+ '[' 0 '!=' 0 ']'
+ source_config
++ sed 's/^ifcfg-//g'
++ basename ifcfg-eth0
+ DEVNAME=eth0
+ echo ifcfg-eth0
+ grep -q '[^g]-'
+ . ifcfg-eth0
++ DEVICE=eth0
++ BOOTPROTO=dhcp
++ HWADDR=00:13:a9:4f:84:44
++ ONBOOT=yes
++ NM_CONTROLLED=yes
++ TYPE=Ethernet
++ USERCTL=yes
++ PEERDNS=yes
++ IPV6INIT=no
++ DHCP_HOSTNAME=home.kitty.com
++ DNS2=192.168.1.1
++ DNS1=192.168.1.1
+ '[' -r keys-eth0 ']'
+ case "$TYPE" in
+ DEVICETYPE=eth
+ '[' -z eth ']'
+ '[' -z '' -a -n '' ']'
+ '[' -z '' ']'
+ REALDEVICE=eth0
+ '[' eth0 '!=' eth0 ']'
+ ISALIAS=no
+ '[' -n 00:13:a9:4f:84:44 ']'
++ echo 00:13:a9:4f:84:44
++ awk '{ print toupper($0) }'
+ HWADDR=00:13:A9:4F:84:44
+ '[' -n '' ']'
+ '[' foo = fooboot ']'
+ '[' -n '' ']'
+ '[' -n '' -a Ethernet = Bridge ']'
+ '[' -x /sbin/vconfig -a '' = yes -a no = no ']'
+ '[' '' = yes ']'
+ '[' dhcp = bootp -o dhcp = dhcp ']'
+ DYNCONFIG=true
+ '[' -x /sbin/ifup-pre-local ']'
+ OTHERSCRIPT=/etc/sysconfig/network-scripts/ifup-eth
+ '[' '!' -x /etc/sysconfig/network-scripts/ifup-eth ']'
+ exec /etc/sysconfig/network-scripts/ifup-eth ifcfg-eth0
dhclient(3848) is already running - exiting. 

This version of ISC DHCP is based on the release available
on ftp.isc.org.  Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.

Please report for this software via the Red Hat Bugzilla site:
    http://bugzilla.redhat.com

exiting.
Trong /etc/sysconfig/network-scripts/ifup-eth, có đoạn này: Code:
if [ -n "${DYNCONFIG}" -a -x /sbin/dhclient ]; then
    # Remove any temporary references which were previously added to dhclient config
    if [ -w /etc/dhclient-${DEVICE}.conf ] ; then
        LC_ALL=C grep -v "# temporary RHL ifup addition" /etc/dhclient-${DEVICE}.conf > /etc/dhclient-${DEVICE}.conf.ifupnew 2> /dev/null
        cat /etc/dhclient-${DEVICE}.conf.ifupnew > /etc/dhclient-${DEVICE}.conf
        rm -f /etc/dhclient-${DEVICE}.conf.ifupnew
    fi
    if [[ "${PERSISTENT_DHCLIENT}" =  [yY1]* ]]; then
       ONESHOT="";
    else
       ONESHOT="-1";
    fi;
    if [ -n "${DHCP_HOSTNAME}" ]; then
       # Send a host-name to the DHCP server (requ. by some dhcp servers).
       if [ -w /etc/dhclient-${DEVICE}.conf ] ; then
           if ! LC_ALL=C grep "send *host-name *\"${DHCP_HOSTNAME}\"" /etc/dhclient-${DEVICE}.conf > /dev/null 2>&1 ; then
               echo "send host-name \"${DHCP_HOSTNAME}\";  # temporary RHL ifup addition" >> /etc/dhclient-${DEVICE}.conf
           fi
       elif ! [ -e /etc/dhclient-${DEVICE}.conf ] ; then
           echo "send host-name \"${DHCP_HOSTNAME}\";  # temporary RHL ifup addition" >> /etc/dhclient-${DEVICE}.conf
       fi
    fi
    # allow users to use generic '/etc/dhclient.conf' (as documented in manpage!) 
    # if per-device file doesn't exist or is empty
    if [ -s /etc/dhclient-${DEVICE}.conf ]; then
       DHCLIENTCONF="-cf /etc/dhclient-${DEVICE}.conf";
    else
       DHCLIENTCONF='';
    fi;
    # copy any lease obtained by the initrd
    if [ -f /dev/.dhclient-${DEVICE}.leases ] ; then
    	mv -f /dev/.dhclient-${DEVICE}.leases /var/lib/dhclient/dhclient-${DEVICE}.leases
	[ -x /sbin/restorecon ] && restorecon /var/lib/dhclient/dhclient-${DEVICE}.leases > /dev/null 2>&1
    fi
    DHCLIENTARGS="${DHCLIENTARGS} ${ONESHOT} -q ${DHCLIENTCONF} -lf /var/lib/dhclient/dhclient-${DEVICE}.leases -pf /var/run/dhclient-${DEVICE}.pid"
    echo
    echo -n $"Determining IP information for ${DEVICE}..."
    if [[ "${PERSISTENT_DHCLIENT}" !=  [yY1]* ]] && check_link_down ${DEVICE}; then
	echo $" failed; no link present.  Check cable?"
	ip link set dev ${DEVICE} down >/dev/null 2>&1
	exit 1
    fi

    if [ -n "$ETHTOOL_OPTS" ] ; then
        /sbin/ethtool -s ${REALDEVICE} $ETHTOOL_OPTS
    fi

    if /sbin/dhclient ${DHCLIENTARGS} ${DEVICE} ; then
	echo $" done."
    else
	echo $" failed."
	exit 1
    fi
# end dynamic device configuration
Stop network và chạy thử lệnh: # sh -x /etc/sysconfig/network-scripts/ifup-eth /etc/sysconfig/network-scripts/ifcfg-eth0 thì được: Code:
...
+ /sbin/dhclient -1 -q -cf /etc/dhclient-eth0.conf -lf /var/lib/dhclient/dhclient-eth0.leases -pf /var/run/dhclient-eth0.pid eth0
dhclient(7169) is already running - exiting. 

This version of ISC DHCP is based on the release available
on ftp.isc.org.  Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.

Please report for this software via the Red Hat Bugzilla site:
    http://bugzilla.redhat.com

exiting.
+ echo ' failed.'
 failed.
+ exit 1
Như vậy là cái warning trên do thằng /sbin/dhclient phun ra. Có thể khẳng định thêm bằng cách: Code:
# grep -lir "is already running - exiting" /sbin
/sbin/dhclient
Có lẽ cần phải download source code của dhclient về và compile lại xem thế nào? ]]>
/hvaonline/posts/list/22679.html#136285 /hvaonline/posts/list/22679.html#136285 GMT
Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network? Code:
# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Disabling IPv4 packet forwarding:  net.ipv4.ip_forward = 0
                                                           [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  RTNETLINK answers: File exists
Error adding address 192.168.1.3 for eth0.
                                                           [  OK  ]
Dự đoán nguyên nhân thì đúng như FaLafterlastangel nói rồi. Giờ ta thử "debug" xem nó phun ra từ đâu. - Stop network lại - Start nó lên ở chế độ "debug": Code:
# sh -x /etc/init.d/network start
...

+ action 'Bringing up interface eth0: ' ./ifup eth0 boot
+ local STRING rc
+ STRING='Bringing up interface eth0: '
+ echo -n 'Bringing up interface eth0:  '
Bringing up interface eth0:  + '[' '' '!=' '' -a -w /etc/rhgb/temp/rhgb-console ']'
+ shift
+ ./ifup eth0 boot
RTNETLINK answers: File exists
Error adding address 192.168.1.99 for eth0.
+ success 'Bringing up interface eth0: '
...
Như vậy là nó "chết" ở:
./ifup eth0 boot 
Lại stop network và chạy tiếp lệnh trên ở "debug mode": Code:
# sh -x /etc/sysconfig/network-scripts/ifup eth0 boot
...

+ OTHERSCRIPT=/etc/sysconfig/network-scripts/ifup-eth
+ '[' '!' -x /etc/sysconfig/network-scripts/ifup-eth ']'
+ exec /etc/sysconfig/network-scripts/ifup-eth ifcfg-eth0 boot
RTNETLINK answers: File exists
Error adding address 192.168.1.99 for eth0.
Tiếp tục: Code:
# sh -x /etc/sysconfig/network-scripts/ifup-eth ifcfg-eth0 boot
...

+ LC_ALL=C
+ ip addr ls eth0
+ LC_ALL=C
+ grep -q 192.168.1.99/24
+ arping -q -c 2 -w 3 -D -I eth0 192.168.1.99
+ ip addr add 192.168.1.99/24 brd 192.168.1.255 dev eth0 label eth0
RTNETLINK answers: File exists
+ echo 'Error adding address 192.168.1.99 for eth0.'
Error adding address 192.168.1.99 for eth0.
OK, như vậy là đoạn code này: Code:
if ! ip addr add ${IPADDR}/${PREFIX} \
            brd ${BROADCAST:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then
            echo $"Error adding address ${IPADDR} for ${DEVICE}."
       fi
trong file /etc/sysconfig/network-scripts/ifup-eth phun ra cái warning trên. Sửa lại đoạn script trên để xem "routing table" trước và sau khi chạy lệnh đó, đồng thời bỏ tùy chọn -q (quiet) trong lệnh arping xem nó phun ra cái gì: Code:
if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${IPADDR}/${PREFIX}" ; then
         route -n
         if ! arping -c 2 -w 3 -D -I ${REALDEVICE} ${IPADDR} ; then
            echo $"Error, some other host already uses address ${IPADDR}."
            exit 1
         fi
         route -n
         if ! ip addr add ${IPADDR}/${PREFIX} \
            brd ${BROADCAST:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then
            echo $"Error adding address ${IPADDR} for ${DEVICE}."
         fi
    fi
Code:
# sh -x /etc/sysconfig/network-scripts/ifup-eth ifcfg-eth0 boot
...

+ LC_ALL=C
+ ip addr ls eth0
+ LC_ALL=C
+ grep -q 192.168.1.99/24
+ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
+ arping -c 2 -w 3 -D -I eth0 192.168.1.99
ARPING 192.168.1.99 from 0.0.0.0 eth0
Sent 2 probes (2 broadcast(s))
Received 0 response(s)
+ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
+ ip addr add 192.168.1.99/24 brd 192.168.1.255 dev eth0 label eth0
RTNETLINK answers: File exists
+ echo 'Error adding address 192.168.1.99 for eth0.'
Error adding address 192.168.1.99 for eth0.
Tóm lại, vấn đề mấu chốt là mời mọi người thảo luận về đoạn script ở trên: Code:
#        if ! ip addr add ${IPADDR}/${PREFIX} \
#           brd ${BROADCAST:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then
#           echo $"Error adding address ${IPADDR} for ${DEVICE}."
#        fi
xem nó có cần thiết hay không? Bởi vì nếu tôi comment đoạn đó lại và restart network thì mọi chuyện suôn sẻ: Code:
# s network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
ARPING 192.168.1.99 from 0.0.0.0 eth0
Sent 2 probes (2 broadcast(s))
Received 0 response(s)
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
                                                           [  OK  ]
]]>
/hvaonline/posts/list/22679.html#146987 /hvaonline/posts/list/22679.html#146987 GMT
Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network? Code:
[root@serverhome ~]# /etc/init.d/network restart
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
]]>
/hvaonline/posts/list/22679.html#178518 /hvaonline/posts/list/22679.html#178518 GMT
Re: Thảo luận lỗi "RTNETLINK answers: File exists" khi restart network? /hvaonline/posts/list/22679.html#178882 /hvaonline/posts/list/22679.html#178882 GMT