Is it possible to use Ifconfig to switch an interface to DHCP and if not, what is the best way?
I have just set up a new Ubuntu server and I am going to be doing a lot of networking tests.
During setup, I simply skipped the network step.
I now need to switch between DHCP and an address quite often.
I know I can easily give a port an address via ifconfig eth0 x.x.x.x netmask x.x.x.x, but, is there an alternative that can be used in order to set a port to use DHCP?
If this isn't possible, I am guessing I can default in /etc/network/interfaces to dhcp and then just use up/down or restart networking in order to apply... but, I would much rather use ifconfig.
1 Answer
Change from static to dynamic
ifconfig eth0 0.0.0.0 0.0.0.0 && dhclient Change back
killall dhclient && ifconfig eth0 10.0.1.22 netmask 255.255.255.0 8