How open port in iptables with PROXY ?

Issues related to configuring your network
Post Reply
nice1233
Posts: 8
Joined: 2017/04/01 13:26:20

How open port in iptables with PROXY ?

Post by nice1233 » 2017/04/25 16:01:12

How open port in iptables with PROXY ?

I have PROXY TRANSPARENT in my server. I want to have access external to SSH. My SSH port is 2221. I forwarding port in my router.

SCRIPT TRANSPARENT:
#!/bin/sh
# squid server IP
SQUID_SERVER="192.168.1.1"
# Interface connected to Internet
INTERNET="enp4s2"
# Interface connected to LAN
LAN_IN="enp0s25"
# Squid port
SQUID_PORT="3128"
# DO NOT MODIFY BELOW
# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Load IPTABLES modules for NAT and IP conntrack support
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# For win xp ftp client
#modprobe ip_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow UDP, DNS and Passive FTP
iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
# set this system as a router for Rest of LAN
iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
# unlimited access to LAN i WAN
iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT

# DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT
# if it is same system
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT
# DROP everything and Log it
iptables -A INPUT -j LOG
Please full command to iptables. Thanks!

Macenger
Posts: 23
Joined: 2016/10/18 08:29:57

Re: How open port in iptables with PROXY ?

Post by Macenger » 2017/04/26 13:20:29

I'm sorry the query is unclear. Are you requesting for the iptable rule that would capture traffic to port 22 and redirect it to port 2221?

nice1233
Posts: 8
Joined: 2017/04/01 13:26:20

Re: How open port in iptables with PROXY ?

Post by nice1233 » 2017/04/28 22:33:38

Macenger wrote:I'm sorry the query is unclear. Are you requesting for the iptable rule that would capture traffic to port 22 and redirect it to port 2221?
I changed default port (security).

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: How open port in iptables with PROXY ?

Post by aks » 2017/04/30 15:47:57

I think what you are looking for is something called port forwarding. Google around that and if it is and you have further questions, come back.

Post Reply