LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 06-01-2007, 01:58 PM   #1
DoDo1975
LQ Newbie
 
Registered: Nov 2006
Posts: 17

Rep: Reputation: 0
iptables port forwarding - with DHCP


Hi,

I am trying to use iptables to forward ftp protocol through my NAT box but I am worried about what happens with DHCP. I have a startup script:

/sbin/iptables -t nat -A PREROUTING -p $proto -d XXX.XXX.XXX.XXX --dport $low:$high -j DNAT --to-destination $ip
/sbin/iptables -t nat -A OUTPUT -p $proto -d XXX.XXX.XXX.XXX --dport $low:$high -j DNAT --to-destination $ip

The problem being that when my WAN interface is setup to use dhcp, the script may run before there is an IP. I have tried replacing the IP with the interface name, but I am unsure how this will affect the forward? Can someone help?
 
Old 06-03-2007, 11:17 AM   #2
FMC
Member
 
Registered: May 2007
Location: São Paulo
Distribution: Gentoo & Debian
Posts: 97

Rep: Reputation: 15
You can write a script to first find a DHCP server, configure the interface and just create the rules when the IP is up.

But if you change IP by interface it will probably work too, this is the best way and I can see no problem with it, just try out!

[]'s, FMC!
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
port forwarding dhcp sycamorex Linux - Networking 1 03-13-2007 05:54 PM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
Forwarding a port using iptables xtremeclones Linux - Networking 1 11-18-2006 05:21 AM
iptables don't do port forwarding gomen Linux - Networking 4 12-26-2005 03:05 PM
iptables - port forwarding midiguy732 Linux - Networking 1 11-24-2005 01:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:22 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration