You are not logged in.
Pages: 1
Hi, everybody, I've asked a question about netcfg2.
If I have a static IP on office, and a static IP on home. Could netcfg2 auto detect it? The answer is NO. The only way is use 'menu'.
I just wrote a script '/usr/bin/netcfg-auto-ip'. So, the /etc/rc.conf could be
NETWORKS=(auto-ip office,home,dhcp)
Here is my netcfg-auto-ip, I wish it could be merged into netcfg2's source. Can anybody help me?
#! /bin/bash
# autoconnect one of static ip
# usage: netcfg-auto-ip <network_profiles>
# eg. netcfg-auto-ip office,home
if [[ $# -ne 1 ]]; then
err "Please supply multiple profile name separated by comma"
exit 1
fi
networks=$(echo $1 | sed 's|,| |g')
for network in $networks ; do
echo "Try: $network"
if ! /usr/bin/netcfg2 -c $network ; then
echo "$network already been started"
exit 0
fi
gate=$(route -n | grep "^0.*eth0" | head -1 | awk '{print $2}')
if ping -q -c1 -W1 $gate > /dev/null ; then
exit 0
fi
echo "ping $network's gateway $gate failed"
/usr/bin/netcfg2 -d $network
done
exit 1
# vim: set ts=2 noet:
Last edited by dlin (2008-04-06 03:18:57)
Running 4 ArchLinux including sh4twbox,server,notebook,desktop. my AUR packages
Offline
well, I haven't tried it (I don't use netcfg), but you probably should submit it to the flyspray.
Offline
well, I haven't tried it (I don't use netcfg), but you probably should submit it to the flyspray.
I just added a task 10110
And, the updated script have put there.
Wish there are more people to vote my enhancement. Thanks.:)
I think this patch is useful for who need automatic switch static route/dhcp from different location.
Running 4 ArchLinux including sh4twbox,server,notebook,desktop. my AUR packages
Offline
Pages: 1