Assigning IP for Arduino

I need to assign a static IP for my arduino mega (ethernet shield plugged). I am using the example sketch given in ethernet>DhcpAddressPrinter. But with this example when I connect ethernet cable directly to my computer (sharing my internet’s connection) IP address changes everytime when i restart arduino or serial monitor. And with a router also IP changes less frequently. Can anybody help me how to assign a static IP address for my arduino.

DhcpAddressPrinter.ino (2.47 KB)

look at other examples of the library