iptables配置网络地址转换(nat)

创建nat

# iptables -t nat -A PREROUTING -p tcp --dport 15796 -j DNAT --to-destination 1.2.3.4:1210
# service iptables save
# systemctl restart iptables
#iptables -t nat -vnL

#iptables -t nat -A POSTROUTING -p tcp -d 1.2.3.4 --dport 1210 -j MASQUERADE

删除nat

# iptables -t nat -D PREROUTING  1
# iptables -t nat -D POSTROUTING 1

查看nat

# iptables -t nat -vnL
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    3   156 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            tcp dpt:15796 to:1.2.3.4:1210

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 978 packets, 70677 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    3   156 MASQUERADE  tcp  --  *      *       0.0.0.0/0            1.2.3.4        tcp dpt:1210

Chain OUTPUT (policy ACCEPT 978 packets, 70677 bytes)
 pkts bytes target     prot opt in     out     source               destination

相关推荐

  1. iptables配置网络地址转换(nat)

    2024-07-13 10:50:02       28 阅读
  2. NAT网络地址转换)模式

    2024-07-13 10:50:02       30 阅读
  3. Linux iptables地址转换

    2024-07-13 10:50:02       50 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-13 10:50:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-13 10:50:02       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-13 10:50:02       58 阅读
  4. Python语言-面向对象

    2024-07-13 10:50:02       69 阅读

热门阅读

  1. 【STM32 ARM】区分MCU,MPU与AP

    2024-07-13 10:50:02       21 阅读
  2. LeetCode 每日一题 2024/7/8-2024/7/14

    2024-07-13 10:50:02       26 阅读
  3. 工作需求第一次写千行SQL语句

    2024-07-13 10:50:02       20 阅读
  4. 项目管理开发实战

    2024-07-13 10:50:02       28 阅读
  5. 【AI原理解析】—知识图谱(KG)原理

    2024-07-13 10:50:02       18 阅读
  6. 0139__TCP协议

    2024-07-13 10:50:02       20 阅读
  7. sqlmap常用参数及示例

    2024-07-13 10:50:02       23 阅读
  8. 软件测试面试200问【答案+文档】

    2024-07-13 10:50:02       24 阅读
  9. C++之STL简介

    2024-07-13 10:50:02       23 阅读
  10. Linux——多路IO

    2024-07-13 10:50:02       25 阅读