LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to allow one ip address from iptables (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-allow-one-ip-address-from-iptables-934931/)

parkarnoor 03-17-2012 07:38 AM

how to allow one ip address from iptables
 
Hi,

i have a linux server in the network. which has seperate VLAN.

and myself and other users in the company have another vlan.

i can connect to linux server.

company nework is 172.25.10.x and server network is 172.25.15.x

now i want only myself can connect to linux server and not all other users.

i am trying following command

#iptables -I INPUT -p tcp -s 172.25.10.x/24 -i eth0 -m state --state NEW,ESTABLISHED --dport 22 -j ACCEPT
(where 172.25.10.x is actual my machine ip address)
but it is not restricting all other users from accessing the linux server.

how can i allow only my machine to access the linux server?

bigrigdriver 03-17-2012 09:38 AM

Here is an example iptables config . Pay attentention to the REJECT, DUMP, and DROP portions of the config.

Then read this Howto , Section 6.2.1 on configuring REJECT lists in iptables.

Hope you get it sorted out. Good luck.

McPhart 03-17-2012 10:55 AM

Uncertain, but shouldn't you use /32 instead of /24 ??
Since it's only 1 address you want to grant access, /32 seems more plausible to me.

parkarnoor 03-18-2012 02:13 AM

how to allow one ip address to access linux server using ssh
 
Hi,

this is in reply to previous one

i added following statement is iptables:

#iptables -A INPUT -p tcp -i br0 -s 172.25.10.x -m state --state NEW,ESTABLISHED --dport 22 -j ACCEPT

but this will allow my ip adress to access linux server.

also all other colleagues can also access. now how will i prevent others users to access the linux server.

i am also working on links given be below (bigrigdriver).

Regards

fukawi1 03-18-2012 03:15 AM

YOu need to replace the "x" in the IP, with your actual ip address for a start.
Next, that rule, is only going to be of any help, if you have a default policy, or catch all rule to drop everything other than what matches your rules.

If you are going to include the input interface match, you need to figure out what interface you are using. In your examples, you use eth0 and br0.


All times are GMT -5. The time now is 07:21 AM.