Multiple NIC Hosts
-
What’s weird, though, is the /etc/network/interfaces appears to get the proper values set (without the -a) but even without eth0 should still be found with little issue, and without these tweaks (reverting back to only having iface eth0) everything functions properly.
-
[quote=“Tom Elliott, post: 43023, member: 7271”]What’s weird, though, is the /etc/network/interfaces appears to get the proper values set (without the -a) but even without eth0 should still be found with little issue, and without these tweaks (reverting back to only having iface eth0) everything functions properly.[/quote]
Actually, I was trying to go off memory. The flag is [B]-i $iface[/B]. You don’t want to use -a. Sorry about that.
-
Updated to reflect the change. Pushed to inits as well.
-
Would the problems we’re seeing be related to the fact we bring the interface up, but we don’t bring it back down, so when the interface is added and the loop happens, it can’t get dhcp because it believes the link is up?
-
Finally got a chance to play with it, and I have a solution.
Insert a 5-second sleep between setting the interface up and checking the link status (we can’t just check before it gets a chance to find out if it is connected to a cable). Here’s the snippet as modified.
[CODE]…
/sbin/ip link set $iface upProvide time for the interface to update linkstate
sleep 5
linkstate=$(/bin/cat /sys/class/net/$iface/carrier)
…[/CODE]Works on my end.
…and if you wait just a second, I’ll have an optimized version…
-
[CODE]# Enable all interfaces
ifaces=$(ls -1 /sys/class/net | tr -d ‘@’)
for iface in $ifaces; do
/sbin/ip link set $iface up
doneProvide time for interfaces to detect their state
sleep 5
echo “auto lo” > /etc/network/interfaces
echo “iface lo inet loopback” >> /etc/network/interfacesfor iface in $ifaces; do
linkstate=$(/bin/cat /sys/class/net/$iface/carrier)
if [[ “x$linkstate” = “x1” -a “x$iface” != “xlo” ]]; then
echo “auto $iface” >> /etc/network/interfaces
echo “iface $iface inet dhcp” >> /etc/network/interfaces
echo -e “\tudhcpc_opts -t 100 -T 20\n” >> /etc/network/interfaces
fi
/sbin/ip link set $iface down
done[/CODE]This solution only requires one sleep rather than five-seconds of sleep time per interface.
Edit: Fixed typos.
-
Bad statement.
linkstate=$(/bin/cat /sys/class/net/$iface
Should be
linkstate=$(/bin/cat /sys/class/net/$iface) -
Also, shouldn’t the tr -d be tr -d ‘@’ not tr -d ‘0’?
-
[quote=“Tom Elliott, post: 43117, member: 7271”]Also, shouldn’t the tr -d be tr -d ‘@’ not tr -d ‘0’?[/quote]
Sorry, I was copying off code from my cellphone and wasn’t thinking about what I was typing. Also caught another typo on the udhcpc_opt statement.
Fixed the typos in the original post.
-
There’s one more issue
Shouldn’t the cat be reading a file, not the directory?
-
[quote=“Tom Elliott, post: 43128, member: 7271”]There’s one more issue
Shouldn’t the cat be reading a file, not the directory?[/quote]
Yes. Fixed again. I really should have slept more last night.
-
It’s all good, you should see the issues I forget about, like using my mac address implicitly in the inventory and wondering why everybody else is getting repeated inventory errors.
-
[quote=“Tom Elliott, post: 43130, member: 7271”]It’s all good, you should see the issues I forget about, like using my mac address implicitly in the inventory and wondering why everybody else is getting repeated inventory errors.[/quote]
Now that’s a good one.
-
Thank you guys for working on this and making it all run smoothly!