Community discussions

MikroTik App
 
dana1975
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Sat Jul 04, 2009 8:32 pm

destination nat with dynamic ip

Fri Aug 07, 2009 12:11 am

i this case i need to map an valid IP address to my web server
provider give me 10Dynamic ip address per each line
i know the dst-nat with static ip
/ip firewall nat add chain=dstnat dst-address=10.5.8.200 action=dst-nat to-addresses=192.168.100.28
/ip firewall nat add chain=srcnat src-address=192.168.100.28 action=src-nat to-addresses=10.5.8.200
but i dont have any static ip
can anybody help me to assign an ip to my webserver
also i need to use dynamic dns to resolve this webserver

thanks
DANA 1.jpg
You do not have the required permissions to view the files attached to this post.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6345
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: destination nat with dynamic ip

Fri Aug 07, 2009 9:10 am

You have to write a script that checks if address is changed and change NAT rules:
http://wiki.mikrotik.com/wiki/Scripting ... ve_changed

You can use Changeip or EveryDNS for dynamic DNS
http://wiki.mikrotik.com/wiki/Dynamic_D ... r_EveryDNS
http://wiki.mikrotik.com/wiki/Dynamic_D ... angeIP.com
 
dana1975
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Sat Jul 04, 2009 8:32 pm

Re: destination nat with dynamic ip

Fri Aug 07, 2009 12:19 pm

thank you for replay
but my problem is different
i don't have any static IP to dst-nat, only provider have IPs and give us with his dhcp server
my question exactly is how can i do the dst-nat for my webserver without knowing the public ip?
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6345
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: destination nat with dynamic ip

Fri Aug 07, 2009 12:24 pm

This is exactly the situation that you have - provider givers you dynamic IP address. So you have to run a script which will check what ip address is set on interface by dhcp server and then script will set that ip address in nat rules.
 
dana1975
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Sat Jul 04, 2009 8:32 pm

Re: destination nat with dynamic ip

Fri Aug 07, 2009 3:00 pm

i explain my situation more and write exactly command that i use
ether1=connect to lan
ether2,3,4=dhcp-client
ether2=ip2,gw2 ether3=ip3,gw3 ether4=ip4,gw4
/ip address add interface=ether1 address=192.168.100.1/24 disabled=no

/ip dhcp-client add interface=ether2 use-peer-dns=yes add-default-route=yes disabled=no
/ip dhcp-client add interface=ether3 use-peer-dns=yes add-default-route=yes disabled=no
/ip dhcp-client add interface=ether4 use-peer-dns=yes add-default-route=yes disabled=no


/ip firewall nat add chain=srcnat action=masquerade disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=gw1,gw2,gw3
now we need 2 ip to assign ether2,first for ether2 and second for destination nat to 192.168.100.28
when i want to run this command
/ip dhcp-client add interface=ether2 use-peer-dns=yes add-default-route=yes disabled=no
MikroTik say to me :" Could not add new dhcp client- dhcp-client on that interface already exists(7)

how can i have 2 IP address and use one of them to dst-nat for my webserver
i write another time that i don't have static ip and only provider have it ang give us only with his dhcp server
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6345
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: destination nat with dynamic ip

Fri Aug 07, 2009 3:12 pm

Well, dhcp client can add only one IP address per interface.
 
dana1975
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Sat Jul 04, 2009 8:32 pm

Re: destination nat with dynamic ip

Fri Aug 07, 2009 3:39 pm

and how can i do dst-nat?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8579
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: destination nat with dynamic ip

Fri Aug 07, 2009 3:44 pm

you cannot add two or more dhcp-clients to one interface

you may try to use bridge to your client, so that your client receive an IP address from your provider's server
Last edited by Chupaka on Fri Aug 07, 2009 3:45 pm, edited 1 time in total.
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6345
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: destination nat with dynamic ip

Fri Aug 07, 2009 3:45 pm

If you can't get second IP then you can't set dst nat :)

One option is to bridge public interface with interface where web server is connected. THat way server will get one of addresses that provider assigned to you and no DST-NAT is needed.

Another option is to use metarouter to get another IP.
http://wiki.mikrotik.com/wiki/Metarouter
 
dana1975
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Sat Jul 04, 2009 8:32 pm

Re: destination nat with dynamic ip

Fri Aug 07, 2009 4:12 pm

Chupaka it's correct, but if i use bridge i can't use load balancing in my webserver
by this way only webserver can have valid ip address
i right ?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8579
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: destination nat with dynamic ip

Fri Aug 07, 2009 4:16 pm

what kind of load-balancing do you need for web-server?.. you are running two parallel web-servers?..
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
dana1975
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Sat Jul 04, 2009 8:32 pm

Re: destination nat with dynamic ip

Mon Aug 10, 2009 5:42 am

no dear friend
only i use 3*512KB upload bandwidth
i connect 3*(1536/512) to mikrotik and also connect webserver to mikrotik(lan ether)
i want to use all upload bandwidth by load balancing
if i use bridge between 2 interface i can't use all BW upload for my webserver
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8579
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: destination nat with dynamic ip

Mon Aug 10, 2009 10:52 am

at first, you should use DNS load-balancing on your three addresses of those three connections - you cannot upload via different uplinks with one src-address, I believe - your ISP will block that
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
dana1975
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Sat Jul 04, 2009 8:32 pm

Re: destination nat with dynamic ip

Mon Sep 07, 2009 11:03 pm

how can i configure DNS load-balancing?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8579
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: destination nat with dynamic ip

Tue Sep 08, 2009 1:04 am

simply add several 'A' records to the DNS server which hosts your domain
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
dsalinas
just joined
Posts: 1
Joined: Fri Mar 19, 2010 8:18 pm

Re: destination nat with dynamic ip

Fri Mar 19, 2010 8:25 pm

any help creating the script to work with the nat rules and dynamic Public IP? my configuration is only one public ip that change every 24h.

the idea is to have the server behind mikrotik for security reasons...

thanks in advance...
:D
 
WarMaster
just joined
Posts: 8
Joined: Wed Oct 25, 2017 10:36 am
Location: The Netherlands

Re: destination nat with dynamic ip

Thu Oct 07, 2021 2:09 pm

I really wish Mikrotik would implement a relative IP reference to a source or destination field in the firewall/NAT enviroment.

Cisco ASA has an option to just refer to the interface as an IP source or destination which in turn points to the IP adres(ses) given to that particular interface weither this IP is static or dynamic.

Working with scripts on network devices to get basic stuff like this working always gives me the heebie jeebies.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8579
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: destination nat with dynamic ip

Thu Oct 07, 2021 5:32 pm

What's wrong with, for example,
in-interface=WAN-1 dst-address-type=local
?
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
WarMaster
just joined
Posts: 8
Joined: Wed Oct 25, 2017 10:36 am
Location: The Netherlands

Re: destination nat with dynamic ip

Wed Oct 13, 2021 1:54 pm

What's wrong with, for example,
in-interface=WAN-1 dst-address-type=local
?
That's exactly what I mean! Rather than defining a new field (dst-address-type) I would suggest using the dst-address field to also accept "local" as a valid entry next to an IP address.

Or even beter; The dst-address field should accept an interface name as relative designation for an IP address. Perhaps there are situations where one would want to refer to a dynamic IP on another interface.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8579
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: destination nat with dynamic ip

Wed Oct 13, 2021 3:43 pm

But then it needs to be renamed to "dst", for example. As neither type nor interface are not addresses :)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.

Who is online

Users browsing this forum: No registered users and 8 guests