Skip to contentSkip to conversation

per user IP adresses

DISCUSSION John Guntenaar 4 participants 7 messages May 4, 2003 – May 6, 2003

lore
Share & tools
lore
#0 lore raw

Hello,

I have a linux machine with 4 IP addresses, I have a couple of friends on that machine and I don't allow them to use IRC, so I simply blocked the IRC ports, but I want to use IRC from the 4th IP without the other users being able to use it. I think I can reach that goal by using the owner match facility of iptables, though I can't find any good examples with google, is it correct and can somebody post an example?

Thanks in advantage,

John

#1 lore raw

Op zondag 4 mei 2003 20:38, schreef John Guntenaar:

Quoted 9 lines

Hello,

I have a linux machine with 4 IP addresses, I have a couple of friends on that machine and I don't allow them to use IRC, so I simply blocked the IRC ports, but I want to use IRC from the 4th IP without the other users being able to use it. I think I can reach that goal by using the owner match facility of iptables, though I can't find any good examples with google, is it correct and can somebody post an example?

Quoted 3 lines

Thanks in advantage,

John

this one is very easy , you can use the same rule , you used before , but now
you say : .......... -s ! $4th_ip -j DROP

Pascal

#2 lore raw

I think you didn't understand my question,

Ofcourse I can just set open that IP address, but I only want it to be open for my own user (so the other users CAN'T use the IP)

I think I need things like -m owner --owner-uid or something but I can't figure out a good rule, I get errors on everything I try :(

John

-----Oorspronkelijk bericht-----
Van: [email protected] [mailto:[email protected]] Namens SaVaGE
Verzonden: zondag 4 mei 2003 21:19
Aan: [email protected]
Onderwerp: Re: per user IP adresses

Op zondag 4 mei 2003 20:38, schreef John Guntenaar:

Quoted 7 lines

Hello,

I have a linux machine with 4 IP addresses, I have a couple of friends on that machine and I don't allow them to use IRC, so I simply blocked the IRC ports, but I want to use IRC from the 4th IP without the other users being able to use it. I think I can reach that goal by using the owner match facility of iptables, though I can't find any good

examples

Quoted 5 lines

with google, is it correct and can somebody post an example?

Thanks in advantage,

John

this one is very easy , you can use the same rule , you used before , but now
you say : .......... -s ! $4th_ip -j DROP

Pascal

#3 lore raw

Hi John,

Quoted 7 lines

I think you didn't understand my question,

Ofcourse I can just set open that IP address, but I only want it to be open for my own user (so the other users CAN'T use the IP)

I think I need things like -m owner --owner-uid or something but I can't figure out a good rule, I get errors on everything I try :(

I don't think REJECT works in the OUTPUT chain, try DROP:

	iptables -A OUTPUT -p tcp --dport 6667 -m owner --owner-uid john
		-s 1.2.3.4 -j ACCEPT
	iptables -A OUTPUT -p tcp --dport 6667 -j DROP

where "john" is the user ID who is allowed to use IRC on IP address 1.2.3.4 only.

Cheers, Chris.

Signature · 4 lines
   ___ __     _
 / __// / ,__(_)_  | Chris Wilson -- UNIX Firewall Lead Developer |
/ (_ / ,\/ _/ /_ \ | NetServers.co.uk http://www.netservers.co.uk |
\ _//_/_/_//_/___/ | 21 Signet Court, Cambridge, UK. 01223 576516 |
#4 lore raw
In reply to John Guntenaar

On Sun, 2003-05-04 at 14:38, John Guntenaar wrote:

I missed the start of this thread, so I backed up and reread it. :^)

Quoted 9 lines

Hello,

I have a linux machine with 4 IP addresses, I have a couple of friends on that machine and I don't allow them to use IRC, so I simply blocked the IRC ports, but I want to use IRC from the 4th IP without the other users being able to use it. I think I can reach that goal by using the owner match facility of iptables, though I can't find any good examples with google, is it correct and can somebody post an example?

Quoted 3 lines

Thanks in advantage,

John

You need something constructed like this:

iptables -A OUTPUT -p tcp --dport 194 -m owner ! --uid-owner \ 1235 -j REJECT --reject-with tcp-reset

or:

iptables -A OUTPUT -p tcp --dport 194 -m owner --uid-owner \ 1235 -j ACCEPT

I use a similar rule to prevent any user except root from being able to connect to my LAN computers from my server. You can add an additional match to either rule to match outgoing interface or sourceIP if needed. Is it really necessary to restrict IRC to only that single IP?

j

#5 lore raw

Hi Joel,

Your LAN construction is exactly what I want, but I want that 1 of the 4 IPs can only bind to the 4th IP, but when I try any of your rules I get errors :(

(And yes, I changed the real IP in 123.123.123.123 in here ;-))

jimbo:/var/www# iptables -A OUTPUT -p tcp -s 123.123.123.123/32 -m owner
! --uid-owner 1000 -j REJECT --reject-with tcp-reset
iptables: Invalid argument
jimbo:/var/www# iptables -A OUTPUT -p tcp --dport 6667 -m owner !
--uid-owner 1000 -j REJECT --reject-with tcp-reset
iptables: Invalid argument
jimbo:/var/www# iptables -A OUTPUT -p tcp --dport 194 -m owner !
--uid-owner \ 1235 -j REJECT --reject-with tcp-reset
iptables: Invalid argument

So what could be wrong?

Thanks,

John

-----Oorspronkelijk bericht-----
Van: [email protected] [mailto:[email protected]] Namens Joel Newkirk
Verzonden: dinsdag 6 mei 2003 1:46
Aan: [email protected]
CC: [email protected]
Onderwerp: Re: per user IP adresses

On Sun, 2003-05-04 at 14:38, John Guntenaar wrote:

I missed the start of this thread, so I backed up and reread it. :^)

Quoted 7 lines

Hello,

I have a linux machine with 4 IP addresses, I have a couple of friends on that machine and I don't allow them to use IRC, so I simply blocked the IRC ports, but I want to use IRC from the 4th IP without the other users being able to use it. I think I can reach that goal by using the owner match facility of iptables, though I can't find any good

examples

Quoted 5 lines

with google, is it correct and can somebody post an example?

Thanks in advantage,

John

You need something constructed like this:

iptables -A OUTPUT -p tcp --dport 194 -m owner ! --uid-owner \ 1235 -j REJECT --reject-with tcp-reset

or:

iptables -A OUTPUT -p tcp --dport 194 -m owner --uid-owner \ 1235 -j ACCEPT

I use a similar rule to prevent any user except root from being able to connect to my LAN computers from my server. You can add an additional match to either rule to match outgoing interface or sourceIP if needed. Is it really necessary to restrict IRC to only that single IP?

j

#6 lore raw
Quoted 16 lines · John Guntenaar

Hi Joel,

Your LAN construction is exactly what I want, but I want that 1 of the 4 IPs can only bind to the 4th IP, but when I try any of your rules I get errors :(

(And yes, I changed the real IP in 123.123.123.123 in here ;-))

jimbo:/var/www# iptables -A OUTPUT -p tcp -s 123.123.123.123/32 -m owner
! --uid-owner 1000 -j REJECT --reject-with tcp-reset
iptables: Invalid argument
jimbo:/var/www# iptables -A OUTPUT -p tcp --dport 6667 -m owner !
--uid-owner 1000 -j REJECT --reject-with tcp-reset
iptables: Invalid argument
Quoted 5 lines
jimbo:/var/www# iptables -A OUTPUT -p tcp --dport 194 -m owner !
--uid-owner \ 1235 -j REJECT --reject-with tcp-reset
iptables: Invalid argument

So what could be wrong?

My bet would be you don't have/haven't loaded ipt_owner... Try "insmod ipt_owner".

j

Quoted 3 lines

Thanks,

John