Operating System - HP-UX
1828584 Members
2540 Online
109982 Solutions
New Discussion

script to check if source routing is disabled.

 
SOLVED
Go to solution
chicuks
Advisor

script to check if source routing is disabled.

HI ,

I want to disable source routing-



Please help me with a script to check in HPUX system if source routing is disabled using the avobe option.

only to check.
10 REPLIES 10
James R. Ferguson
Acclaimed Contributor

Re: script to check if source routing is disabled.

Hi :

Why do you need a script? You need to read the manpages:

# ndd -get /dev/ip ip_forward_src_routed

...returns 0 if disabled.

Regards!

...JRF...
chicuks
Advisor

Re: script to check if source routing is disabled.

Hi James,

You are right it returns 0 if source routing is disabled but i need to periodically check if source routing is disabled or it is enabled by some other administrator with root previlages.

The script will help me to check if source routing is disabled on the system.

So you this option could be used in the script.:)
James R. Ferguson
Acclaimed Contributor

Re: script to check if source routing is disabled.

Hi (again):

> You are right it returns 0 if source routing is disabled but i need to periodically check if source routing is disabled or it is enabled by some other administrator with root previlages.

OK, so what is "periodically check" [how often] and what do you want to do if it is in an enabled state and/or a disabled state.

You need to be more clear in framing your questions, please.

Regards!

...JRF...
Fredrik.eriksson
Valued Contributor

Re: script to check if source routing is disabled.

JRF: how can something be in both an enabled and disabled state? :) *giggle*

I'd have to agree with JRF, we can't figure out what you expect from a script.
But guessing what you want you can do something like this:

#!/bin/bash
retval=$(ndd -get /dev/ip ip_forward_src_routed)

if [ $retval -eq 0 ]; then
sendmail
fi

And just add it to your crontab. If you want to take some kind of action when $retval is 0 you can add that instead of the sendmail line.

Best regards
Fredrik Eriksson
James R. Ferguson
Acclaimed Contributor

Re: script to check if source routing is disabled.

Hi (again):

@ Fredrik: JRF: how can something be in both an enabled and disabled state? :) *giggle*

Duh, that was silly of me :-)

@ Chicuks:

The suggestion Fredrik gave is fine. Instead of using 'cron' you could also loop continuously; sleeping for some period; waking and testing the state; and looping again. This can be done in a shell script and there are numerous examples of the technique if you search the forum.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: script to check if source routing is disabled.

>Fredrik: JRF: how can something be in both an enabled and disabled state? :) *giggle*

That reminds me of a saying about set theory:
Sets are not like doors, they can be open and closed at the same time.

For software, you can have something that is both enabled and disabled. That would most likely be a bug where something is wedged and two programs think the state is different. :-)
chicuks
Advisor

Re: script to check if source routing is disabled.

ok lemme make it clear again


i want a script to check & not for remediation.

The aim is to disable source routing.

& to check if source routing is disabled i need a script

the output of the script should be
source routing disabled = OK
source routing enabled =NOK(not ok)
James R. Ferguson
Acclaimed Contributor
Solution

Re: script to check if source routing is disabled.

Hi:

> ok lemme make it clear again

I would hardly call a one-line command to check a "script". However based on the things already said, you could do:

#!/usr/bin/sh
while true
do
RSLT=$(ndd -get /dev/ip ip_forward_src_routed)
if [ "${RSLT}" = 0 ]; then
MSG="source routing disabled = OK"
else
MSG="source routing enabled =NOK (not ok)"
fi
echo ${MSG}
sleep 300
done
exit 0

...This script, once started, would awaken every 300-seconds and announce what it found. If 'cron'ed, the STDOUT will be mailed to the initiating user. If you want a one-time only check, comment out the loop, like:

#!/usr/bin/sh
#while true
#do
RSLT=$(ndd -get /dev/ip ip_forward_src_routed)
if [ "${RSLT}" = 0 ]; then
MSG="source routing disabled = OK"
else
MSG="source routing enabled =NOK (not ok)"
fi
echo ${MSG}
# sleep 300
#done
exit 0

Regards!

...JRF...
chicuks
Advisor

Re: script to check if source routing is disabled.

Thanks James
chicuks
Advisor

Re: script to check if source routing is disabled.

thnx