Change IP Address

Change IP Address

This instruction helps to you change ip address of your server.

Warning!

It is prefered to do that via console, if you will do that via remote connection you can lost it.

Show current ip address

I prefer to use ip address command to do that.

tacgui@tacacsgui:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    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: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:95:71:fd brd ff:ff:ff:ff:ff:ff
    inet 10.6.20.11/24 brd 10.6.20.255 scope global ens32
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe95:71fd/64 scope link
       valid_lft forever preferred_lft forever

Change Network Settings

You can use different editors, but nano is more user-friendly. Use command sudo nano /etc/network/interfaces to edit main network file.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens32 # name of interface
iface ens32 inet static
        address 10.6.20.11 # ip address of your interface
        network 10.6.20.0 # you can change that entry or delete it
        broadcast 10.6.20.255 # you can change that entry or delete it
        gateway 10.6.20.1 # Gateway
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8 # DNS server ip address
        dns-search tacacsgui.local # you can change that entry or delete it

If you will use nano editor, to save changes press Ctrl + x and then press y to approve the save action.


Apply New Settings

It is final step. Use bunch of commands sudo ip addr flush dev ens32; sudo ifdown ens32; sudo ifup ens32;. Replace ens32 before applying, if you have other interface name.

Info

It was successfully tested on with remote connection and it will work for you if you will set correct ip address.

Created at: 2018-05-22 08:59:41
Updated at: 2018-05-22 09:45:29
Author: Alexey Mochalin