How to permanently set a network interface to promiscuous mode?
c0uchw4rrior
c0uchw4rrior at gmail.com
Thu Oct 18 21:10:50 UTC 2007
Bram & Josh,
I think ifup-post already includes a clean way to extend its behavior
through the creation of /sbin/ifup-local
The relevant snippet in ifup-post is right at the end:
if [ -x /sbin/ifup-local ]; then
/sbin/ifup-local ${DEVICE}
fi
So, I created a file named /sbin/ifup-local containing Josh's script
fragment (but using $1 instead of ${DEVICE}) and made it executable:
[root at host ~]# cat /sbin/ifup-local
#!/bin/bash
RC=0
PROM=$(egrep -i 'promisc' /etc/sysconfig/network-scripts/ifcfg-$1 | awk
-F"=" '{ print $2 }')
if [ "$PROM" = "yes" ];
then
/sbin/ifconfig $1 promisc
RC=$?
fi
exit $RC
Works like a charm! And I didn't have to modify ifup-post.
Regards,
c0uch
From: "Mertens, Bram" <mertensb mazdaeur com>
> To: "General Red Hat Linux discussion list" <redhat-list redhat com>
> Subject: RE: How to permanently set a network interface to promiscuous
> mode?
> Date : Fri, 3 Aug 2007 09:16:55 +0200
>
> Josh
>
> Thanks for the input I'll have a closer look at this but it looks
> promising!
>
> Regards
>
> Bram
>
> -----Original Message-----
> > From: redhat-list-bounces redhat coma
> > [mailto:redhat-list-bounces redhat com] On Behalf Of Joshua Gimer
> > Sent: donderdag 2 augustus 2007 17:34
> > To: General Red Hat Linux discussion list
> > Subject: Re: How to permanently set a network interface to
> > promiscuous mode?
> >
> > What about adding support for PROMISC yourself in an init
> > script that
> > runs after "network". Maybe something like:
> >
> > #!/bin/bash
> >
> > cd /etc/sysconfig/network-scripts/
> >
> > interfaces=`ls ifcfg* | LANG=C egrep -v '(ifcfg-lo|:|-range|rpmsave|
> > rpmorig|rpmnew)' | \
> > LANG=C egrep -v '(~|\.bak)$' | \
> > LANG=C egrep 'ifcfg-[A-Za-z0-9\._-]+$' | \
> > sed 's/^ifcfg-//g' |
> > sed 's/[0-9]/ &/' | LANG=C sort -k 1,1 -k 2n |
> > sed 's/ //'`
> >
> > for i in $interfaces
> > do
> > PROM=$(egrep -i 'promisc' ifcfg-$i | awk -F"=" '{
> > print $2 }')
> >
> > if [ "$PROM" = "yes" ];
> > then
> > /sbin/ifconfig $i promisc
> > fi
> > done
> >
> > Or you can add support for it in /etc/sysconfig/network-scripts/ifup-
> > post, something like:
> >
> > PROM=$(egrep -i 'promisc' ifcfg-${DEVICE} | awk -F"=" '{ print $2 }')
> >
> > if [ "$PROM" = "yes" ];
> > then
> > /sbin/ifconfig ${DEVICE} promisc
> > fi
> >
> > at the end of the file before exit 0.
> >
> > Josh
> >
> > On Aug 1, 2007, at 1:42 AM, Mertens, Bram wrote:
> >
> > > Hi,
> > >
> > > We need to configure a network interface on one of our machines so
> > > that
> > > it always gets set to promiscuous mode.
> > >
> > > So far I have manually issued "ifconfig eth1 promisc" but I wouldn't
> > > like to do this every time the interface has been brought
> > down and up
> > > again. According to /usr/share/doc/initscripts-7.93.25.EL/
> > > sysconfig.txt
> > > there used to be a "PROMISC=yes" option that could be used in the
> > > "/etc/sysconfig/network-scripts/ifcfg-eth1" file but
> > apparantely this
> > > option is deprecated and the file reads "To properly set
> > these, use
> > > the
> > > packet socket interface."
> > >
> > > So far I haven't been able to find any documentation on this packet
> > > socket interface. How can I configure this netwxork interface to
> > > always
> > > come up in promiscuous mode?
> > >
> > > Thanks in advance.
> > >
> > > Bram
>
More information about the redhat-list
mailing list