change MTU of a network interface (VirtualBox)

844 views
Skip to first unread message

marco.a...@gmail.com

unread,
Nov 20, 2015, 10:22:57 AM11/20/15
to Vagrant
Hello,

how can I change MTU of a network interface with a Vagrantfile option ?
What I have is:

[root@dev-local ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:a9:2d:51 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 85575sec preferred_lft 85575sec
    inet6 fe80::a00:27ff:fea9:2d51/64 scope link
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:8b:7e:e7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.10/24 brd 192.168.1.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe8b:7ee7/64 scope link
       valid_lft forever preferred_lft forever
[root@dev-local ~]#

I would like to change MTU of enp0s3 to 1300.
The Vagrantfile is this:

Vagrant.configure(2) do |config|
  config.vm.provider "virtualbox" do |v|
    v.memory = 512
    v.cpus = 1
    v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
  end
  config.vm.hostname = "dev-local"
  config.ssh.username = 'root'
  config.ssh.password = 'root'
  config.ssh.insert_key = 'true'
  config.ssh.pty = false
  config.vm.boot_timeout = 600
  config.vm.network "private_network", ip: "192.168.10.10"
  if ENV['ROOT_TFS_MAPPINGS']
    config.vm.synced_folder ENV['ROOT_TFS_MAPPINGS'], "/src"
  end
  if Vagrant.has_plugin?("vagrant-vbguest")
    config.vbguest.auto_update = true
    config.vbguest.no_remote = true
  end
end

If I change manually /etc/sysconfig/network-scripts/ifcfg-enp0s3, the interface has no ip address mounted after a "vagrant reload". It seems that vagrant is in some way aware that the file was manually changed and this causes a failure...

Thanks

Alvaro Miranda Aguilera

unread,
Nov 21, 2015, 8:08:29 AM11/21/15
to vagra...@googlegroups.com
Hello!

If you know the file you want to use, or the command you need to run, will be quicker if you tell Vagrant to create the interface, but not configure.

  config.vm.network "private_network", ip: "192.168.50.4",
    auto_config: false


Then, you can use a shell provisioner to copy a file from /vagrant/ to the location you require and start the interface manually.

Or you can use a shell provisioner to run the command you need:

ifconfig …. etc

If you got this way, you can tell Vagrant to always run that script. (By default a provisioning script will run on first time)
 config.vm.provision "shell", inline: "echo hello",
    run: "always"


Thanks

Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c40f6ac2-dd80-4628-8c3e-74e19b9fa862%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages