Commit 7e7fed4f authored by Mick Tarsel's avatar Mick Tarsel Committed by Natanael Copa
Browse files

Use first network interface that is up

Previous code would return eth0 every time and pay no attention
if interface was up. This patch gets the state from operstate file
in sysfs to use the interface that is actually up in case there
are multiple interfaces present. If no interface is up, just use
last interface.
parent 33865428
......@@ -145,8 +145,11 @@ setup_inittab_console(){
# uses the first "eth" interface.
ip_choose_if() {
for x in /sys/class/net/eth*; do
[ -e "$x" ] && echo ${x##*/} && return
if grep -iq up $x/operstate;then
[ -e "$x" ] && echo ${x##*/} && return
[ -e "$x" ] && echo ${x##*/} && return
# ip_set <device> <ip> <netmask> <gateway-ip>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment