# This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: ens33: addresses: [192.168.37.200/24] dhcp4: no gateway4: 192.168.37.1 nameservers : addresses: [8.8.8.8] version: 2 //应用 sudo netplan apply
3.2 防火墙开启http服务
1 2 3 4 5 6 7 8 9
//安装apache sudo apt-get install apache2
//查看目录配置文件 cd /etc/apache2 ls
//重启apache2 sudo /etc/init.d/apache2 restart
3.3 配置iptables
编辑文件 /etc/iptables.rules
1
vi /etc/iptables.rules
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# Firewall configuration written by system-config-firewall ## Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 5000 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 9000 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT