在Linux上部署Llama 3时,网络设置是非常重要的环节,以下是一些关键点和注意事项:
127.0.0.1
或者 localhost
,则该服务仅限于本机访问。为了允许来自其他计算机的请求,应该将API监听的地址更改为服务器的实际公网或局域网IP地址 (0.0.0.0
)。sudo vim /etc/network/interfaces
编辑内容示例:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
应用配置:
sudo netplan apply
sudo vim /etc/sysconfig/network-scripts/ifcfg-eth0
编辑内容示例:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
重启网络:
sudo systemctl restart network
iptables
:sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo iptables-save | sudo tee /etc/iptables/rules.v4
ufw
(适用于Ubuntu):sudo ufw enable
sudo ufw default allow incoming
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
编辑 /etc/resolv.conf
文件,添加DNS服务器地址:
nameserver 8.8.8.8
nameserver 8.8.4.4
ping
和 traceroute
等工具测试网络连通性。通过以上步骤和注意事项,您可以确保在Linux上部署Llama 3时网络配置正确,并且服务能够安全地对外提供。