Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Notifications
Mark all as read
Q&A

Dynamic IP & lease loss - "callback" mechanism?

+0
−0

I'm playing with NAT, and have a script now that, at startup of my little Linux machine, creates some DNAT rules, which take one incoming special port, and forward that to another interface with a standard e.g. SSH port, so I can talk to this Linux box, from the outside, and to its connected 2nd box, as if it were one machine, but different ports.

The interface to the outside world was, so far, configured with static IP. But it might need configuring for dynamic assignment.

So, my simple startup bash script adding the DNAt rules with iptables, then won't work anymore:

  1. it can only be called when it's clear that the interface has gotten an IP
  2. the interface could lose the IP (lease) at some point - then the old DNAt rules need to be deleted (?) and new ones added for the updated IP address of the interface in question.

Is there some sort of callback mechanism in Linux that I can hook into, so it tells me when the IP address was changed/assigned, and I can then react to that by fixing the DNAT rules?

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

0 answers

Sign up to answer this question »