Unverified Commit 932b3516 by Matjaz Gregoric Committed by Tobias Macey

Find name of default network interface to set MTU.

On Ubuntu 16.04, the default networks interface is not always called
eth0, depending on the hardware. The name of the default network
interface on some VM types on AWS is ens3, for example.

Determine the interface name using ip route command instead of
hardcoding to eth0.

Also, /etc/network/interfaces.d/<interface-name>.cfg files no longer
exist in Ubuntu 16.04. Use a script in /etc/network/if-up.d to
adjust the MTU value at startup instead.
parent 2fa76a2f
...@@ -30,24 +30,23 @@ ...@@ -30,24 +30,23 @@
tags: tags:
- deploy - deploy
- name: Set the MTU to 1500 temporarily - name: Get name of default network interface
shell: /sbin/ifconfig eth0 mtu 1500 up shell: "ip route show 0/0 | awk '{print $NF}'"
register: get_interface_name
when: ansible_distribution in common_debian_variants when: ansible_distribution in common_debian_variants
- name: Check for eth0.cfg - name: Set the MTU to 1500 temporarily
stat: shell: "/sbin/ifconfig {{ get_interface_name.stdout }} mtu 1500 up"
path: /etc/network/interfaces.d/eth0.cfg
register: eth0_cfg
when: ansible_distribution in common_debian_variants when: ansible_distribution in common_debian_variants
- name: Set the MTU to 1500 inside eth0.cfg file - name: Set the MTU to 1500 permanently
lineinfile: template:
dest: /etc/network/interfaces.d/eth0.cfg dest: /etc/network/if-up.d/mtu
regexp: "^post-up /sbin/ifconfig eth0 mtu 1500" src: mtu.j2
line: "post-up /sbin/ifconfig eth0 mtu 1500" mode: 0755
insertafter: "^iface" owner: root
when: ansible_distribution in common_debian_variants and eth0_cfg.stat.exists group: root
when: ansible_distribution in common_debian_variants
# #
# End dealing with Jumbo frames issue in mixed MTU deployements in AWS # End dealing with Jumbo frames issue in mixed MTU deployements in AWS
# #
......
#!/bin/sh
ifconfig {{ get_interface_name.stdout }} mtu 1500
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment