On Jan 3, 2005, at 6:28 PM, Eric F Crist wrote:
A couple more questions, then I'm done. Promise.
I need to verify whether or not there is an entry for grog_firewall_oif and grog_firewall_iif in /etc/rc.conf. If not, I want to exit with an error.
You want to check for either "grog_firewall_oif" or "grog_firewall_iif" in /etc/rc.conf
egrep -v "^#" /etc/rc.conf |\ egrep -q "grog_firewall_oif | grog_firewall_iif" || (echo "$0" ; exit 1)
The first line says "skips the comment lines" (the ones that begin with #)
Also, a little more advanced, I need to pull information from an ifconfig output. I need to pull network numbers for both the internal interface, as well as external interface. For example,
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 192.168.1.5 netmask 0xffffff00 broadcast 192.168.1.255 inet6 fe80::20e:a6ff:feb9:2d3d%vr0 prefixlen 64 scopeid 0x3 ether 00:0e:a6:b9:2d:3d media: Ethernet autoselect (100baseTX <full-duplex>) status: active
I don't actually need my own address, I need to be able to figure out that the system, based on the above output, is on the 192.168.1.0/24 network. This will be input into my firewall rulesets.
I imagine that there's a util or command around that can do this, or I can code out the math, but there's got to be an easier way.
How much can you assume? Will you know the interface? If so it's fairly easy
ifconfig vr0 |\ tr '\012' ' ' |\ sed 's#.*inet ##; s# netmask.*##'
roughly translated:
line 1: give me the information for vr0 only
line 2: replace the end of line (\012) and replace them with a space
line 3: delete everything from the beginning of the line up to "inet " and then delete everything from " netmask" to the end of the line
Put it into a variable
MY_IP=`ifconfig vr0 |\ tr '\012' ' ' |\ sed 's#.*inet ##; s# netmask.*##'`
TjL
_______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"