Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Rudi Starcevic <tech@wildcash.com>
To: netfilter@lists.netfilter.org
Subject: Re: Route packets from an interface to another
Date: Mon, 12 Sep 2005 06:36:02 -0700	[thread overview]
Message-ID: <43258442.4000009@wildcash.com> (raw)
In-Reply-To: <200509092345.40386.rob0@gmx.co.uk>

Hi,

I do something like this with the script below.

Please let me know if you see a better way to do this
than I am using below.

Thanks.
Kind regards,
Rudi.


#!/bin/sh

echo "Network Setup Start"

echo "Flushing NICs"
ip addr flush eth0
ip addr flush eth1

ip link set eth0 down
ip link set eth1 down

ip link set eth0 up
ip link set eth1 up

echo "Flushing NetFilter"
iptables -F
iptables -t nat -F

echo "Routing Tables:"
cat /etc/iproute2/rt_tables

echo "Setup NIC 0"
ip addr add 192.168.2.7/24 dev eth0 brd +

echo "Setup NIC 1"
ip addr add 192.168.3.7/24 dev eth1 brd +

ip addr list
ip route list

echo "Setup Default Route [ inet table ]"
ip route add default via 192.168.2.1 proto static table inet

echo "Setup LAN Route [ implan table ]"
ip route add 192.168.3/24 via 192.168.3.7 proto static table implan

ip route list

echo "Setup LAN ip rule"
ip rule add to 192.168.3/24 prio 16000 table implan

echo "Setup Internet ip rule"
ip rule add to 0/0 prio 17000 table inet

echo "Enable Kernel Forwarding"
echo "1" > /proc/sys/net/ipv4/ip_forward

echo "Enable NetFilter Forwarding"
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

echo "Flushing ip route cache"
ip route flush cache

#iptables -vL
#iptables -t nat -vL

exit 0




  parent reply	other threads:[~2005-09-12 13:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-09 19:51 Route packets from an interface to another Jonathan
2005-09-09 21:36 ` /dev/rob0
2005-09-09 21:18   ` Jonathan
2005-09-10  4:45     ` /dev/rob0
2005-09-10  7:54       ` /dev/rob0
2005-09-12  7:56         ` Jonathan
2005-09-13  1:45           ` /dev/rob0
2005-09-12 13:36       ` Rudi Starcevic [this message]
     [not found]         ` <65aa6af905091114314108597e@mail.gmail.com>
2005-09-11 21:32           ` Fwd: " Edmundo Carmona
2005-09-12 14:39             ` Rudi Starcevic
     [not found]               ` <65aa6af9050911145833fa12fd@mail.gmail.com>
2005-09-11 21:58                 ` Edmundo Carmona
2005-09-12 15:06                 ` Fwd: " Rudi Starcevic
     [not found]                   ` <65aa6af9050911151962bc24a2@mail.gmail.com>
2005-09-11 22:20                     ` Edmundo Carmona
2005-09-12 15:19                     ` Rudi Starcevic
2005-09-11 21:34         ` /dev/rob0
2005-09-12 14:47           ` Rudi Starcevic
2005-09-12 14:51           ` Rudi Starcevic
  -- strict thread matches above, loose matches on Subject: below --
2007-09-10 12:18 vinod K D
2007-09-10 15:23 ` Grant Taylor
2005-09-09 19:15 Jonathan
2005-09-09 20:22 ` Edmundo Carmona
2005-09-09 19:32   ` Jonathan
     [not found]     ` <65aa6af905090913353e0d0150@mail.gmail.com>
2005-09-09 20:35       ` Edmundo Carmona
     [not found]       ` <1224.83.227.26.235.1126295454.squirrel@webmail.2lug.se>
2005-09-09 21:03         ` Edmundo Carmona

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43258442.4000009@wildcash.com \
    --to=tech@wildcash.com \
    --cc=netfilter@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox