阿里云和腾讯云等内网安装DirectAdmin的方法

阿里云和腾讯云因为默认设置的是内网IP, 在安装DirectAdmin的时候有很多问题, 网上虽然有些方法, 不过都只考虑到安装的时候, 但是DirectAdmin每个月还需要更新一次授权, 如果没有设置好, 会导致授权无法更新.

首先查看服务器网卡

/sbin/ifconfig

如果没有显示公网ip地址, 那么我们需要手动设置一个网卡, 如下设置新网卡名称为eth0:0

cd /etc/sysconfig/network-scripts
vi ifcfg-eth0:0

编辑下面的信息, 把IP地址修改为您的公网IP

DEVICE=eth0:0
BOOTPROTO=none
ONPARENT=yes
IPADDR=47.47.47.47
NETMASK=255.255.255.0
ONBOOT=yes

#先检查是否安装了iptables
service iptables status
#安装iptables
yum install -y iptables
#升级iptables(安装的最新版本则不需要)
yum update iptables
#安装iptables-services
yum install iptables-services

 

#停止firewalld服务
systemctl stop firewalld
#禁用firewalld服务
systemctl mask firewalld

#注册iptables服务
#相当于以前的chkconfig iptables on
systemctl enable iptables.service
#开启服务
systemctl start iptables.service
#查看状态
systemctl status iptables.service

 

设置NAT转发:
如公网IP地址是:47.47.47.47, 内网IP地址是:172.21.21.21, 请修改为自己的IP

iptables -t nat -A POSTROUTING -s 47.47.47.47 -j SNAT --to-source=172.21.21.21

保存防火墙规则

service iptables save

再重启服务器

reboot

重启后查看网卡, 看看公网IP有没有设置上

/sbin/ifconfig

测试一下

curl --interface eth0:0 -v https://www.directadmin.com

如果正常就开始安装DirectAdmin, 安装方法参考这里
https://blog.imgchr.com/archives/16/

安装完成后还需要去DirectAdmin后台设置
IP管理–添加IP
把内网IP(如172.21.21.21)添加进去, 掩码可以去/sbin/ifconfig查看
添加完成后返回IP关联, 点击公网IP(如:47.47.47.47), 选择下面的内网IP(如172.21.21.21), 取消添加到DNS, 选择添加到Apache后点击关联.

再编辑DirectAdmin配置文件, 添加LAN IP(内网IP)

vi /usr/local/directadmin/conf/directadmin.conf

lan_ip=172.21.21.21

cd /usr/local/directadmin/custombuild
./build rewrite_confs

然后重启服务器

reboot

About the Author

Avatar photo

今生在线

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据