LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 03-05-2012, 06:49 AM   #1
GanIT
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Rep: Reputation: Disabled
Problem configuring firewall


Hope someone will reply as tise thread is so old now.I tried the above mentioned methods using Fedora 16. But didn't work.Will someone help me to figure out the problem? I will give indetail information if I get a reply. Thank You.
 
Old 04-03-2012, 11:21 AM   #2
WizadNoNext
Member
 
Registered: Nov 2009
Posts: 140

Rep: Reputation: 9
GanIT: give me details what you want to achieve and I would give solution.
 
Old 05-13-2012, 05:43 AM   #3
GanIT
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Actually I was trying to make a firewall for my ADSL. Although my main target is to make a firewall for two ADSL connections, first I'm trying to build it for one connection. I used two ehternet cards eth1 for router side p17p1 for LAN side once I succesfully configured both NICs and apply iptable rules on iptable.conf file I try to restart iptable service then I'm getting this error message "Redirecting to /binsystemctl restart iptables.service Job failed. See system logs and ‘systeml status’ for details." When I check /var/logs following logs are created

Localhost iptables.init[2321] : iptables: Appying firewall rules: [FAILED]
Localhost systemd[1]: iptables.service: main process exited, code=exited, status=1
Localhost sytemd[1]: Unit iptables.service entered failed state.

From linux box I can ping a PC which on LAN and can ping router as well. And I can ping both eth1 and p17p1(can ping eth1 only if set default gateway address of client PC as 192.168.1.1[eth1 ip]) from a PC in the LAN but cann’t ping the router. And no internet connection to clients on LAN as well. (have setup DNS in resolv.conf)

Is it a problem with rules I entered in iptables or error on iptable? Please help as I'm strugling to fix this problem for three months.

Following are the rules I entered in iptables under nat
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A POSTROUTING –out-interface eth1 –j MASQUERADE
-A FORWARD –in-interface p17p1 –j ACCEPT
COMMIT
 
Old 05-21-2012, 02:30 AM   #4
GanIT
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Question

Anybody like to help on my issue. Or do I have to openup a new thread for this?
 
Old 05-22-2012, 03:50 AM   #5
WizadNoNext
Member
 
Registered: Nov 2009
Posts: 140

Rep: Reputation: 9
Give us those failing scripts.
I can give working configuration, as I have firewall/nat on my server.
You need dhcp, it would be good to have dns and proxy as well on server, as dns and proxy would speed up a bit your connection.
I have dynamic solution. Static solution is hard to manage.

Code:
#!/bin/sh

PATH="/sbin:/bin:/usr/sbin:/usr/bin"

IPtables_dumpfile='/etc/iptables/rules'
IP6tables_dumpfile='/etc/iptables/rules6'

# Include config file for iptables-persistent
. /etc/iptables/iptables.conf

case "$1" in
start)
    if [ -e /var/run/iptables ]; then
        echo "iptables is already started!"
        exit 1
    else
        touch /var/run/iptables
    fi

    modprobe tcp-$CONGESTION
    sysctl net.ipv4.tcp_congestion_control=$CONGESTION

    if [ $ENABLE_FORWARDING -ne 0 ]; then
        # Enable Routing
        echo 1 > /proc/sys/net/ipv4/ip_forward
        echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
    fi

    # Load Modules
    modprobe -a $MODULES

    # Load saved rules
    if [ -f $IPtables_dumpfile ]; then
        iptables-restore <$IPtables_dumpfile
    fi

    if [ -f $IP6tables_dumpfile ]; then
        ip6tables-restore <$IP6tables_dumpfile
    fi

    ;;

stop|force-stop)
    if [ ! -e /var/run/iptables ]; then
        echo "iptables is already stopped!"
        exit 1
    else
        rm /var/run/iptables
    fi

    if [ $SAVE_NEW_RULES -ne 0 ]; then
        # Backup old rules
        cp $IPtables_dumpfile $IPtables_dumpfile.bak
        cp $IP6tables_dumpfile $IP6tables_dumpfile.bak
        iptables -t nat -F upnp
        iptables -t filter -F upnp
        # Save new rules
        iptables-save >$IPtables_dumpfile
        ip6tables-save >$IP6tables_dumpfile
    fi

    # Restore Default Policies
    iptables -P INPUT ACCEPT
    iptables -P FORWARD ACCEPT
    iptables -P OUTPUT ACCEPT

    # Flush rules on default tables
    iptables -F
    iptables -t nat -F
    iptables -t mangle -F

    # Unload previously loaded modules
    modprobe -r $MODULES

    # Disable Routing if enabled
    if [ $ENABLE_FORWARDING -ne 0 ]; then
        # Disable Routing
        echo 0 > /proc/sys/net/ipv4/ip_forward
        echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
    fi

    ;;
restart|force-reload)
    $0 stop
    $0 start
    ;;
status)
    echo "Filter Rules:"
    echo "--------------"
    iptables -L -v
    echo ""
    echo "NAT Rules:"
    echo "-------------"
    iptables -t nat -L -v
    echo ""
    echo "Mangle Rules:"
    echo "----------------"
    iptables -t mangle -L -v
    ;;
*)
    echo "Usage: $0 {start|stop|force-stop|restart|force-reload|status}" >&2
    exit 1
    ;;
esac

exit 0
This script should be written to file /etc/init.d/iptables-persistent

Code:
# A basic config file for the /etc/init.d/iptable-persistent script
#

# Should new manually added rules from command line be saved on reboot? Assign to a value different that 0 if you want this enabled.
SAVE_NEW_RULES=0

# Modules to load:
MODULES="nf_nat_ftp nf_conntrack_ftp nf_nat_irc nf_conntrack_irc"

# Enable Routing?
ENABLE_FORWARDING=1

# Advanced Congestion Control
CONGESTION=yeah
This should be written to /etc/iptables/iptables.conf

With IPtables - I have quite extensive rules, which are prepared for a lot more complex setup, then yours (bridge, some services on server), so to use my rules I have to filter out parts which you do not need.
 
Old 05-23-2012, 02:31 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Since the original thread was 7 years old, and yours doesn't deal with content filtering, I moved your posts to it's own thread.
 
  


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
Need help configuring a firewall for a desktop Dralnu Linux - Security 6 09-02-2009 02:14 AM
Configuring firewall from terminal vatzcar Fedora 3 01-19-2008 01:08 PM
Configuring Firewall rschlichter Linux - Security 2 08-01-2007 11:05 AM
Configuring Firewall in Redhat 8.0 pancakefarm Linux - Newbie 2 11-03-2006 07:45 AM
configuring firewall westverg Linux - Networking 2 02-02-2005 03:20 AM

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

All times are GMT -5. The time now is 11:02 AM.

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