2015年12月15日火曜日

[network]転送系 iptables リバプロ

■http
nginx とかで転送すべし

■その他プロトコル
iptables で転送すべし

- 準備
# cat /etc/sysctl.conf | grep net.ipv4.ip_forward
net.ipv4.ip_forward = 1
↑1になっていること。

- 更新方法  新規
    iptablesの再起動

- 更新 追加
   https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-IPTables-IPTables_Control_Scripts.html
iptablesを安全に追加するには、reload使うと、既存のがフラッシュされない!

   確認(status) > 編集(vi) > 適用(# /sbin/service iptables reload)

   確認方法
    # service iptables status

- 削除
    # iptables -t nat -D POSTROUTING 1


参考サイト:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Security_Guide/s1-firewall-ipt-fwd.html
https://help.sakura.ad.jp/app/answers/detail/a_id/2423/~/iptables%E3%81%AE%E8%A8%AD%E5%AE%9A%E6%96%B9%E6%B3%95

■緊急用
ssh で転送すべし

# ssh -N -f -g -L 80:localhost:10080 root@接続先
 -f バックグランドで動作
 -N リモートでのコマンドなし
 -L ローカル

外部から見た時
 > localhost:80 で接続 http://◯◯.jp等

localhostから見た時
> 外部から80番ポートで接続がくる。
>10080へ変換して、接続先ポートへ受け流す。

■iptables
初期化
*filter
:INPUT ACCEPT [6:424]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [5:588]
COMMIT
 
保存
# /etc/init.d/iptables save
 
開始
# service iptables start 

IP拒否 192.168.0.50
# iptables -I INPUT -s 192.168.0.50 -j DROP
 
■シスコ系
権限変更 
# enable
ACL 変更 >>> http://www.infraexpert.com/study/aclz7.html
 
■ルーティング設定
 /etc/sysconfig/network-scripts このへんい書く

運用中の場合はroute コマンド使う。
 
 route add -net 192.168.100.0/24 gw 192.168.100.253 

0 件のコメント:

コメントを投稿