How can one best alleviate the pain of a fractured rib and how long should pain last?

Ouch! Rib fractures can be extremely painful. We used to prescribe chest binders - a wrap that goes around your chest - to help support the area, but no longer do so because it's been found that they don't help healing or pain much. You can get some pain relief by taking anti-inflammatory medications (like ibuprofen). Be sure to not take more than recommended. Ice applied to the area might help too.
Time is the best. It depends on the full extent of the fracture(s) but the pain should be almost completely gone by 2-3 months. Time is the best healer or most simple fractures, while surgery is indicated for complex chest wall injuries.