沃梦达 / 编程技术 / 服务器 / 正文

Centos6.5 iptables 中的SNAT

SNAT配置网卡网关服务器配置双网卡具体命令cd /etc/sysconfig/network-scriptscp ifcfg-eth0 ifcfg-eth1ip add //查看网卡信息 复制 eth1 MAC地址vim ifcfg-eth1进行修改service network restart...

SNAT

配置网卡
网关服务器
配置双网卡
具体命令
cd /etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-eth1
ip add //查看网卡信息 复制 eth1 MAC地址
vim ifcfg-eth1
进行修改

service network restart
vim /etc/sysctl.conf
修改
net.ipv4.ip_forward = 0 为 1
sysctl -p //更新其配置
配置IP tables规则
iptables -t nat -A POSTOUTING -s 192.168.1.0/24 -o eth1 -j SNAT --to-source 192.168.2.1
外网服务器
配置IP
配置httpd测试
vim /etc/httpd/conf/httpd.conf
修改
ServerName 前井号去除
vim /var/www/html/index.html
写入
It’s web
在内网访问
查看其日志
tailf /etc/httpd/logs/access_log

192.168.2.1 - - [17/Oct/2018:20:25:02 +0800] “GET / HTTP/1.1” 200 35 “-” “Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131029 Firefox/17.0”

实际访问为 外网网关

本文标题为:Centos6.5 iptables 中的SNAT

基础教程推荐