惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
V
V2EX
博客园 - 【当耐特】
V
Visual Studio Blog
宝玉的分享
宝玉的分享
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
News | PayPal Newsroom
Schneier on Security
Schneier on Security
I
InfoQ
博客园 - Franky
The GitHub Blog
The GitHub Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Commits to openclaw:main
Recent Commits to openclaw:main
AI
AI
WordPress大学
WordPress大学
Webroot Blog
Webroot Blog
L
LangChain Blog
Help Net Security
Help Net Security
V2EX - 技术
V2EX - 技术
TaoSecurity Blog
TaoSecurity Blog
O
OpenAI News
月光博客
月光博客
H
Hacker News: Front Page
F
Full Disclosure
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security Affairs
博客园 - 司徒正美
MyScale Blog
MyScale Blog
Vercel News
Vercel News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hacker News: Ask HN
Hacker News: Ask HN
N
News and Events Feed by Topic
J
Java Code Geeks
Simon Willison's Weblog
Simon Willison's Weblog
Recent Announcements
Recent Announcements
D
Darknet – Hacking Tools, Hacker News & Cyber Security
I
Intezer
The Last Watchdog
The Last Watchdog
博客园_首页
C
Check Point Blog
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - NetSoft

java - 环境变量 ubuntu - 网络文件夹访问 ubuntu - 查看硬盘占用情况 ubuntu - 查看系统资源占用(内存,cpu和进程) ubuntu - 配置IP地址 Ubuntu - 切换到管理员(root)身份 ubuntu - 下更改语言环境 reporting server改名 facebook是如何管理代码的 SIM卡编号的含意 vi编辑器常用的命令及快捷键 IIS 问题 64位windows 2003环境UNC部署权限设置 Linux常用的压缩及解压缩命令如表2-5所示。 Esxi开启putty链接 Android系统中自带的图标 Unparsed aapt error(s)! Check the console for output解决方法 - NetSoft Eclipse自动拷贝SVN的.SVN目录到bin目录问题的解决 - NetSoft - 博客园 浅议DAS、NAS、SAN区别(转载)
Ubuntu iptables 内网端口映射
NetSoft · 2010-09-26 · via 博客园 - NetSoft

1.系统环境

内网两台服务器:

A 172.16.119.128

B 172.16.119.129

希望将A机器的80端口映射到B机器的8013端口。 

2.设置步骤

2.1./etc/sysctl.conf配置文件修改

删除“# net.ipv4.ip_forward = 1”行前面的“#”。 默认该行被注释掉的。

2.2.查看现有配置信息

iptables -L

如果显示内容如下:

Chain INPUT (policy ACCEPT)

target     prot opt source               destination

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination

表示无任何设置,可以继续下一步操作。

否则执行:

iptalbes -F

iptalbes -X

iptalbes -Z 

2.3.设置端口映射

分别执行: 

iptables -t nat -A PREROUTING -d 172.16.119.128 -p tcp --dport 80 -j DNAT --to-destination 172.16.119.129:8013

iptables -t nat -A POSTROUTING -d 172.16.119.129 -p tcp --dport 8013 -j SNAT --to 172.16.119.128

iptables -A FORWARD -o eth0 -d 172.16.119.129 -p tcp --dport 8013 -j ACCEPT

iptables -A FORWARD -i eth0 -s 172.16.119.129 -p tcp --sport 8013 -j ACCEPT

4.验证端口映射

此时,访问http://172.16.119.128/abc.htm,应该能访问到对应129服务器上端口为8013网站的abc.htm页面。 

 
3.设置开机自动加载iptables的配置文件

3.1 保存配置

执行命令: 

# iptables-save > /etc/init.d/iptables.up.rules

将当前配置保存再iptables.up.rules文件中,文件名可以自己决定。

3.2 修改网卡配置文件

在网卡IP配置文件/etc/network/interfaces末行加入(/etc/init.d/iptables.up.rules可改成自己定义的配置文件位置和名称)

pre-up iptables-restore < /etc/init.d/iptables.up.rules

3.3 重启服务器验证

shutdown -r now