LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-07-2011, 05:29 AM   #16
CodeKrash
LQ Newbie
 
Registered: May 2011
Posts: 21

Rep: Reputation: 1

I think I found it:

Code:
I think I found it:

Code:
iptables -t nat -A PREROUTING -i eth0 -p tcp -dport 80 -j DNAT -to 192.168.0.2:80
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-07-2011, 05:48 AM   #17
CodeKrash
LQ Newbie
 
Registered: May 2011
Posts: 21

Rep: Reputation: 1
Am I obviously missing something here?
Code:
[root@codekrash ~]#  iptables -t nat -A PREROUTING -i eth0 -p tcp -sport 8080 -j DNAT -to 10.8.0.6
Bad argument `8080'
and

Code:
[root@codekrash ~]#  iptables -t nat -A PREROUTING -i eth0 -p tcp -sport 8080 -j DNAT -to 10.8.0.6:8080
Bad argument `8080'
 
Old 05-07-2011, 06:27 AM   #18
CodeKrash
LQ Newbie
 
Registered: May 2011
Posts: 21

Rep: Reputation: 1
Talking

Code:
[root@codekrash ~]# iptables -t nat -A PREROUTING -i eth1 -s 0.0.0.0/0 -d 10.8.0.6 -p tcp --dport 8080 -m state --state ESTABLISHED,RELATED -j ACCEPT
Code:
[root@codekrash ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
2    REJECT     all  --  0.0.0.0/0            127.0.0.0/8         reject-with icmp-port-unreachable
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:1194
5    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80
6    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:3690
7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
8    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           icmp type 8
9    LOG        all  --  0.0.0.0/0            0.0.0.0/0           limit: avg 5/min burst 5 LOG flags 0 level 7 prefix `iptables denied: '
10   REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

Table: nat
Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     tcp  --  0.0.0.0/0            10.8.0.6            tcp dpt:8080 state RELATED,ESTABLISHED

Chain POSTROUTING (policy ACCEPT)
num  target     prot opt source               destination
1    SNAT       all  --  10.8.0.0/24          0.0.0.0/0           to:209.59.217.122

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination
do i need to add an additional forward somewhere, because it's not seeming to work

edit:
Code:
 iptables  -A FORWARD -i eth1 -s 0.0.0.0/0 -d 10.8.0.6 -p tcp --dport 8080 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Code:
Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     tcp  --  0.0.0.0/0            10.8.0.6            tcp dpt:8080 state NEW,RELATED,ESTABLISHED
maybe i need to change the target ip?

edit2:
Code:
iptables -A INPUT -i eth1 -s 0.0.0.0/0 -d $LANIP -p tcp --sport 8080 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -i eth1 -s 0.0.0.0/0 -d $INTERNETIP -p tcp --dport 8080 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables  -A FORWARD -i eth1 -s 0.0.0.0/0 -d $INTERNETIP -p tcp --dport 8080 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

Last edited by CodeKrash; 05-07-2011 at 06:52 AM.
 
Old 05-07-2011, 07:23 AM   #19
CodeKrash
LQ Newbie
 
Registered: May 2011
Posts: 21

Rep: Reputation: 1
Thumbs up SNAT/DNAT Port Forwarding - SOLUTION

Code:
iptables -t nat -A PREROUTING -d $INTERNETIP -p tcp --dport 8080 -j DNAT --to-destination $LANIP
don't you love it when things slide together nicely
 
Old 04-12-2015, 08:12 AM   #20
dr_dex
LQ Newbie
 
Registered: Dec 2005
Location: Tønsberg, Norway
Distribution: Ubuntu
Posts: 9

Rep: Reputation: 0
Exclamation

Quote:
Originally Posted by peter_robb View Post
You should have modules ip_conntrack_pptp & ip_nat_pptp loaded at least.
do lsmod to check and modprobe ip_nat_pptp to load both..
Thanks a bunch for this little nugget!

Just FYI, in newer kernels these modules are called nf_nat_pptp and nf_conntrack_pptp.

If you need to load all of the nat/conntrack modules supported by your kernel, you can use this little script:
Code:
#!/bin/bash
# Load all NAT and connection tracking netfilter modules for current kernel
find /lib/modules/$(uname -r)/kernel/net/netfilter/ 
    -name nf_\*.ko | sed 's/\.ko$//' | while read name; \
    do modprobe $(basename $name) ; done
find /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter/ \
    -name nf_\*.ko | sed 's/\.ko$//' | while read name; \
    do modprobe $(basename $name) ; done
find /lib/modules/$(uname -r)/kernel/net/ipv6/netfilter/ \
    -name nf_\*.ko | sed 's/\.ko$//' | while read name; \
    do modprobe $(basename $name) ; done
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
IPTABLES and GRE PPTP working jbrandis Linux - Security 3 10-27-2005 10:15 AM
iptables forward one port on same IP baetmaen Linux - Networking 2 01-27-2005 08:47 AM
How to port forward with IPTABLES... Scrag Linux - Security 6 12-13-2004 04:57 AM
IPTABLES port forward wanaka Linux - Security 3 09-28-2004 07:07 PM
Port Forward with iptables nymig94 Linux - Networking 5 12-02-2001 09:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration