iptables DNAT 설정 스크립트

#!/bin/sh

# env setting

BE_SERVER_IP="10.39.x.x "  #private IP

BE_PORT="3306"             #ftp Port 

PF_DEVICE="eth0"           #랜카드

 

# PortFowarding Kernel Setting, PortFowarding ON

echo "1. Kernel Setting : /proc/sys/net/ipv4/ip_forward 0 -> 1"

echo 1 > /proc/sys/net/ipv4/ip_forward

sleep 0.5

 

# Iptables Rule Flush

echo "2. IPTABLES Flush"

iptables -F

iptables -t nat -F

sleep 0.5

 

# Iptables Masq

echo "3. IPTABLES MASQ Setting"

iptables -t nat -A POSTROUTING -o ${PF_DEVICE} -j MASQUERADE

sleep 0.5

 

# PortFowarding Port and Destination Server:port

echo "4. IPTABLES Port Fowrding Setting"

for BE_IP in ${BE_SERVER_IP}

do

           for BE_P in ${BE_PORT}

           do

                     iptables -t nat -A PREROUTING -p tcp --dport ${BE_P} -i ${PF_DEVICE} -j DNAT --to ${BE_IP}:${BE_P}

           done

done

sleep 0.5

 

# Iptables Rules View

echo "4. IPTABLES Rule Review "

echo "====================================================================================================="

echo " "

iptables -t nat -nL

echo " "

echo "====================================================================================================="

echo "5. Done"

exit 0

centos swap 추가

dd if=/dev/zero of=/swapfile count=8192 bs=1Mchmod 600 /swapfilemkswap /swapfileswapon /swapfileecho "/swapfile swap swap defaults 0 0" >> /etc/fstab » 내용보기

time wait 문제 발생 커널 파라미터 변경

#port range 추가echo "1024  65535" > /proc/sys/net/ipv4/ip_local_port_range#tcp timeout 시간 줄이기echo 5 > /proc/sys/net/ipv4/tcp_fin_timeout ( FIN 대기시간 기본 60초에서 5초로 변경) vi /etc/sysct... » 내용보기

lvm 디스크 사용량 모니터링을 위한 팁

1. df로 lvm 마운트 현황 파악2. pvs로 물리적 디스크 볼륨 그룹 할당 현황 파악3. ls -la /sys/block/dm-x/slaves- 어떤 dm-x가 해당 lvm인지 확인 가능- iostat -dxm 1 -p ALL |grep dm-0해당 lvm 디스크 사용량 모니터링 » 내용보기

k8s 자동 완성 및 kubectl alias 설정

BASHecho "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.You can also use a shorthand alias for kubectl that also works with com... » 내용보기