5、配置iptables
配置也很多。我的如下
修改/etc/sysctl.conf,设置net.ipv4.ip_forward = 1
cp /etc/sysconfig/iptables-config /etc/sysconfig/iptables
我的配置如下:
# Load additional iptables modules (nat helpers)
# Default: -none-
# Space separated list of nat helpers (e.g. 'ip_nat_ftp ip_nat_irc'), which
# are loaded after the firewall rules are applied. Options for the helpers are
# stored in /etc/modules.conf.
#IPTABLES_MODULES=""
#[0] -A PREROUTING -s 192.168.0.11 -p tcp -m tcp -i eth0 --dport 80 -j REDIRECT --to-ports 500
# Unload modules on restart and stop
# Value: yes|no, default: yes
# This option has to be 'yes' to get to a sane state for a firewall
# restart or stop. Only set to 'no' if there are problems unloading netfilter
# modules.
#IPTABLES_MODULES_UNLOAD="yes"
# Save current firewall rules on stop.
# Value: yes|no, default: no
# Saves all firewall rules to /etc/sysconfig/iptables if firewall gets stopped
# (e.g. on system shutdown).
#IPTABLES_SAVE_ON_STOP="no"
# Save current firewall rules on restart.
# Value: yes|no, default: no
# Saves all firewall rules to /etc/sysconfig/iptables if firewall gets
# restarted.
#IPTABLES_SAVE_ON_RESTART="no"
# Save (and restore) rule and chain counter.
# Value: yes|no, default: no
# Save counters for rules and chains to /etc/sysconfig/iptables if
# 'service iptables save' is called or on stop or restart if SAVE_ON_STOP or
# SAVE_ON_RESTART is enabled.
#IPTABLES_SAVE_COUNTER="no"
# Numeric status output
# Value: yes|no, default: no
# Print IP addresses and port numbers in numeric format in the status output.
#IPTABLES_STATUS_NUMERIC="no"
# Generated by webmin
*filter
:INPUT ACCEPT [0]
:FORWARD ACCEPT [0]
:OUTPUT ACCEPT [0]
COMMIT
# Completed
# Generated by webmin
*mangle
:INPUT ACCEPT [0]
:FORWARD ACCEPT [0]
:OUTPUT ACCEPT [0]
REROUTING ACCEPT [0]
OSTROUTING ACCEPT [0]
COMMIT
# Completed
# Generated by webmin
*nat
:OUTPUT ACCEPT [0]
REROUTING ACCEPT [0]
OSTROUTING ACCEPT [0]
# --------------------------------------------
# 关键
# --------------------------------------------
-A PREROUTING -p tcp -m tcp -s 192.168.0.0/24 -i eth0 --dport 80 -j REDIRECT --to-ports 500
-A POSTROUTING -s 192.168.0.0/24 -o eth1 -j SNAT --to-source 192.168.12.164
# --------------------------------------------
# 注意里面的eth,第一据中是-i eth0,表示从eth0进来的数据,即内网数据
# 第二据是-o eth1,表示从eth1出去的数据,即发向外网的数据
# 这里的500表示我修改了squid的端口,没有使用默认的3128
# --------------------------------------------