A machine

network card 1   Public network IP
network card 2   Intranet

B machine
network card 1 Intranet

If you want to connect the public network port P1 Mapping to the intranet B Machine port P2

iptables -t nat -A PREROUTING -d [A Public address ] -p tcp -m tcp --dport [ Public network port ] -j DNAT --to-destination [B Intranet IP]:[B Network port ]
iptables -t nat -A POSTROUTING -d [B Intranet IP] -p tcp -m tcp --dport [B Network port ] -j SNAT --to-source [A Intranet address ]
iptables -A FORWARD -o [A A network adapter ] -d [B Intranet IP] -p tcp --dport [B Network port ] -j ACCEPT
iptables -A FORWARD -i [A A network adapter ] -s [B Intranet IP] -p tcp –sport [B Network port ] -j ACCEPT

*nat
:PREROUTING ACCEPT [16232:957099]
:INPUT ACCEPT [16232:957099]
:OUTPUT ACCEPT [33:2307]
:POSTROUTING ACCEPT [33:2307]
-A PREROUTING -d 172.168.6.195/32 -p tcp -m tcp --dport 10000 -j DNAT --to-destination 172.168.6.202:5222
-A POSTROUTING -d 172.168.6.202/32 -p tcp -m tcp --dport 5222 -j SNAT --to-source 172.168.6.195
COMMIT
# Completed on Thu Jun 2 10:17:46 2016
# Generated by iptables-save v1.4.12 on Thu Jun 2 10:17:46 2016
*filter
:INPUT ACCEPT [1048988:102011563]
:FORWARD ACCEPT [7312:1019956]
:OUTPUT ACCEPT [744535:106322618]
-A FORWARD -d 172.168.6.202/32 -p tcp -m tcp --dport 5222 -j ACCEPT
COMMIT

Experience sharing :Linux The double card SNAT and DNAT Mapping local ports out of the Internet

  1. Experience sharing :Linux The double card Different segments Inter-switch communication

    The environment is as follows : present situation : a linux There are two network cards on the host eth0 and eth1 , Machines can access 192 Network service resources , But not accessible 10 Network resources . requirement :linux Can pass eth1 visit 10 Network resources route : network card : operation ...

  2. Linux Double network card binding

    Linux Double network card binding Linux Double network card binding is a common mode of double network card binding :mode1:active-backup Pattern , That is, active standby mode .mode0:round-broin Pattern , Load balancing mode ( Switch configuration is required ...

  3. Linux Double network card binding technology

    bond Technology is in linux2.4 Add the kernel later .  The general procedure is 1. hold bonding Modules are added to the kernel , 2 Edit the network card settings to bind , Remove address settings 3 add to bond equipment , Set the address and other configuration 4  Restart the network 5 At the switch ...

  4. Linux The double card NAT Share the Internet

    linux The double card NAT Share the Internet Glossary of terms private IP Address ( Route unreachable address ) It's a local area network IP Address ( Not visible on the Internet ). public IP Address ( Routing reachable address ) It's one that's visible on the Internet IP Address . IP Camouflage is ...

  5. Linux Dual network card, dual network segment communication

    /********************************************************************************* * Linux Dual network card, dual network segment communication ...

  6. Linux Double network card binding

    Linux Double network card binding author :Eric WeChat :loveoracle11g eth0 and eth1 Bind as bond0 [root@rac-node1 ~]# cat /etc/sysconfig/network ...

  7. Linux Double network card binding bond Detailed explanation -- Single NIC binding multiple IP

    Linux Double network card binding bond Detailed explanation 1 What is? bond network card bond It is binding multiple network cards to a logical network card , Realize the redundancy of local network card , Bandwidth expansion and load balancing , It's a common technology in production scenarios .Kernels 2.4.12 And ...

  8. Linux Dual network card binding configuration

    Linux Dual network card binding configuration                                       Introduction to the environment Linux Redhat 6.5.4 Network card demand 4 Two network cards are bound in pairs ,4 The network cards are eth ...

  9. linux Dual NIC implementation

    linux Implementation of dual NIC , Create a new network card in the virtual machine ,NAT Way to connect , among eth0 Set to connect to the Internet , at present eth0 Automatically assign status to , So the code is commented out ,eth1 Set to connect to the intranet .

Random recommendation

  1. Maven Custom binding plug-in target : Create the source code of the project jar

    <build> <plugins> <!-- Custom binding , Create the source code of the project jar --> <plugin> <groupId>org.apac ...

  2. NYOJ---540 Strange order

    Strange order The time limit :1000 ms  |  Memory limit :65535 KB difficulty :1 describe lately ,Dr. Kong Design a new robot Bill. This robot is very smart , Will do a lot of things . Only the understanding of natural numbers is different from that of human beings ...

  3. GCC Introduction to inline assembly

    The original for GCC-Inline-Assembly-HOWTO, stay google You can find the original text on , Welcome to point out the translation mistakes . Chinese Version Description Due to the limited level of Translators , So there are some mistakes in the translation , Please forgive me. .C The key words of language are not translated , Some words or phrases ( ...

  4. Linux SSH Use public key and private key to realize login free

    Public and private keys ( I'm illiterate , Key words are read before yao, This is a polyphonic word. It should be read here yue), In pairs , Once any of these changes are made, validation fails . 1. The realization of no login :   Use the following example ssky-keygen and ssh-copy- ...

  5. Perfect solution ubuntu Desktop 16.04 Chinese version firefox In Africa root The user can't start normally

    ubuntu After installed , The default installation is firefox browser , however , Not root Account login for , double-click firefox Icon , The following prompt appears :Your Firefox profile cannot be loaded. ...

  6. Mac To build ELK

    Reprint my personal blog :http://blog.ywheel.cn/post/2017/03/04/setup_elk_on_mac/ Recent projects need to quickly retrieve the fields of text data . Combination query . Fuzzy query , On the shelf ...

  7. java Use java.lang.management Monitoring and management Java virtual machine

    ClassLoadingMXBean be used for Java Virtual machine class loading system management interface . CompilationMXBean be used for Java The management interface of the compiler system of the virtual machine . GarbageCollector ...

  8. 32 One use python code snippet

    1. Bubble sort lis = [56,12,1,8,354,10,100,34,56,7,23,456,234,-58] def sortport():    for i in range(len(lis ...

  9. canvas Make a dial

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  10. 【Python】os.path.isfile() How to use

    Method 1 : # -*- coding:utf-8 -*- import os import sys from uiautomator import device as d filepath = r'E: ...