NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I make my Linux RT cRIO run this bash command on startup?

Solved!
Go to solution

I am trying to make my Linux RT cRIO-9064 have an IPv6 address for a project that I am working on. The address that I am trying to add to my cRIO is: fd00::4/64  I can connect to my cRIO via Putty and add my desired IPv6 address with the command /sbin/ip -6 addr add fd00::4/64 dev eth0

 

However, every time I power cycle my cRIO, my IPv6 address gets wiped from memory. How can I prevent this?

 

Would it be possible to run a script that runs the command /sbin/ip -6 addr add fd00::4/64 dev eth0 on startup or is there a file location on the cRIO that stores IPv4/IPv6 addresses and I can just add it there? If so, how?

 

Thanks.

 

 

0 Kudos
Message 1 of 5
(3,893 Views)

Hi JHugh,

 

To directly answer the question that you asked, look into sysv init scripts (we have a handy guide here, but there are plenty of resources online for just this sort of thing).

 

To more directly field the spirit of the question that you're asking (getting a persistent, static ipv6 address on an interface), you're better served looking into the ifplugd scripts that run when a networking interface disappears or becomes available (including startup). The file you want to look at is /etc/ifplugd/ifplugd.action, it's a standard shell script.

 

A word of caution: either of these approaches can be undone when installing software through MAX.

0 Kudos
Message 2 of 5
(3,877 Views)

Hi Brad!

 

Thanks for the response!

 

I tried to follow the tutorial that you linked, and I am receiving the error in my remote shell that "#!/bin/bash is not a file or directory" when I try to test the startup script on step 3.3 of the tutorial. What could cause this, or am I making this more complicated than it needs to be i.e. I could just call my .sh file at the end of this post directly by pasting the code somewhere?

 

Thanks.

 

My startup script is in /etc/init.d/ssj and contains the following code:

#!/bin/bash

 

NAME="IPv6 Startup Script"

DAEMON=/usr/bin/ipv6

ARGS=""

USER=./admin

PIDFILE=/var/run/ipv6.pid

 

do_start() {

/sbin/start-stop-daemon --start --pidfile $PIDFILE \

--make-pidfile --background \

--chuid $USER --exec $DAEMON $ARGS

}

 

do_stop() {

/sbin/start-stop-daemon --stop --pidfile $PIDFILE --verbose

}

 

case "$1" in

start)

echo "Starting $NAME"

do_start

;;

stop)

echo "Stopping $NAME"

do_stop

;;

restart)

echo "Restarting $NAME"

do_stop

do_start

;;

*)

echo "Usage: $0 {start|stop|restart}"

exit 1

;;

esac

 

exit 0

 

My ipv6 configuration code is in /usr/bin/ipv6 and contains the following code:

#!/bin/sh

/sbin/ip -6 addr add fd00::4/64 dev eth0

 

 

0 Kudos
Message 3 of 5
(3,871 Views)
Solution
Accepted by topic author JHugh

I solved it. I updated the file on the cRIO at /etc/network/interfaces by appending the following lines of code:

auto eth0

iface eth0 inet6 static

address fd00::4

netmask 64

gateway 2607:f0d0:2001:000a:0000:0000:0000:0001

0 Kudos
Message 4 of 5
(3,867 Views)

Hmm, my concern with your solution would be that the interface is now being managed from two different systems: ifplugd for ipv4 and busybox for ipv6. I suppose it's working since the settings are fairly orthogonal to one another.

0 Kudos
Message 5 of 5
(3,862 Views)