LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-16-2007, 02:09 AM   #1
herbo
LQ Newbie
 
Registered: Dec 2007
Location: Australia
Posts: 7

Rep: Reputation: 0
iptables problem


Giday,

I am trying to come to grips with iptables.
Each time I change my default policy from accept to drop, I am then are unable to ssh back into my server, even though I have tried a number of different commands.

The server I am using is a virtual one, a vmware-server. I am using PuTTy from a windows machine to ssh in.
I am running Debian & have only the one network card.
The sever ip is 192.168.39.201, my ip is 192.168.1.101

This is the kind of script I am running. I have also left in some of the commented out sections I have tried.

#! /bin/bash

# Clean old firewall
iptables -F
iptables -X

# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# Allow ssh from 192.168.1.101
iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT

# iptables -A INPUT -p tcp -s 192.168.1.101 -d 192.168.39.201 --sport 22 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A OUTPUT -s 192.168.39.201 -d 192.168.1.101 -p tcp --sport 22 --dport 22 -m state --state ESTABLISHED -j ACCEPT

# unlimited access to LAN
iptables -A INPUT -s 192.168.1.0/24 -j ACCEPT
iptables -A OUTPUT -s 192.168.1.0/24 -j ACCEPT

There must be something else I should be doing?
 
Old 12-16-2007, 04:05 AM   #2
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
I think your troubles must have to do with the fact your server is virtual. W/o virtualization, the last two commands would allow unlimited access to everything on the subnet. I can't help you with virtualization, but I believe there are some articles on the Internet about how to use iptables with a virtual server.
 
Old 12-17-2007, 02:29 AM   #3
herbo
LQ Newbie
 
Registered: Dec 2007
Location: Australia
Posts: 7

Original Poster
Rep: Reputation: 0
If it is something to do with the actual virtualization, I had a look for anything that could help, but what I found I think is a bit beyond the scope of what I can do at the moment.

Any help to point me in the right direction would be greatly appreciated.
 
Old 12-17-2007, 02:56 AM   #4
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
I while back I was trying to help somebody else out with iptables on a virtual server and quickly got in over my head. I have almost no experience with virtualization, and certainly nothing like this. Maybe somebody else can point you in the right direction.

Good luck.
 
Old 12-17-2007, 03:06 AM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
You're running different subnets - 192.168.39. and 192.168.1.

I don't see why it works with default policy of accept either (or is your windows machine on 192.168.39.).

Why the different subnets

btw - I don't think virtualisation is the issue
 
Old 12-17-2007, 03:58 AM   #6
herbo
LQ Newbie
 
Registered: Dec 2007
Location: Australia
Posts: 7

Original Poster
Rep: Reputation: 0
After trying it on the same subnet, & then playing around with it I found (short version)


#! /bin/bash

# Clean old firewall
iptables -F
iptables -X

# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# unlimited access to LAN
iptables -A INPUT -s 192.168.39.0/24 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -s 192.168.39.0/24 -m state --state ESTABLISHED -j ACCEPT

iptables -A INPUT -s 192.168.1.10 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -s 192.168.1.10 -m state --state ESTABLISHED -j ACCEPT

The (virtual) host computer's subnet(not ip) has to given access, then the remote computer.

I haven't tried ssh yet, but will let you know.

Thanx
 
Old 12-17-2007, 04:06 AM   #7
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
If you haven't gotten it working, describe your network setup a bit more
 
Old 12-17-2007, 06:16 AM   #8
herbo
LQ Newbie
 
Registered: Dec 2007
Location: Australia
Posts: 7

Original Poster
Rep: Reputation: 0
I've think I have it working, but had make the virtual computer host's network have unlimited access. Not sure why, but at least it works for now & I'll see what happens next.

# Allow ssh from 192.168.1.10
iptables -A INPUT -s 192.168.1.10 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -s 192.168.1.10 -p tcp --dport 22 -m state --state ESTABLISHED -j ACCEPT

# unlimited access to LAN
iptables -A INPUT -s 192.168.39.0/24 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -s 192.168.39.0/24 -m state --state ESTABLISHED -j ACCEPT
 
Old 12-17-2007, 09:03 AM   #9
wanghao
Member
 
Registered: Mar 2007
Distribution: centos
Posts: 126

Rep: Reputation: 15
First so much i see you vmware's nic adapter was set to nat not the bridge,and it's clear it the nat are chose you just can connect you win from you server at reverse .so change the nic config on the vmware.
All you best.
 
Old 12-18-2007, 11:10 PM   #10
herbo
LQ Newbie
 
Registered: Dec 2007
Location: Australia
Posts: 7

Original Poster
Rep: Reputation: 0
I have the nic adapter for the vmware server set on bridged.
 
  


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
iptables problem.?????????? raklo Linux - Software 4 07-29-2007 11:29 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
iptables problem Israfel2000 Linux - Security 10 06-09-2005 10:47 PM
iptables problem? poulaum Linux - Networking 12 02-27-2003 03:57 PM
Problem with IPTABLES jfall Linux - Networking 3 11-04-2002 03:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:08 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