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've been toying around with my ubuntu machine turning it into a router (so I can achieve full vpn speeds) and came up with this firewall script which runs at start up.
Can anyone give me any tips on anything I may have missed. How it's looking etc.
Cheers in advance
Code:
#!/bin/sh
#Reset firewall
/sbin/iptables -t nat -F
/sbin/iptables -t mangle -F
/sbin/iptables -F
/sbin/iptables -X
#Reset IP6
/sbin/ip6tables -t nat -F
/sbin/ip6tables -t mangle -F
/sbin/ip6tables -F
/sbin/ip6tables -X
# Default policy to drop all incoming packets
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/ip6tables -P INPUT DROP
/sbin/ip6tables -P FORWARD DROP
/sbin/ip6tables -P OUTPUT DROP
# Accept incoming/outgoing packets from localhost
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -j ACCEPT
#Allow Plex
/sbin/iptables -A INPUT -p tcp --dport 32400 -j ACCEPT
#Accept local traffic
/sbin/iptables -A INPUT -s 192.168.1.0/24 -j ACCEPT
/sbin/iptables -A OUTPUT -d 192.168.1.0/24 -j ACCEPT
#Accept VPN Server traffic
/sbin/iptables -A INPUT -s 192.168.181.0/24 -j ACCEPT
/sbin/iptables -A OUTPUT -d 192.168.181.0/24 -j ACCEPT
# Accept INPUT if initiated the connection
/sbin/iptables -A INPUT -m conntrack \
--ctstate ESTABLISHED,RELATED -j ACCEPT
# Forward LAN packets to the WAN
/sbin/iptables -A FORWARD -o tun0 -j ACCEPT
# Forward WAN packets to the LAN if the LAN initiated the
# connection
/sbin/iptables -A FORWARD -i tun0 -m conntrack \
--ctstate ESTABLISHED,RELATED -j ACCEPT
# NAT traffic going out the WAN interface
/sbin/iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
#Start VPN
cd /firewall/
/usr/sbin/openvpn con.ovpn
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.