Overview

Network in Linux is configured via scripts. There are 2 locations for network:

The udev rules set the mapping between devices and users or any other system change which is needed. For example, during Oracle RAC installation, we have to set udev rules to change the owner of a specific iSCSI device to oracle user instead of root. During start up the udev deamon checks the rules and apply them. We can of course trigger the rules ourselves as we are going to see.

Network interfaces

The default configuration location for network interfaces is at: /etc/sysconfig/network-scripts, in this folder, each interface has his own file with the necessary configuration which of course can be changed. In case a change is done, restart of the network interface should be done. This can be done by restarting:

Let's change our IP for example (bear in mind that the IP should be supported by the NIC)

We can see our network configuration as follows:

[root@mysqlmaster ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:95:cb:b8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.129/24 brd 192.168.0.255 scope global dynamic enp0s3
       valid_lft 3025sec preferred_lft 3025sec
    inet6 fe80::a00:27ff:fe95:cbb8/64 scope link
       valid_lft forever preferred_lft forever
[root@mysqlmaster ~]#

We can also see, the same settings in the following system configuration file:

[root@mysqlmaster ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE="Ethernet"
BROWSER_ONLY="no"
BOOTPROTO="static" (static or dhcp, depending on what you want)
IPADDR=192.168.0.129
NETMASK=255.255.255.0
NAME="enp0s3"
DEVICE="enp0s3"
ONBOOT="yes" (if you wish it to start during bootup)

If I change my IP from 129 → 130 and restart my network interface I should have different IP, right :) ?

[root@mysqlmaster ~]# ifdown enp0s3
Device 'enp0s3' successfully disconnected.
[root@mysqlmaster ~]# cat log.log
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
[root@mysqlmaster ~]#
[root@mysqlmaster ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:95:cb:b8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.130/24 brd 192.168.0.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe95:cbb8/64 scope link
       valid_lft forever preferred_lft forever

This way we don't have to restart the whole network stack, there is however one problem with that procedure. What if we are connected to this IP and we change it, well you just lost your connection :) So if we do the same thing but we restart the whole service:

[root@mysqlmaster ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[root@mysqlmaster ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:95:cb:b8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.129/24 brd 192.168.0.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe95:cbb8/64 scope link
       valid_lft forever preferred_lft forever
[root@mysqlmaster ~]#

Modify DNS Search (Ubuntu)

To modify the DNS search location use the following commands:

Modify DNS Search domain

lackbox@ubuntu:~$ sudo su - 
[sudo] password for flackbox: 
root@ubuntu:~# nmcli c modify "Wired connection 1" ipv4.dns-search "flackboxA.lab"
root@ubuntu:~# 
root@ubuntu:~# 
root@ubuntu:~# nmcli c down "Wired connection 1" && nmcli c up "Wired connection 1"
Connection 'Wired connection 1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
root@ubuntu:~# 
root@ubuntu:~# 
root@ubuntu:~# 
root@ubuntu:~# 
root@ubuntu:~# 

That command will modify the “Wired Connection 1” settings to search for flackboxA.lab domain.