mirror of
				https://github.com/juliengk/csf-post-docker.git
				synced 2023-10-10 11:37:41 +00:00 
			
		
		
		
	Refactor one iptables rule
This commit is contained in:
		
							
								
								
									
										12
									
								
								docker.sh
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								docker.sh
									
									
									
									
									
								
							| @@ -70,9 +70,9 @@ if [ `echo ${containers} | wc -c` -gt "1" ]; then | |||||||
| 			add_to_docker_isolation ${DOCKER_NET_INT} ${DOCKER_INT} | 			add_to_docker_isolation ${DOCKER_NET_INT} ${DOCKER_INT} | ||||||
|  |  | ||||||
| 			for net in `docker network ls | awk '{ print $2 }' | grep -Ev "bridge|host|null|ID|${netmode}"`; do | 			for net in `docker network ls | awk '{ print $2 }' | grep -Ev "bridge|host|null|ID|${netmode}"`; do | ||||||
| 				DINT="br-$(docker network inspect -f '{{.Id}}' ${net} | cut -c -12)" | 				dint="br-$(docker network inspect -f '{{.Id}}' ${net} | cut -c -12)" | ||||||
|  |  | ||||||
| 				add_to_docker_isolation ${DOCKER_NET_INT} ${DINT} | 				add_to_docker_isolation ${DOCKER_NET_INT} ${dint} | ||||||
| 			done | 			done | ||||||
|  |  | ||||||
| 			add_to_forward ${DOCKER_NET_INT} | 			add_to_forward ${DOCKER_NET_INT} | ||||||
| @@ -100,11 +100,11 @@ if [ `echo ${containers} | wc -c` -gt "1" ]; then | |||||||
|  |  | ||||||
|                                 iptables -t nat -A POSTROUTING -s ${ipaddr}/32 -d ${ipaddr}/32 -p ${dst_proto} -m ${dst_proto} --dport ${dst_port} -j MASQUERADE |                                 iptables -t nat -A POSTROUTING -s ${ipaddr}/32 -d ${ipaddr}/32 -p ${dst_proto} -m ${dst_proto} --dport ${dst_port} -j MASQUERADE | ||||||
|  |  | ||||||
|                                 if [ $src_ip == "0.0.0.0" ]; then | 				iptables_opt_src="" | ||||||
|                                         iptables -t nat -A DOCKER ! -i ${DOCKER_NET_INT} -p ${dst_proto} -m ${dst_proto} --dport ${src_port} -j DNAT --to-destination ${ipaddr}:${dst_port} | 				if [ ${src_ip} != "0.0.0.0" ]; then | ||||||
|                                 else | 					iptables_opt_src="-d ${src_ip}/32 " | ||||||
|                                         iptables -t nat -A DOCKER -d ${src_ip}/32 ! -i ${DOCKER_NET_INT} -p ${dst_proto} -m ${dst_proto} --dport ${src_port} -j DNAT --to-destination ${ipaddr}:${dst_port} |  | ||||||
| 				fi | 				fi | ||||||
|  | 				iptables -t nat -A DOCKER ${iptables_opt_src}! -i ${DOCKER_NET_INT} -p ${dst_proto} -m ${dst_proto} --dport ${src_port} -j DNAT --to-destination ${ipaddr}:${dst_port} | ||||||
|                         done |                         done | ||||||
|                 fi |                 fi | ||||||
|         done |         done | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user