Networking Forums

Networking Forums > Computer Networking > Linux Networking > iptables - opening an inbound port but allowing access to all machines outbound

Reply
Thread Tools Display Modes

iptables - opening an inbound port but allowing access to all machines outbound

 
 
Allan M. Bruce
Guest
Posts: n/a

 
      06-09-2006, 05:21 PM
I want to open up a port on my iptables router to allow a connection from
WAN to a specific machine on my LAN (called A). I also want this port to be
accessible from all machines in the LAN to WAN. At the moment my script
allows incoming and outgoing connections on the port to or from A. How can
I modify this to allow outgoing connections on this port from all machines
in the LAN? My script is:

iptables -t nat -I PREROUTING -p tcp -s ! 192.168.0.1 --dport 12345 -j
DNAT --to 192.168.0.1
iptables -I FORWARD -p tcp -d 192.168.0.1 --dport 12345 -j ACCEPT

Thanks
Allan


 
Reply With Quote
 
 
 
 
Jarek Poplawski
Guest
Posts: n/a

 
      06-12-2006, 08:18 AM
Allan M. Bruce wrote:
> I want to open up a port on my iptables router to allow a connection from
> WAN to a specific machine on my LAN (called A). I also want this port to be
> accessible from all machines in the LAN to WAN. At the moment my script
> allows incoming and outgoing connections on the port to or from A. How can
> I modify this to allow outgoing connections on this port from all machines
> in the LAN? My script is:
>
> iptables -t nat -I PREROUTING -p tcp -s ! 192.168.0.1 --dport 12345 -j
> DNAT --to 192.168.0.1
> iptables -I FORWARD -p tcp -d 192.168.0.1 --dport 12345 -j ACCEPT


To assure connections from LAN are returned by the router:

iptables -t nat -A POSTROUTING -p tcp -d 192.168.0.1 --dport
12345 -j SNAT --to 192.168.0.XXX # your router's IP in the LAN

Jarek P.
 
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables: allowing only listed hosts to connect to a port Mark Hobley Linux Networking 15 07-05-2008 10:08 AM
using iptables to block OUTBOUND port 25? deja3-user@bitrealm.com Linux Networking 6 02-18-2008 05:58 AM
Best way to intercept inbound and outbound TCP packets will_u_tellmemore Linux Networking 5 12-12-2006 02:59 AM
iptables; allowing external web access to 192.168.0.1; how? =?ISO-8859-1?Q?Ga=E9tan_Martineau?= Linux Networking 4 01-09-2004 11:51 PM
Can Linksys broadband/wifi routers run inbound/outbound access lists? Peter Broadband 7 12-09-2003 02:50 PM



1 2 3 4 5 6 7 8 9 10 11