Iptables Redirect Script Improvement

Iptables Redirect Script Improvement

Closed - This job posting has been filled and work has been completed.

Job Description

Below is an explanation of what is required:
1. Currently, an authorized IP is the only access to the dns server 1.1.1.1. But we have another server which is 2.2.2.2 where the client should be able to connect to while he is using the dns server 1.1.1.1. In short, we would like you to upgrade the esixting iptables script that should redirects a dns query to dns server 2.2.2.2 whilst the client is using the dns server 1.1.1.1.

2. An existing script called iptables_execute.sh is already in existent to solve the access control for dns 1.1.1.1 by fetching the client IPs to a file from the mysql db to create the appropriate iptables rules for client access.

A file of IP's is in the form of:
23.23.23.45
12.13.14.15
25.46.78.23
14.25.57.68

3. We would like you to extend the existing script, setup dns server on 2.2.2.2 as well as add a dns_server column to the existing database on 1.1.1.1. The final database columns are:

user_info | user_ip | dns_server

4. The script should modify the files (iptables_mysql & iptables_mysql.current) to include the dns server IP for a particular client IP.

An example would be: (Note: a space between the 2 ips in a line)
23.23.23.45 2.2.2.2
12.13.14.15 8.8.4.4
25.46.78.23 3.4.3.4
14.25.57.68 2.4.2.4


5. So the client in IP 23.23.23.45 while using the dns server 1.1.1.1 should be redirected to the dns server 2.2.2.2 and so on for the other client ips.

6. Make sure that only server 1.1.1.1 can access dns server 2.2.2.2

7. If the dns_server for the client is the same as 1.1.1.1, then no redirection should occur.