How to set firewall iptables for intrnet ip and port to access internet destination ip address

Spread the love

I have two linux servers: serverONE and serverTWO.
serverONE has Intranet address :
serverTWO has two ip address: and And is also Intranet address; is internet address.
I have a internet destination address:
[[email protected] ~]$ ping // is OK

and serverONE connects serverTWO is OK.
[[email protected] ~]$ ping // is OK

I set iptables with serverTWO , and gateway in serverONE.
And it makes serverONE can ping like:
[[email protected] ~]# cat /proc/sys/net/ipv4/ip_forward
[[email protected] ~]# iptables -t nat -A POSTROUTING -s -j SNAT –to

[[email protected] ~]# echo “GATEWAY=” >> cat /etc/sysconfig/network-scripts/ifcfg-eth0
[[email protected] ~]# systemctl restart network

and then
[[email protected] ~]$ ping //is OK.

NOW, I want to make serverONE connect with port 1005, like:
[[email protected] ~]$ curl //is failed
curl: (7) Failed to connect to port 1055: No route to host

I have tested serverTWO, and it is OK, like:
[[email protected] ~]$ curl //is OK
curl: (52) Empty reply from server

I have tried to make port NAT, like :
[[email protected] ~]# iptables -t nat -A PREROUTING –dst -p tcp –dport 1005 -j DNAT –to-destination
[[email protected] ~]# iptables -t nat -A POSTROUTING –dst -p tcp –dport 1005 -j DNAT –to

UNluck, it fails again:
[[email protected] ~]$ curl //is failed again
curl: (7) Failed to connect to port 1055: No route to host

I don’t know how to set iptables, who can help me ?

X ITM Cloud News


Leave a Reply

Next Post

Fixed Missing Emoji - Now Emoji Overkill!

Thu Sep 17 , 2020
Spread the love          Many of the emoji in my system were missing/weren’t loading in color. I followed the directions in this post and updated my ~/.config/fontconfig/conf.d/01-emoji.conf file as instructed in the aforementioned link (code provided below) and now I have emoji overkill! My default system font is now changed, the text/character […]

Cloud Computing – Consultancy – Development – Hosting – APIs – Legacy Systems

X-ITM Technology helps our customers across the entire enterprise technology stack with differentiated industry solutions. We modernize IT, optimize data architectures, and make everything secure, scalable and orchestrated across public, private and hybrid clouds.

This image has an empty alt attribute; its file name is x-itmdc.jpg

The enterprise technology stack includes ITO; Cloud and Security Services; Applications and Industry IP; Data, Analytics and Engineering Services; and Advisory.

Watch an animation of  X-ITM‘s Enterprise Technology Stack

We combine years of experience running mission-critical systems with the latest digital innovations to deliver better business outcomes and new levels of performance, competitiveness and experiences for our customers and their stakeholders.

X-ITM invests in three key drivers of growth: People, Customers and Operational Execution.

The company’s global scale, talent and innovation platforms serve 6,000 private and public-sector clients in 70 countries.

X-ITM’s extensive partner network helps drive collaboration and leverage technology independence. The company has established more than 200 industry-leading global Partner Network relationships, including 15 strategic partners: Amazon Web Services, AT&T, Dell Technologies, Google Cloud, HCL, HP, HPE, IBM, Micro Focus, Microsoft, Oracle, PwC, SAP, ServiceNow and VMware