Network Startup in a script

This one has got me stumped… :frowning:

I am restarting io-net so I can configure (2) NICs and start IPFilter. If I type out the commands individually it works great, but if I put it in a script 9 times out of 10 it will fail. I have tried sleep commands in the script, but it doesn’t seem to help. I posted the whole script, but it seems to fail on the io-net command, since the next lines are ifconfig and it errors “ifconfig: socket: No such file or directory” When this happens the rest of the script fails, from lack of interfaces. Again if I type these out it works everytime… :confused:

This is what I am trying to do:

echo “Restarting io-net…”
slay -f io-net
sleep 2
io-net -d ne2000 -d el900 -p tcpip forward
sleep 2
ps -A | grep io-net
echo “done.”
echo “Bringing up interfaces…”
ifconfig en0 up
ifconfig en1 up
sleep 1
ifconfig -a
sleep 1
echo “done.”
echo “Assigning IP addresses…”
netmanager
echo “done.”
echo “Starting IPFilter…”
mount -T io-net /lib/dll/nfm-ipfilter.so
sleep 1
ipnat -FC -f/etc/ipfd.conf
sleep 1
ipf -f/etc/ipfw.conf
ipf -y
echo “done.”

The key is not to sleep but to invoke wakefor on the resource you are waiting to arrive. For example…

slay -f io-net
io-net -d ne2000 -d el900 -p tcpip forward
waitfor /dev/io-net/en0
waitfor /dev/io-net/en1
waitfor /dev/io-net/ip0
ifconfig en0 …
ifconfig en1 …
mount -Tio-net /lib/dll/nfm-ipfilter.so
waitfor /dev/io-net/…

You get the picture now I am sure.

Thanks for the help… all is working now. I am running 6.1 so it took me bit to find that “waitfor” is “on” in 6.1. This is what I ended up doing:

cat /etc/rc.d/rc.local

echo “Restarting io-net…”
slay -f io-net
io-net -d ne2000 -d el900 -p tcpip forward
ps -A | grep io-net
echo “done.”
echo “Briniging up interfaces…”
on -w /dev/io-net/en0 -W30
on -w /dev/io-net/en1 -W30
on -w /dev/io-net/ip0 -W30
on -w /dev/io-net/ip_en -W30
ifconfig en0 up
ifconfig en1 up
ifconfig -a
sleep 2
echo “done.”
echo “Assigning IP addresses…”
netmanager
ifconfig -a
echo “done.”
echo “Starting IPFilter…”
mount -T io-net /lib/dll/nfm-ipfilter.so
on -w /dev/io-net/ip_ip0 -W30
ipnat -FC -f/etc/ipfd.conf
ipf -f/etc/ipfw.conf
ipf -y
echo “done.”

When deal with network interface, if_up is more powerful.

if_up -p en0
if_up -p en1
netmanager

is more reliable.

I have tried if_up… and it always returned a true on the interface. What is the -p for? I didn’t see that option in the man page.

Sorry about that - in 6.2 waitfor is just a symlink to on which “does the right thing”.

Oops, I forgot you are running 6.1, maybe that is not supported in
6.1. But if_up should wait until there is an IP configured on an
interface (that’s what it designed to), so “always return true”
sounds no good if you “if_up en0” before even ifconfig it.

Here is what is says on a 6.2 installation.

$ use if_up
if_up [-ap] [-r retries] [-s seconds] interface…

Options:
-p Only wait until specified interfaces are present. Default is
to wait until interfaces are both present and configured.
-a Wait until all specified interfaces are present / configured.
Default is to wait until a single interface is present /
configured.
-r retries Number of times to walk interface list. Default is 5.
-s seconds Wait this number of seconds before re-walking interface list.
Default is 1.

I have a NIC card that has two interfaces on it - ie. both en0 and en1 are on the same card.

I tried

slay io-net
io-net -di82544 -ptcpip if=en0:192.168.0.1,if=en1:192.168.0.2

But - from another PC, I can only ping to the IP address of en0, not en1.
If I don’t config en0, ie: io-net -di82544 -ptcpip if=en1:192.168.0.2
then I can ping to en1.

What is the proper way to config multiple interfaces on the same NIC card to run TCPIP?

I am running 6.21 PE.

I don’t think QNX supports to have two IP addresses on the same subnet. Maybe you can try to use 192.168.0.X for one and 192.168.1.X for the other interface.

I tried what you have suggested and it didn’t work for me.

You have to have too separate network for the two subnet, not just playing with different IPs. Assuming you have the QNX box (server A) wired to both network, and you have server B wired on subnet one, server C wired on subnet two. server B should be able to ping one interface on server A, and server C should be able to ping the other interface on server A.