Solved How to add IPv6 address in DA via terminal not through GUI ?

MaXi32

Verified User
Joined
Jul 25, 2016
Messages
657
Location
The Earth
After DA has finished install, I see only one file that has my IPv4 address in here (eventhough the server is fully compatible with ipv6 before installation)

Code:
/usr/local/directadmin/data/admin/ips/1.2.3.4

I tried the following method documented here to add ipv6 and link to ipv4 (https://www.directadmin.com/features.php?id=1972). In bash script I do the following:

Bash:
#!/bin/bash
IPV4_ADD0="1.2.3.4"
IPV6_ADD="1234:1234:0:0:1234:1234:1234:1234"
echo "action=linked_ips&ip_action=add&ip=${IPV6_ADD}&ip_to_link=${IPV4_ADD0}&apache=yes&dns=yes&apply=yes" >> /usr/local/directadmin/data/task.queue

I ran that script, then when I look at the /var/log/directadmin/errortaskq.log it said this:

Code:
2020:12:17-12:13:01: linked_ips=error=1&result=Error adding link: Error reading ./data/admin/ips/123:123:0:0:123:123:123:123: Unable to open ./data/admin/ips/123:123:0:0:123:123:123:123 for reading.<br>
No such file or directory<br>
<br>

So, I took a guess that perhaps I need to add this IPv6 first into directory /usr/local/directadmin/data/admin/ips, so I did the following:

Code:
/usr/local/directadmin/scripts/addip 1234:1234:0:0:1234:1234:1234:1234 /64 eth0

I'm not sure if addip script is supposed to do the same job what the GUI did but it said in the documentation here the purpose is to add an IP to device: https://www.directadmin.com/features.php?id=2533. But then I got this output:

Code:
IP 1234:1234:0:0:1234:1234:1234:1234 already exists on eth0

I have configured the system to fully support ipv6, what is the correct flow to add this ipv6 and link it manually to ipv4 via terminal? There is no problem if I do this through GUI.
 
Last edited:
So, if I add that IPv6 manually from the GUI here:

ipv6-gui.PNG


and I notice an IP file is created in /usr/local/directadmin/data/admin/ips/1234:1234:0:0:1234:1234:1234:1234. Then only I can run this command:

# THIS IS HOW TO LINK IP VIA COMMAND LINE

Code:
#THIS WILL LINK IPV6 to IPV4:
echo "action=linked_ips&ip_action=add&ip=${IPV6_ADD}&ip_to_link=${IPV4_ADD0}&apache=yes&dns=yes&apply=yes" >> /usr/local/directadmin/data/task.queue

#THIS WILL LINK IPV4 to IPV6:
echo "action=linked_ips&ip_action=add&ip=${IPV4_ADD0}&ip_to_link=${IPV6_ADD}&apache=yes&dns=yes&apply=yes" >> /usr/local/directadmin/data/task.queue

and it links successfully.

But how do I link between ipv4 and ipv6 without first adding IPv6 through GUI?

Since taskq log complained of missing IP file from that directory, I found a documentation about rebuilding IP https://help.directadmin.com/item.php?id=417:

Bash:
#!/bin/bash
IPV4_ADD0="1.2.3.4"
IPV6_ADD="1234:1234:0:0:1234:1234:1234:1234"
# Create an empty IP file with the following contents using bash:
touch /usr/local/directadmin/data/admin/ips/${IPV6_ADD}
{
echo "gateway="
echo "global=no"
echo "linked_ips="
echo "netmask=/64"
echo "ns="
echo "reseller="
echo "status=free"
echo "value="
} >/usr/local/directadmin/data/admin/ips/${IPV6_ADD}

#THIS WILL LINK IPV6 to IPV4:
echo "action=linked_ips&ip_action=add&ip=${IPV6_ADD}&ip_to_link=${IPV4_ADD0}&apache=yes&dns=yes&apply=yes" >> /usr/local/directadmin/data/task.queue

#THIS WILL LINK IPV4 to IPV6:
echo "action=linked_ips&ip_action=add&ip=${IPV4_ADD0}&ip_to_link=${IPV6_ADD}&apache=yes&dns=yes&apply=yes" >> /usr/local/directadmin/data/task.queue

Is creating this IP file equivalent to inserting IP through GUI like in the screenshot? What steps did I miss using this approach ?

Edit:

Updated post with extra info
 
Last edited:
New finding that might fully answered my last question on post #2. I found out that when removing and adding this Ipv6 through GUI, it also will add and remove the ip entries from virtual host entry in here:

# /etc/httpd/conf/ips.conf

Apache config:
<VirtualHost [1234:1234:0:0:1234:1234:1234:1234]:80>
        ServerName shared.domain
        UserDir public_html
        DocumentRoot /var/www/html


        SuexecUserGroup apache apache


        CustomLog /var/log/httpd/homedir.log homedir
        CustomLog /var/log/httpd/access_log combined
</VirtualHost>


<VirtualHost [1234:1234:0:0:1234:1234:1234:1234]:443>
        SSLEngine on
        SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt
        SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key
        SSLCACertificateFile /etc/httpd/conf/ssl.crt/server.ca


        ServerName shared.domain
        UserDir public_html
        DocumentRoot /var/www/html


        SuexecUserGroup apache apache


        CustomLog /var/log/httpd/homedir.log homedir
        CustomLog /var/log/httpd/access_log combined
</VirtualHost>

So in conclusion, I don't think it's a good idea to just add that IP file like in post #2 because we need to edit that apache config too (maybe). Hope to see this feature (or API) release for taskq like what DA has offered for linking btween ipv4 and ipv6. Maybe there is a hidden (undocumented) API for this. If someone found the answer please let me know here.

EDIT: I found the answer. I think I can use this method temporarily and the above httpd config actually can be generated by just running ./build rewrite_confs. Solved.

EDIT2: Today I just started to play with DA API and I can actually use an undocumented API for this which can be obtained through DA debug mode:

Bash:
API: CMD_API_IP_MANAGER
data="action=add&ip=${IPV6}&netmask=/64&device=yes&add_to_device_aware=yes"

So that's an alternative and using this API is the best.
 
Last edited:
In conclusion for all the above posts (which might confused you guys). To manually add IPv4 or Ipv6, you have 2 ways:

1) You can use method in post #2 (modify file system) and remember to run ./build rewrite_conf
2) Using API in last post #3 CMD_API_IP_MANAGER
 
I had an IPv6 configured before installing DA, added it trough the UI (got very upset with DA because my backup restore did not add AAAA records) but thanks to your post I found the existence of "link IP" and behold it works. I did not need to manually trigger anything.
 
I had an IPv6 configured before installing DA, added it trough the UI (got very upset with DA because my backup restore did not add AAAA records) but thanks to your post I found the existence of "link IP" and behold it works. I did not need to manually trigger anything.

You are welcome .. I'm glad that I can help you.
 
Back
Top