Tag: Network

  • How to add secondary IP address using nmcli

    How to add secondary IP address using nmcli

    On an AlmaLinux 9 server, I wanted to add secondary IPs to a server. First, I checked the network interface device name used in the server with the command

    ip a
    

    The current public IP address was assigned to the network interface with the name enp13s0. To see how it is configured, I run

    cd /etc
    grep -irl enp13s0
    

    That showed the server am using Network Manager to configure the IP address

    [root@node4 etc]# grep -irl enp13s0
    NetworkManager/system-connections/enp13s0.nmconnection
    [root@node4 etc]# 
    

    You can add additional IP adding using nmcli command.

    nmcli con mod DEVICE_NAME +ipv4.addresses "IP_ADDR/24"
    

    Example

    nmcli con mod enp13s0 +ipv4.addresses "67.222.158.35/24"
    nmcli con mod enp13s0 +ipv4.addresses "67.222.158.36/24"
    nmcli con mod enp13s0 +ipv4.addresses "67.222.158.37/24"
    nmcli con mod enp13s0 +ipv4.addresses "67.222.158.38/24"
    nmcli con mod enp13s0 +ipv4.addresses "67.222.158.39/24"
    nmcli con mod enp13s0 +ipv4.addresses "67.222.158.40/24"
    nmcli con mod enp13s0 +ipv4.addresses "67.222.158.41/24"
    

    To make the IPs online, run

    nmcli con up enp13s0
    

    Now ip a command lists all secondary IP addresses

    [root@node4 etc]# ip a show enp13s0
    2: enp13s0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 74:56:3c:31:38:0a brd ff:ff:ff:ff:ff:ff
        inet 67.222.158.34/24 brd 67.222.158.255 scope global noprefixroute enp13s0
           valid_lft forever preferred_lft forever
        inet 67.222.158.35/24 brd 67.222.158.255 scope global secondary noprefixroute enp13s0
           valid_lft forever preferred_lft forever
        inet 67.222.158.36/24 brd 67.222.158.255 scope global secondary noprefixroute enp13s0
           valid_lft forever preferred_lft forever
        inet 67.222.158.37/24 brd 67.222.158.255 scope global secondary noprefixroute enp13s0
           valid_lft forever preferred_lft forever
        inet 67.222.158.38/24 brd 67.222.158.255 scope global secondary noprefixroute enp13s0
           valid_lft forever preferred_lft forever
        inet 67.222.158.39/24 brd 67.222.158.255 scope global secondary noprefixroute enp13s0
           valid_lft forever preferred_lft forever
        inet 67.222.158.40/24 brd 67.222.158.255 scope global secondary noprefixroute enp13s0
           valid_lft forever preferred_lft forever
        inet 67.222.158.41/24 brd 67.222.158.255 scope global secondary noprefixroute enp13s0
           valid_lft forever preferred_lft forever
        inet6 fe80::7656:3cff:fe31:380a/64 scope link noprefixroute 
           valid_lft forever preferred_lft forever
    [root@node4 etc]# 
    

    To list all network interface devices using nmcli, run

    [root@node4 etc]# nmcli connection show
    NAME          UUID                                  TYPE      DEVICE       
    enp13s0       4ca2de2f-1f4d-38e2-84fc-4d17aafc2514  ethernet  enp13s0      
    docker0       521f050e-7870-43b3-a6ca-618d45116b03  bridge    docker0      
    [root@node4 etc]# 
    

    Back to IP

  • systemd-networkd

    systemd-networkd

    systemd-networkd configuration files are stored in /etc/systemd/network/

    Example

    /etc/systemd/network/05-eth0.network
    

    Here is a sample config

    [Match]
    Name=eth0
    
    [Network]
    DHCP=no
    DNS=172.105.170.5 172.105.161.5 172.105.171.5
    Domains=members.linode.com
    IPv6PrivacyExtensions=false
    
    Gateway=194.195.127.1
    Address=194.195.127.150/24
    

    To restart systemd-networkd

    systemctl restart systemd-networkd
    

    See IP

  • Configure Failover IP in Ubuntu 20.04 OVH VPS

    Configure Failover IP in Ubuntu 20.04 OVH VPS

    To configure IP on OVH VPS, you need to manually configure networking as OVH gateway is outside the failover IP subnet. For most hosting providers getaway will be in the same subnet as the IP address. To configure IP using netplan, see instruction here.

    First, install ifupdown package

    apt install -y ifupdown
    

    Now edit file

    vi /etc/network/interfaces
    

    Add

    auto NETWORK_INTERFACE_HERE
    iface NETWORK_INTERFACE_HERE inet static
        address FO_IP_ADDR
        netmask 255.255.255.255
        broadcast FO_IP_ADDR
        dns-nameservers 8.8.8.8 8.8.4.4
        post-up ip route add GATEWAY_ADDR dev NETWORK_INTERFACE_HERE
        post-up ip route add default via GATEWAY_ADDR dev NETWORK_INTERFACE_HERE
        pre-down ip route del GATEWAY_ADDR dev NETWORK_INTERFACE_HERE
        pre-down ip route del default via GATEWAY_ADDR dev NETWORK_INTERFACE_HERE
    

    In the above text, replace

    NETWORK_INTERFACE_HERE = with your actual network interface name, for example, eth0, ens18, etc.
    FO_IP_ADDR = Your VPS IP address, OVH calls this Failover IP address. It is just any secondary IP address you purchase.
    GATEWAY_ADDR = Gateway IP address. This is the same as the Main IP of the server with the last octal replaced by 254

    Example

    Ubuntu 20.04 failover IP

    Configuration is the same as Ubuntu 18.04, the only difference is post-up and pre-down tines, where Ubuntu 18.04 used older route command, in Ubuntu 20.04, we use “ip route” command instead.

  • Change Unidentified Network from public in windows 7

    After upgrading Main computer (one that connect to DSL modem) on LAN, other PC’s are able to get internet. But failed to ping on 192.168.0.1.

    Method 1

    Go to

    Start > Search > secpol.msc
    

    Navigate to

    Network List Manager Policies > Unidentified Networks
    

    Double Click and Change Location Type to

    Private
    

    Warning This means from now on all Unidentified Networks will be set as private!!

    Method 2

    NOTE: This is temporary solution, on rebooting, changes will be lost

    This is caused by Network card that connect to lan with IP 192.168.0.1 is assigned as a “Public Network”. Public Network have many features disabled for security.

    To fix this, run “ChangeCategory.psl” on Power Shell running as Administrator.

    Copy and paste following content to a text file, save it as ChangeCategory.psl

    $NLMType = [Type]::GetTypeFromCLSID('DCB00C01-570F-4A9B-8D69-199FDBA5723B')
    $INetworkListManager = [Activator]::CreateInstance($NLMType)
    
    $NLM_ENUM_NETWORK_CONNECTED  = 1
    $NLM_NETWORK_CATEGORY_PUBLIC = 0x00
    $NLM_NETWORK_CATEGORY_PRIVATE = 0x01
    $UNIDENTIFIED = "Unidentified network"
    
    $INetworks = $INetworkListManager.GetNetworks($NLM_ENUM_NETWORK_CONNECTED)
    
    foreach ($INetwork in $INetworks)
    {
        $Name = $INetwork.GetName()
        $Category = $INetwork.GetCategory()
    
        if ($INetwork.IsConnected -and ($Category -eq $NLM_NETWORK_CATEGORY_PUBLIC) -and ($Name -eq $UNIDENTIFIED))
        {
            $INetwork.SetCategory($NLM_NETWORK_CATEGORY_PRIVATE)
        }
    }
    

    Now run power shell as administrator.

    Type

    set-executionpolicy remotesigned
    ChangeCategory.ps1 
    

    This should be done in folder where ChangeCategory.ps1 is saved.

    PowerShell change network

    After doing this, Network and Sharing Center will show

    Undefined Network

    Windows Firewall will show “undefined network” in “Home or work (private) networks”. Being in private network, you get privileges to share, ping etc…

    See Windows