Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to get portforwarding to work on my linux router. I would like to host a webserver that listens on 8080.
eth1 is my internet interface
eth0 is my LAN interface
iptables -A FORWARD -t filter -i eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
as for the Port forwarding this is what I have so far:
Iptables -t nat - A POSTROUTING -p tcp -i eth1 -d 161.210.34.156 ---dport 80 ---sport 1024:65535 -j DNAT --to 10.0.0.11:8080
iptables -p tccp -i eth1 -eth0 -d 10.0.0.11 --dport 8080 --sport 1024:65535 -m state --state NEW -j ACCEPT
iptables -A FORWARD -t filter -o eth1 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -t filter -i eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
I am very new with iptables. any tips would be great!!
thanks
Originally posted by jebaird I am trying to get portforwarding to work on my linux router. I would like to host a webserver that listens on 8080.
eth1 is my internet interface
eth0 is my LAN interface
iptables -A FORWARD -t filter -i eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
as for the Port forwarding this is what I have so far:
Iptables -t nat - A POSTROUTING -p tcp -i eth1 -d 161.210.34.156 ---dport 80 ---sport 1024:65535 -j DNAT --to 10.0.0.11:8080
iptables -p tccp -i eth1 -eth0 -d 10.0.0.11 --dport 8080 --sport 1024:65535 -m state --state NEW -j ACCEPT
iptables -A FORWARD -t filter -o eth1 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -t filter -i eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
I am very new with iptables. any tips would be great!!
thanks
try this instead (it's basically the same but i cleaned it up for you a little bit ):
Code:
echo 0 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter
iptables -F
iptables -F -t nat
iptables -F -t mangle
iptables -X
iptables -X -t nat
iptables -X -t mangle
iptables -P FORWARD DROP
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -s 10.0.0.0/24 \
-m state --state NEW -j ACCEPT
iptables -A FORWARD -p TCP -i eth1 -eth0 -d 10.0.0.11 --dport 8080 \
-m state --state NEW -j ACCEPT
iptables -t nat -A PREROUTING -p TCP -i eth1 -d 161.210.34.156 \
--dport 80 -j DNAT --to-destination 10.0.0.11:8080
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.