Jul 10 2018

Virtual IP Creation with Linux Service in CentOS 7

Category: Linux & UnixFatih Acar @ 10:43

You can create virtual IP address with linux service. I designed the linux service to create a virtual IP address when operating system is rebooted.

My System Properties

Ethernet Adaptor Name : ens14025
Virtual IP : 192.168.44.55

1. Create Bash Script To Create Virtual IP Address


[root@test ~]# vi /opt/scripts/virtual_ip_up.sh

#!/bin/bash
ifconfig ens14025:1 192.168.44.55 netmask 255.255.255.0

[root@test ~]# chmod 744 /opt/scripts/virtual_ip_up.sh

2. Create Service File


[root@test ~]# vi /etc/systemd/system/virtual_ip.service

[Unit]
Description=Virtual IP
After=syslog.target
After=network.target

[Service]
Type=simple

User=root
Group=root

OOMScoreAdjust=-1000

ExecStart=/opt/scripts/virtual_ip_up.sh

TimeoutSec=300

[Install]
WantedBy=multi-user.target


[root@test ~]# chmod 644 /etc/systemd/system/virtual_ip.service

3. Start Service



[root@test ~]# systemctl daemon-reload
[root@test ~]# systemctl start virtual_ip.service
[root@test ~]# systemctl enable virtual_ip.service

2,960 total views, 5 views today

Tags: Linux, Linux Administration, System Administration

facebook comments:

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.