java 相关的问题,如下centos 6.8装tomcat
发布网友
发布时间:2022-04-22 22:39
我来回答
共1个回答
热心网友
时间:2022-07-12 05:50
分两步:
1,JAVA程序是否OK
关掉iptables看是否能打开。
2,IPtables没有贴出全部,用下面的脚本执行一下。
sh name.sh
#!/bin/bash
#Purpose:Initial Firewall setting on Centos
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
## Check if user is root
(( $EUID != 0 )) && {
echo "ERROR: You must be root to run this script."
exit 1
}
SPOOFIP="127.0.0.0/8 192.168.0.0/16 \
172.16.0.0/12 10.0.0.0/8 169.254.0.0/16 \
0.0.0.0/8 240.0.0.0/4 255.255.255.255/32 \
168.254.0.0/16 224.0.0.0/4"
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
CUR_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CUR_TIME="$(date +%Y%m%d%H%M%S)"
function init_fwhost(){
echo -e "\033[32mBackup iptables configuration ...backup path:/etc/sysconfig\033[0m"
service iptables start
iptables-save >/etc/sysconfig/iptables.bak.${CUR_TIME}
echo -e "\033[32mInit configuration ...\033[0m"
iptables -F
iptables -X
iptables -Z
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
##add other ip list from here
iptables -A INPUT -j DROP
service iptables save
service iptables restart
chkconfig iptables on
}
#Do main
init_fwhost