LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-10-2004, 02:11 PM   #1
brokenflea
Member
 
Registered: Nov 2003
Distribution: Slackware 11.0, FreeBSD
Posts: 284

Rep: Reputation: 30
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
 
Old 02-10-2004, 02:50 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

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

Or give it a fixed IP.
 
Old 02-10-2004, 03:02 PM   #3
jazernorth
Member
 
Registered: Jan 2004
Location: Green Bay
Distribution: RedHat 8.0, LFS-5.0
Posts: 100

Rep: Reputation: 15
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}'`"

Last edited by jazernorth; 02-10-2004 at 03:04 PM.
 
Old 02-10-2004, 09:53 PM   #4
Half_Elf
Guru
 
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables question iomari Linux - Security 4 01-13-2005 12:14 AM
Iptables Question? unixfreak Linux - Security 1 09-01-2004 08:23 PM
iptables Question gauge73 Linux - Networking 3 12-14-2003 12:02 AM
IPtables Question jacovds Linux - Security 10 11-17-2003 09:46 AM
iptables question Texicle Slackware 7 01-19-2003 12:48 AM


All times are GMT -5. The time now is 02:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration