LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Question on IPTABLES (https://www.linuxquestions.org/questions/linux-networking-3/question-on-iptables-144520/)

brokenflea 02-10-2004 02:11 PM

Question on IPTABLES
 
this is the first time i'm setting up a firewall using iptables and i needed help with my setup script. this is the beginning portion of what the script looks like :

INTERFACE="eth0"
IPADDR="
BCASTADDR="192.168.1.255"

my question was, i have a home network setup with a linksys wired router and my linux box uses a DHCP address given by the router. what entry to i put in the iptables script for IPADDR ? or how does that work

thanks in advance

david_ross 02-10-2004 02:50 PM

You could try:
IPADDR=`/sbin/ifconfig eth0 | grep inet | awk {'print $2'} | cut -d: -f2`

Or give it a fixed IP.

jazernorth 02-10-2004 03:02 PM

This is how I dynamically get my eth0 IP address:

Code:

AWK=/bin/awk

IFCONFIG=/sbin/ifconfig

EXTIF="eth0"

EXTIP="`$IFCONFIG $EXTIF | $AWK \
 /$EXTIF/'{next}//{split($0,a,":");split(a[2],a," ");print a[1];exit}'`"


Half_Elf 02-10-2004 09:53 PM

you could also use rules aimed on device (eth0, eth1, ppp0, etc...) instead of ip.
this work well too :)


All times are GMT -5. The time now is 05:20 PM.