Networking – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Wed, 24 Aug 2022 10:44:52 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 Configuring the Static IPv4 Address on Ubuntu using Netplan https://tecadmin.net/setup-static-ip-address-on-ubuntu-using-netplan/ https://tecadmin.net/setup-static-ip-address-on-ubuntu-using-netplan/#respond Wed, 01 Jun 2022 06:48:07 +0000 https://tecadmin.net/?p=29140 The Ubuntu 17.10 and later systems use the Netplan as a new command-line utility for managing network interfaces. It works with the Systemd-networkd or NetworkManager renderes. Netplan configuration files are written in YAML format, allowing you simple-to-complex networking configurations. Which work from the Desktop to the server and from the cloud to IoT devices. This [...]

The post Configuring the Static IPv4 Address on Ubuntu using Netplan appeared first on TecAdmin.

]]>
The Ubuntu 17.10 and later systems use the Netplan as a new command-line utility for managing network interfaces. It works with the Systemd-networkd or NetworkManager renderes. Netplan configuration files are written in YAML format, allowing you simple-to-complex networking configurations. Which work from the Desktop to the server and from the cloud to IoT devices.

This article will help you to configure static IPv4 addresses on Ubuntu systems using the Netplan command-line tool.

Check the Network Interface Name

First of all, you need to identify the network interface name. It can differ based on the installation type and system environment.

  • To find the interface name type:
    sudo nmcli device status 
    
    Output:
    DEVICE TYPE STATE CONNECTION eth0 ethernet connected Wired connection 1 lo loopback unmanaged --
  • You can also check the interface name using the ip command:
    sudo ip a 
    

    Configure Static IPv4 Address using Netplan on Ubuntu
    Checking the network interface name

The above output shows that the system is configured with the network interface name eth0. This can be different on your system. So please verify the system network interface name with the ip a command as shown above.

Configuring the Static IP Address using Netplan

Netplan stores all the configuration files under /etc/netplan directory. As you already have the network interface name found in the above commands. Now, we will configure the static IP address to that interface using the NetPlan utility.

Let’s, create a configuration file and edit it in your favorite text editor:

sudo vi /etc/netplan/01-netcfg.yaml 

Add the network configuration in YAML format. The below configuration uses 4 spaces due to strict indentation followed by the YAML.

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            addresses:
                - 192.168.0.210/24
            nameservers:
                addresses: [8.8.8.8, 8.8.4.4]
            routes:
                - to: default
                  via: 192.168.0.254

In the above configuration:

  • eth0 – is the network interface name
  • 192.168.0.210/24 – is the IPv4 address to set on interface. Make sure to define CIDR. You can add multiple IP address as well.
  • routes via 192.168.0.254 – Set the gateway IP address of the network
  • 8.8.8.8, 8.8.4.4 – is the IP address of the Google DNS servers.

Make sure the IPv4 address belongs to the system network and has the correct gateway Ip address.

Once confirmed, press ESC and :wq to save file content and close it.

Now, execute the following command to apply the changes:

sudo netplan apply 

This will configure the static IPv4 address on the network interface. Now the system will be accessible with the new IP address you configured above.

Conclusion

In this tutorial, you have learned to configure the network interface on Ubuntu systems.

The post Configuring the Static IPv4 Address on Ubuntu using Netplan appeared first on TecAdmin.

]]>
https://tecadmin.net/setup-static-ip-address-on-ubuntu-using-netplan/feed/ 0
IP FailOver Setup Using KeepAlived on CentOS & Red Hat https://tecadmin.net/ip-failover-setup-using-keepalived-on-centos-redhat/ https://tecadmin.net/ip-failover-setup-using-keepalived-on-centos-redhat/#comments Thu, 19 Sep 2013 06:38:45 +0000 https://tecadmin.net/?p=630 Keepalived is used for IP failover between two servers. It facilities for load balancing and high-availability to Linux-based infrastructures. It works on VRRP ( Virtual Router Redundancy Protocol ) protocol. We have running two load balance servers using HAProxy and now we need to implement VRRP between both servers. This tutorial will help you to [...]

The post IP FailOver Setup Using KeepAlived on CentOS & Red Hat appeared first on TecAdmin.

]]>
Keepalived is used for IP failover between two servers. It facilities for load balancing and high-availability to Linux-based infrastructures. It works on VRRP ( Virtual Router Redundancy Protocol ) protocol. We have running two load balance servers using HAProxy and now we need to implement VRRP between both servers. This tutorial will help you to configure KeepAlived, Use this tutorial to configure HAProxy on both servers.

Network Scenario:
    1. LB1 Server: 192.168.10.111 ( eth1 )
    2. LB2 Server: 192.168.10.112 ( eth1 )
    3. Virtual IP: 192.168.10.121

Now we are implementing ip failover setup between LB1 and LB2 servers.

Graphical representation of Fail over Setup:

keepalived-vrrp-network

Step 1 – Install Required Packages

Use the following command to install required packages to configure Keepalived on the server.

# yum install gcc kernel-headers kernel-devel
Step 2 – Install Keepalived

Keepalived is available in centos base repository. Install it using yum command line tool.

# yum install keepalived

Keepalived configuration File: /etc/keepalived/keepalived.conf

Step 3 – Configure Keepalived on LB1

Edit Keepalived configuration file on LB1 and add following configuration. Update all red highlighted values with your network and system configuration.

! Configuration File for keepalived

global_defs {
   notification_email {
     sysadmin@mydomain.com
     support@mydomain.com
   }
   notification_email_from lb1@mydomain.com
   smtp_server localhost
   smtp_connect_timeout 30
}

vrrp_instance VI_1 {
    state MASTER
    interface eth1
    virtual_router_id 51
    priority 101
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.10.121
    }
}
Step 4 – Configure KeepAlived on LB2

Edit Keepalived configuration file on LB2 and add following configuration. While making changes in LB2 configuration file, make sure to set priority values to lower than LB1. For example below configuration is showing 100 priority value than LB1 has it 101.

! Configuration File for keepalived

global_defs {
   notification_email {
     sysadmin@mydomain.com
     support@mydomain.com
   }
   notification_email_from lb2@mydomain.com
   smtp_server localhost
   smtp_connect_timeout 30
}

vrrp_instance VI_1 {
    state MASTER
    interface eth1
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.10.121
    }
}
1. Priority value will be higher on Master server, It doesn’t matter what you used in state. If your state is MASTER but your priority is lower than the router with BACKUP, you will lose the MASTER state.
2. virtual_router_id should be same on both LB1 and LB2 servers.
3. By default single vrrp_instance support up to 20 virtual_ipaddress. In order to add more addresses you need to add more vrrp_instance
Step 5 – Start KeepAlived

Start KeepAlived service using the following command and also configure to autostart on system boot.

# service keepalived start
# chkconfig keepalived on
Step 6 – Check Virtual IPs

By default virtual IP will be assigned to master server, In case of master gets down, it will automatically assign to the slave server. Use the following command to show assigned virtual IP on the interface.

# ip addr show eth1

Sample output

2: eth1:  mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:6f:ed:60 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.111/24 brd 192.168.1.255 scope global eth1
    inet 192.168.10.121/32 scope global eth1
    inet6 fe80::20c:29ff:fe6f:ed60/64 scope link
       valid_lft forever preferred_lft forever
Step 7 – Verify IP Failover

Follow the below process to test keepalived failover is working correctly.

  • Shutdown master server ( LB1 ) and check if ips are automatically assigned to the slave server.
    # ip addr show eth1
    
  • Now start LB1 and stop slave server ( LB2 ). IPs will automatically be assigned to master server.
    # ip addr show eth1
    
  • Watch log files to insure its working
    # tailf /var/log/messages
    

    Sample Output

    Mar 19 17:30:24 localhost Keepalived_vrrp[6958]: VRRP_Instance(VI_1) Transition to MASTER STATE
    Mar 19 17:30:25 localhost Keepalived_vrrp[6958]: VRRP_Instance(VI_1) Entering MASTER STATE
    Mar 19 17:30:25 localhost Keepalived_vrrp[6958]: VRRP_Instance(VI_1) setting protocol VIPs.
    Mar 19 17:30:25 localhost Keepalived_healthcheckers[6957]: Netlink reflector reports IP 192.168.10.121 added
    Mar 19 17:30:25 localhost avahi-daemon[1407]: Registering new address record for 192.168.10.121 on eth1.IPv4.
    Mar 19 17:30:25 localhost Keepalived_vrrp[6958]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for
    

I hope this article will help to setup IP failover between two load balance servers.

The post IP FailOver Setup Using KeepAlived on CentOS & Red Hat appeared first on TecAdmin.

]]>
https://tecadmin.net/ip-failover-setup-using-keepalived-on-centos-redhat/feed/ 16
Network Configuration in CentOS & Red Hat https://tecadmin.net/network-configuration-in-centos-redhat/ https://tecadmin.net/network-configuration-in-centos-redhat/#comments Sat, 02 Mar 2013 10:52:37 +0000 https://tecadmin.net/?p=363 Linux provides a number of tools for network configuration. Most important network settings for you Linux machine to access over network are IP configuration Device activation DNS configuration Default gateway 1. Default Network Configuration Files: Default linux interfaces configuration file exists in /etc/sysconfig/network-scripts/ named ifcfg-ethX ( ‘X’ is replace with number 0,1 or 2 etc [...]

The post Network Configuration in CentOS & Red Hat appeared first on TecAdmin.

]]>
Linux provides a number of tools for network configuration. Most important network settings for you Linux machine to access over network are

  • IP configuration
  • Device activation
  • DNS configuration
  • Default gateway

1. Default Network Configuration Files:

  • Default linux interfaces configuration file exists in /etc/sysconfig/network-scripts/ named ifcfg-ethX ( ‘X’ is replace with number 0,1 or 2 etc ).
  • /etc/sysconfig/network : is global configuration file
     NETWORKING = yes
     HOSTNAME = server1.tecadmin.net
     GATEWAY = 192.168.10.1
    
  • /etc/sysconfig/network-script/ifcfg-ethX : is Ethernet configuration file so assign ip address, netmask on interface.
  • /etc/resolv.conf : DNS servers ip addresses are specified in this file.
  • /etc/hosts : Is used for locally resolve a hostname with ip.

2. Device Configuration:

There are two ways to configure network device to get ip address. 1- In dynamic configuration system gets ip address and other network details from dhcp server where in static configuration we set the fixed ip address and network details in interfaces configuration files. Below is the example file of network interfaces.

Dynamic Configuration:

DEVICE = ethX
HWADDR = 00:33:5A:9B:74:99
BOOTPROTO = dhcp
ONBOOT = yes
TYPE = Ethernet

Static Configuration:

DEVICE = ethX
HWADDR = 00:33:5A:9B:74:99
BOOTPROTO = static
IPADDR = 192.168.10.100
NETMASK = 255.255.255.0
GATEWAY = 192.168.10.1
ONBOOT = yes
TYPE = Ethernet
USRCTL = no

Details of configuration parameters:

  • DEVICE: Ethernet device name
  • HWADDR: Hardware address or MAC address
  • BOOTPROTO: dhcp or static
  • ONBOOT: yes/no , it tells that interface will automatically up or not on boot.
  • Type: Type of interface.
  • USRCTL: yes/no , it tells that a non root user can bring this device up or down.

If you do not want to edit files directly, you can use `setup` command to configure network interfaces

The post Network Configuration in CentOS & Red Hat appeared first on TecAdmin.

]]>
https://tecadmin.net/network-configuration-in-centos-redhat/feed/ 1