asked on
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT
iptables -P INPUT DROP
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -m multiport --dports 20028,8084 -j ACCEPT
iptables -A INPUT -i eth0 -s 98.102.63.106 -p tcp --syn -m multiport --dports 22,80,443 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 20028 -j REDIRECT --to-port 22
iptables -t nat -A PREROUTING -i eth0 -s 98.102.63.106 -p tcp --dport 22 -j DNAT --to-destination 192.168.168.10:22
So, ssh'ing to xx.xx.xx.110 from 98.102.63.106 works and gets me to 192.168.168.10.ASKER
> iptables -t nat -L PREROUTING -n -v --line-numbers
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 DNAT tcp -- eth0 * 98.102.63.106 0.0.0.0/0 tcp dpt:22 to:192.168.168.10:22
2 7 420 REDIRECT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:20028 redir ports 22
ASKER
Where is this iptable running?On the firewall, yes, it is a linux box.
What is the test that you are doing?I do have a linux box at 192.168.168.10 which is a stand-in for the Samsung phone system. However, the Samsung will be the same IP and one should get a login prompt on that when ssh'd to as well. When all is said and done, the IP's redirecting to the Samsung will be restricted to the Phone Company's IPs. Right now, it is restricted to an IP I have access to for testing: 98.102.63.10. That redirection works.
ASKER
The only port 22 you should have open is with the source restrictionYes, you're right. That was a silly change on my part. Esp. since I can get to the firewall by `ssh -p 20028 ...` on the host 98.102.63.106. So clearly adding it to the non-restricted list was dumb.
Is there a router before the Linux firewall where you have port forwarding setup?No. The firewall is connected directly to the Internet (ISP's cable modem) and the "Samsung" surrogate (192.168.168.10) is connected directly the the firewall's eth1.
> iptables -t filter -L -n --line-numbers
Chain INPUT (policy DROP)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 20028,8084
5 ACCEPT tcp -- 98.102.63.106 0.0.0.0/0 tcp flags:0x17/0x02 multiport dports 22,80,443
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
iptables -t nat -L --line-numbers> iptables -t nat -L -n --line-numbers
Chain PREROUTING (policy ACCEPT)
num target prot opt source destination
1 REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:20028 redir ports 22
2 DNAT tcp -- 98.102.63.106 0.0.0.0/0 tcp dpt:22 to:192.168.168.10:22
Chain INPUT (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
num target prot opt source destination
1 MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0
Iptables -t DNAT -L --line-numbers> iptables -t DNAT -L -n --line-numbers
iptables v1.4.20: can't initialize iptables table `DNAT': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
Iptables -t MASQUERADE -L --line-numbers> iptables -t MASQUERADE -L -n --line-numbers
iptables v1.4.20: can't initialize iptables table `MASQUERADE': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
Iptables -t SNAT -L --line-numbers> iptables -t SNAT -L -n --line-numbers
iptables v1.4.20: can't initialize iptables table `SNAT': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
And just to round it out:> iptables -L -n --line-numbers
Chain INPUT (policy DROP)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 20028,8084
5 ACCEPT tcp -- 98.102.63.106 0.0.0.0/0 tcp flags:0x17/0x02 multiport dports 22,80,443
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
ASKER
I think in the current configuration you have what you wanted.Well, not quite, and there must be a a way to fix this.
ASKER
What IP does the firewall have, use the LAN side default gateway IP in the --to-destination.The firewall IP is 98.102.63.110, the gateway is 98.102.63.105. There are 2 LAN-side cards which are the gateways for those LANs: 192.168.168.1, 192.168.1.1. Not sure what you mean by "98.102.63.110". Can you show me?
ASKER
Software firewalls, also known as host-based firewalls, provide a layer of software on one host that controls network traffic in and out of that single machine. Most operating systems now include firewall software, but many available software firewalls include central distribution, antivirus systems and disaster recovery.
TRUSTED BY
13 is then followed by the port 22 accept rule on line 15.
Try swapping the order moving line 13 below line 15
iptables -t NAT -L PREROUTING --line-numbers
Iptables has an option I think that you can use the information from the above command to move/change the order of the rule either shifting one down line 13 of the above or moving line 15 above the line-number reported for line 13 above.
Unfortunately, I do not see what the circumstance is.