A client requested that the MTU limit should be 1492.
Is there a way to do it in the source code (program in C)?
Is there any other way to do it in general? (ifconfig?)
Why does somebody needs to modify MTU to a certain limit? What is the benefit? And the most important: By changing the MTU is there any risk to break the code?
Programmaticaly way using C:
int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
struct ifreq ifr;
strcpy(ifr.ifr_name, "eth0");
if(!ioctl(sock, SIOCGIFMTU, &ifr)) {
ifr.ifr_mtu // Contains current mtu value
}
ifr.ifr_mtu = ... // Change value if it needed
if(!ioctl(sock, SIOCSIFMTU, &ifr)) {
// Mtu changed successfully
}
It works at least on Ubuntu, see man netdevice
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With