As general rule a physical assessment is necessary as it can be the result of compensation for other problems (flat feet or hyperlordosis for example, just to name a couple). The treatment involves stretching the Iliotibial Band itself (eventual thickening cant be reduced that way but the ITB is attached to muscles so stretching that has a direct effect on those), taking care of the muscles and trigger points that refer to the area and a series of stretching and strengthening exercises, but they would do nothing if the causes aren't addressed properly.
Recent studies have changed a bit the traditional belief that ITB syndrome is due to friction. They have shown that it might be associated with the compression of an highly vascularized and innervated fat pad between knee and ITB or a damage to the Periosteum (the outer layer of tissue covering the bone) at the ITB attachment.
This doesn't mean a complete treatment change but it can point the finger to other structures as the real source of pain. Knowing that helps developing treatment programs that can be much more effective.
Posture, gait, footwear etc need to be assessed, a full health history taken to rule out other conditions with similar symptoms and pinpoint the causes of the problem. General stretches are never a waste but they might do very little to help solving your problem if they don't address the real cause, which isnt the same for everyone, so in here you will get just a very general answer.
As a suggestion yoga could be considered as a way to increase flexibility, the benefits of it are several and many find it a perfect complement to their main activity.
The easiest ITB stretch is the lean with the help of a wall:
(the one you are stretching is the one facing the wall btw). Stretch both sides. Many pictures in internet show a lean that is way too exaggerated, that ends focusing on other structures rather than the ITB and the position is not stable enough to be a safe remedial exercise. Stretches are often improperly done missing their target structure, they need to be shown, then the patient would perform them and be corrected so that they can be useful, the picture above is an indication but you will have a better outcome working with a proper medical practitioner. This stretch is rarely prescribed alone, stretching all the other muscles of the leg/hips/back (and strengthening some) is needed, but these will have to be specific for your situation.
Manage inflammation, through cold rinses or ice after every activity while causes are getting addressed properly (that is just for the inflammation, it doesn't fix your ITB problem). Avoid repeated use of anti inflammatory drugs as they just mask the symptoms and lead to a chronic problem.
IF your work involves sitting a lot, that aggravates the situation, try to stretch regularly during the day.
Some suggest rolling the ITB (using various kind of rollers or even a tennis ball), that's hit and miss, the way a therapist would actively work on the ITB is a bit different and it needs to be done at an angle, with whats shown online (pressure square on the ITB) you are benefiting more the surrounding muscles, which can alleviate a bit the pain, but does little for the ITB itself.
Following OP request I searched for a video showing the right way to use the roller, this one shows the main part of the whole exercise (it doesn't show rolling across the ITB). https://www.youtube.com/watch?v=sOLBRhrF4Kc
The study he is talking about is Fairclough, et al. 2006
Be careful when rolling, some rollers are aggressive, and a ball is even more aggressive (the smaller and harder the worse). Its best to start learning the exercise with something gentle and then progress to something more aggressive. Some people that did things wrong (too fast, too slow, for too long, too aggressive, wrong roller, wrong position...) ended with some bad bruising.
Your goal should be not only managing the problem but resolving it so that it doesn't become chronic. A chronic problem not only keeps recurring and aggravating but also starts to involve neighbouring structures.
Some things you can do by yourself but you will obtain real results much faster if you see a therapist (a GOOD one).
Its also beneficial to use trekking poles, it helps to reduce the impact force going through the knee, even more if you tend to "stomp" on your heel while hiking.
There are "ITB straps", you can quickly find them online, that helped some people with ITBS, the problem with these is that they can quickly become a crutch and they don't cure anything.
Remember that the longer the problem presents itself the longer it takes to recover, so plain symptoms management can be counterproductive.