Beruflich Dokumente
Kultur Dokumente
- Server Fault
Sign up
https://serverfault.com/questions/706462/how-to-set-up-iptables-for-local-router-machine 1/5
4/4/2019 routing - How to set up iptables for local router machine? - Server Fault
#!/bin/bash
ethInternal=eth1
ethExternal=eth0
EDIT 1
EDIT 2
EDIT 3
SV-01: vi /var/log/kern.log
@MadHatter on server/router it is 1 .
on the client it is 0 – puk Jul 17 '15
at 7:18
2 Answers
*filter
# 1. Logging.
# 1.1. logdrop chain
-N logdrop
-A logdrop -j LOG --log-prefix "dropp
-A logdrop -j DROP
# 3. INPUT CHAIN
# 3.0. Allow loopback
-A INPUT -i lo -j ACCEPT
# 3.1. Allow already established conn
-A INPUT -m conntrack --ctstate RELAT
# 3.2. log and drop invalid packets
-A INPUT -m conntrack --ctstate INVAL
# 3.3. Allow DHCP renew on eth0
-A INPUT -p udp -m udp --dport 68 -i
# 3.4. Allow any connections from lan
-A INPUT -i eth1 -j ACCEPT
# 3.5. Log and drop the rest
-A INPUT -j logdrop
# 4. Forwarding
# 4.0. Allow forwarding from lan to w
-A FORWARD -i eth1 -o eth0 -j ACCEPT
# 4.1. Allow forwarding from lan to l
-A FORWARD -i eth1 -o eth1 -j ACCEPT
# 4.2. Allow forwarding from wan to l
By using our site, you acknowledge
-A FORWARD that-oyou
-i eth0 have
eth1 -mread and- understand our Cookie Policy, Privacy Policy, and our
state
# 4.4. log and drop the rest in FORWA
Terms of Service.
-A FORWARD -j logdrop
https://serverfault.com/questions/706462/how-to-set-up-iptables-for-local-router-machine 3/5
4/4/2019 routing - How to set up iptables for local router machine? - Server Fault
COMMIT
*nat
# 5. NAT
# 5.1. Enable NAT
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
*raw
COMMIT
https://serverfault.com/questions/706462/how-to-set-up-iptables-for-local-router-machine 4/5
4/4/2019 routing - How to set up iptables for local router machine? - Server Fault
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
Terms of Service.
https://serverfault.com/questions/706462/how-to-set-up-iptables-for-local-router-machine 5/5