OpenVZ Forum - RDF feed
type: channel
items: *SOLVED* How to disable raw sockets
items: Re: How to disable raw sockets

*SOLVED* How to disable raw sockets
type: item
description: Hi, Does anyone know how to block raw sockets inside a VPS? I'm asking this because I would like to avoid a ddos attack to come from a VPS of mine. Is it possible? Or is there any other way to do it besides disabling raw sockets? Regards, Eugenio Pacheco
creator: eugeniopacheco
date: 2006-06-10T10:59:04-00:00

Re: How to disable raw sockets
type: item
description: You can set paramters numothersock, numtcpsock, othersockbuf, tcpsndbuf, tcprcvbuf of the VPS to values, that are only enough to work "legaly" with VPS. HTH.
creator: Vasily Tarasov
date: 2006-06-11T10:22:37-00:00

Re: How to disable raw sockets
type: item
description: if you are using venet network device for VPS networking (not veth), then DDoS attacks from inside VPS are impossible. This is why we recommend to use venet device and do care about security.
creator: dev
date: 2006-06-11T11:25:35-00:00

Re: How to disable raw sockets
type: item
description: Hi, I believe I am using venet, not veth. Below I have used ifconfig to show the interfaces. [root@server ~]# ifconfig eth0 Link encap:Ethernet HWaddr x:x:x:x:x:x inet addr:x.x.x.x Bcast:x.x.x.x Mask:255.255.255.252 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:23591161 errors:0 dropped:0 overruns:0 frame:0 TX packets:23587373 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1651199768 (1.5 GiB) TX bytes:1656101486 (1.5 GiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:37 errors:0 dropped:0 overruns:0 frame:0 TX packets:37 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:32613 (31.8 KiB) TX bytes:32613 (31.8 KiB) venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 RX packets:33669 errors:0 dropped:0 overruns:0 frame:0 TX packets:33412 errors:0 dropped:6 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3803369 (3.6 MiB) TX bytes:3193558 (3.0 MiB) The way it is, people are still able to ddos from the vps. Also, even though I have capped their connection by using the following script: #!/bin/bash DEV=eth0 tc qdisc del dev $DEV root tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth 10mbit tc class add dev $DEV parent 1: classid 1:1 cbq rate 512kbit allot 1500 prio 5 bounded isolated tc filter add dev $DEV parent 1: protocol ip prio 16 u32 match ip src x.x.x.x flowid 1:1 tc qdisc add dev $DEV parent 1:1 sfq perturb 10 DEV2=venet0 tc qdisc del dev $DEV2 root tc qdisc add dev $DEV2 root handle 1: cbq avpkt 1000 bandwidth 10mbit tc class add dev $DEV2 parent 1: classid 1:1 cbq rate 512kbit allot 1500 prio 5 bounded isolated tc filter add dev $DEV2 parent 1: protocol ip prio 16 u32 match ip dst x.x.x.x flowid 1:1 tc qdisc add dev $DEV2 parent 1:1 sfq perturb 10 They are still able to use more than 512kbps (I don't know why). I know this …
creator: eugeniopacheco
date: 2006-06-11T21:59:38-00:00

Re: How to disable raw sockets
type: item
description: Finally I've got the reason... Hunk 1: Quote: DEV=eth0 tc qdisc del dev $DEV root tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth 10mbit tc class add dev $DEV parent 1: classid 1:1 cbq rate 512kbit allot 1500 prio 5 bounded isolated tc filter add dev $DEV parent 1: protocol ip prio 16 u32 match ip src x.x.x.x flowid 1:1 tc qdisc add dev $DEV parent 1:1 sfq perturb 10 Hunk 2: Quote: DEV2=venet0 tc qdisc del dev $DEV2 root tc qdisc add dev $DEV2 root handle 1: cbq avpkt 1000 bandwidth 10mbit tc class add dev $DEV2 parent 1: classid 1:1 cbq rate 512kbit allot 1500 prio 5 bounded isolated tc filter add dev $DEV2 parent 1: protocol ip prio 16 u32 match ip dst x.x.x.x flowid 1:1 tc qdisc add dev $DEV2 parent 1:1 sfq perturb 10 Note, that both hunks work at egress of VE0! Here is why wget is limited by traffic and ddos-atack tools aren't: wget downloads from some node to VPS, for VE0 it's egress, so hunk 1 or hunk 2 work. But ddos-atack tools emit(!) traffic. Thus for VE0 it's ingress traffic. Consequently hunk2 doesn't catch it! If you want to solve your problem you can use this hunk 3 in addition to hunk2, hunk1: Quote: DEV=venet0 tc filter add dev $DEV parent 1: protocol ip prio 20 u32 match u32 1 0x0000 police rate 2kbit buffer 10k drop flowid :1
creator: Vasily Tarasov
date: 2006-06-15T13:28:29-00:00

Re: How to disable raw sockets
type: item
description: Hi, Thanks for your help, but it still didn't work. In 30 seconds 2500MB limiting the connection of the ip on the vps to 512kbps and adding your line. I also tried adding it to the eth0 interface and it didn't work. I tried with both interfaces and it still didn't work. Also, I noticed you mentioned that the upload is not being limited, but it is. If someone try to download something FROM the VPS, he will be limited, if he tries to upload something TO the VPS, he will be limited, only the ddos is not being limited... And that I have no clue as to why. Regards, Eugenio Pacheco
creator: eugeniopacheco
date: 2006-06-15T13:49:13-00:00

Re: How to disable raw sockets
type: item
description: Quote: Also, I noticed you mentioned that the upload is not being limited, but it is. If someone try to download something FROM the VPS, he will be limited, if he tries to upload something TO the VPS, he will be limited, If somebody tries to download smth from VPS (it is uploading for VPS), IP packet goes something like that: Node, forward that <----------- Hardware <--------------- VPS requests ^ Node With VPS | | | hunk 2 works So you are right. In my previous post I meant that if upload goes to HN with VPS, then there is no forwarding - so no limiting and hunk 3 helps in such situation. Anyway this isn't your case... And it's really strange why ddos tools aren't limited!..
creator: Vasily Tarasov
date: 2006-06-15T14:19:11-00:00

Re: How to disable raw sockets
type: item
description: Hi, I completely agree that it is strange ddos is not limited. Everything else is limited, only ddos is not. it is weird. Thanks for your help though. Regards, Eugenio Pacheco
creator: eugeniopacheco
date: 2006-06-15T15:18:25-00:00

Re: How to disable raw sockets
type: item
description: The reason is that ddos-atack utils generate a lot of packets of small size. So there are a LOT of PACKETS, but there only FEW MEGABYTES. So tc rules don't catch them: there is no traffic (Mb/sec) exceeding.
creator: Vasily Tarasov
date: 2006-06-16T12:04:58-00:00

Re: How to disable raw sockets
type: item
description: If you want to limit packages per second rate from VE you can use the following command on HN: # iptables -I FORWARD 1 -o eth0 -s x.x.x.x -m limit --limit 200/sec -j ACCEPT # iptables -I FORWARD 2 -o eth0 -s x.x.x.x -j DROP x.x.x.x is the IP address of VE, you want to limit. Good luck!
creator: Vasily Tarasov
date: 2006-06-16T13:04:23-00:00