> ## Content Index
> Fetch the complete content index at: https://ostreff.info/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to set DSCP/COS in FreeBSD and use it in Telco environment
- URL: https://ostreff.info/3gpp2ipv4/
- Published: 2021-01-28T09:30:00.000Z
- Updated: 2021-01-31T10:39:25.000Z
- Author: Jordan Ostreff
- Tags: Telco, FreeBSD, QoS

Preserving [QoS](https://en.wikipedia.org/wiki/Quality%5Fof%5Fservice?ref=ostreff.info) parameters in Telco environment, where part of the equipment is following [3gpp](https://www.3gpp.org/?ref=ostreff.info) rules and other part is followin [ietf](https://www.ietf.org/?ref=ostreff.info) rfcs rules is really chalenging. And of course there is allways need to add some additional freeware equipment ...

![](https://ostreff.info/content/images/2021/01/image-4.png)

Reference (recomendation) table

In above table is used information from [Ericsson](https://www.ericsson.com/?ref=ostreff.info) excelent documentation/recomendations and information published already [here](https://ostreff.info/ip-qos-values/). 

Imagine the scenario that you must mark ( with [dscp](https://en.wikipedia.org/wiki/Differentiated%5Fservices?ref=ostreff.info) cs6, [cos](https://en.wikipedia.org/wiki/IEEE%5FP802.1p?ref=ostreff.info) 6 ) all DNS related conversations of your machine. This means you should mark all incomming packets via tcp and udp on port 53 and also all outgoing tcp and udp packets to port 53.

Last days I've made some research what can be done with [FreeBSD](https://www.freebsd.org/?ref=ostreff.info). I have found that it's possible to do such marking on the OS level, if programmers doesn't made such marking to be possible via specific configuration, in his application configuration. 

It looks that COS and DSCP values can be set in two different places. 

COS value is part of Layer 2 interface configuraton on vlan level in **[vlanpcp](https://www.freebsd.org/cgi/man.cgi?ifconfig%288%29&ref=ostreff.info)** parameter as it's visible bellow it is set to COS=6:

vlanXXXX: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500  
options=403<RXCSUM,TXCSUM,LRO>  
ether 4a:4f:52:44:41:4e  
inet 10.0.0.1 netmask 0xfffffffe broadcast 255.255.255.255  
groups: vlan  
vlan: XXXX **vlanpcp: 6** parent interface: lagg0  
fib: 5  
media: Ethernet autoselect  
status: active  
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO\_LINKLOCAL>

![](https://ostreff.info/content/images/2021/01/image-1.png)

Wireshark check of 802.1q

So the only solution I have found is to design your DNS servers to use dedicated interfaces on your server.

DSCP value is more complicated to be set. It looks that it can be modified/set in the firewall. Using [IPFW](https://docs.freebsd.org/en/books/handbook/?ref=ostreff.info) the job can be done using following rules inside your ruleset:

```
    ${fwcmd} add setdscp cs6 { tcp or udp } from any 53 to any
    ${fwcmd} add setdscp cs6 { tcp or udp } from any to any 53
```

![](https://ostreff.info/content/images/2021/01/dscp-qos.jpg)

Wireshark check of DSCP in IPv4 headers

It looks that it's not possible same thing to be done via my favorite firewall [PF](https://docs.freebsd.org/en/books/handbook/?ref=ostreff.info). 

For [linux](https://linux.org/?ref=ostreff.info) implementations - for dscp look in [iptables examples](https://mediaonfire.com/blog/2013%5F11%5F01%5Fdscp%5Ftagging%5Fwith%5Fiptables.html?ref=ostreff.info) already published in Internet, for cos research begin from [this article](https://community.mellanox.com/s/article/howto-set-egress-priority-vlan-on-linux?ref=ostreff.info).