![]() |
甲骨文防火墙、DNS设置 - Printable Version +- MyBBS (https://bbs.mjjjd.eu.org) +-- Forum: My Category (https://bbs.mjjjd.eu.org/forumdisplay.php?fid=1) +--- Forum: VPS (https://bbs.mjjjd.eu.org/forumdisplay.php?fid=2) +--- Thread: 甲骨文防火墙、DNS设置 (/showthread.php?tid=2) |
甲骨文防火墙、DNS设置 - adahrzgj - 08-21-2022 [b]********************************************************************************************[/b] [b]使用iptables开放端口 [/b] 这个大佬使用iptalbes开放了必要的端口,可以用。 sudo iptables -I INPUT -s 0.0.0.0/0 -p tcp --dport 8888 -j ACCEPT sudo iptables -I INPUT -s 0.0.0.0/0 -p tcp --dport 80 -j ACCEPT sudo iptables -I INPUT -s 0.0.0.0/0 -p tcp --dport 443 -j ACCEPT sudo iptables-save sudo apt-get update sudo apt-get install iptables-persistent -y sudo netfilter-persistent save [b]sudo netfilter-persistent reload[/b] [b]********************************************************************************************[/b] [b]彻底禁用防火墙[/b] 直接删除iptables规则 sudo rm -rf /etc/iptables && reboot 开放所有端口 sudo iptables -P INPUT ACCEPT sudo iptables -P FORWARD ACCEPT sudo iptables -P OUTPUT ACCEPT sudo iptables -F sudo apt-get purge netfilter-persistent reboot [b]Oracle自带的Ubuntu镜像默认设置了Iptable规则,关闭它[/b]
apt-get purge netfilter-persistent reboot 强制删除
rm -rf /etc/iptables && reboot
开放所有端口
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT sudo iptables -P OUTPUT ACCEPT sudo iptables -F 强制删除
rm -rf /etc/iptables && reboot[b]修改DNS配置[/b] 一、修改Ubuntu20.04 LTS版本的DNS,首先修改 /etc/systemd/resolved.conf 文件,在其中添加dns信息,例如: DNS=8.8.8.8 114.114.114.114 然后退出保存。 然后以root身份在ubuntu终端中依次执行如下命令: systemctl restart systemd-resolved systemctl enable systemd-resolved mv /etc/resolv.conf /etc/resolv.conf.bak ln -s /run/systemd/resolve/resolv.conf /etc/ 再查看/etc/resolv.conf文件就可以看到新的dns信息已经写入其中了。 二、(永久修改,持续生效) 修改下面文件: vi /etc/network/interfaces 在文件最后加入: dns-nameservers 8.8.8.8 使用过Ubuntu18.04的朋友们应该会遇到域名无法解析的问题,这个时候要设置dns,但是比较恶心的是,18版本不能简单地修改/etc/resolv.conf,因为一旦重启,就恢复默认值了。 也不能修改 /etc/resolvconf/resolv.conf.d/base,因为无法保存修改。 解决办法: sudo vi /etc/systemd/resolved.conf 如图所示,把DNS取消注释,添加DNS,保存退出,重启即可。 [b]oracle 4C24G RHEL 打开防火墙及端口:[/b] 1、检查防火墙的状态 # firewall-cmd --state 2、检索您当前活动的区域。 记下您要在其中打开端口80和443的区域:# firewall-cmd --get-active-zones 3、临时打开端口80和端口443端口: firewall-cmd --zone=public --add-service=http firewall-cmd --zone=public --add-service=https 4、永久打开端口80和443端口: firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --zone=public --permanent --add-service=https firewall-cmd --reload 5、检查开放的端口/服务: firewall-cmd --list-all 6、关闭先前打开的HTTP端口80和HTTPS端口443: firewall-cmd --zone=public --permanent --remove-service=http firewall-cmd --zone=public --permanent --remove-service=https firewall-cmd –reload 禁用整个系统所有接口的IPv6 vi /etc/sysctl.conf net.ipv6.conf.all.disable_ipv6 = 1 运行 sysctl -p /etc/sysctl.conf |