Message-ID: <27561054.511.1711727025319.JavaMail.serveradmin@t01app> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_510_19425246.1711727025291" ------=_Part_510_19425246.1711727025291 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Add Additional IP Addresses to Ubuntu Server

Add Additional IP Addresses to Ubuntu Server

Intr= oduction

...

Add Additional Static IP Address

First make sure you know how your current network looks on your server w= ith the already assigned IP address,

=20
ifconfi=
g -a
eth0      Link encap:Ethernet  HWaddr 00:16:3c:3f:68:7f =20
          inet addr:64.73.220.110  Bcast:64.73.220.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3cff:fe3f:687f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1677062 errors:0 dropped:952 overruns:0 frame:0
          TX packets:11659 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000=20
          RX bytes:88552695 (88.5 MB)  TX bytes:2706451 (2.7 MB)
# you will see more but ignore
 
cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
 
# get gateway
route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Ifa=
ce
0.0.0.0         64.73.220.1     0.0.0.0         UG    0      0        0 eth=
0
10.0.3.0        0.0.0.0         255.255.255.0   U     0      0        0 lxc=
br0
64.73.220.0     0.0.0.0         255.255.255.0   U     0      0        0 eth=
0
 
# Get name servers,
cat /etc/resolv.conf=20
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf=
(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 216.15.129.205
nameserver 216.15.129.206
=20

Key things to note is your ethernet card device name (usually eth0), mas= k, gateway and name servers. In this example,

Network Attribute Value
ethernet card device eth0
mask 255.255.255.0
gateway 64.73.220.1
name servers

216.15.129.205
216.15.129.206

 

Temporary= to Test

You may use the ifconfig or ip command. I like the ifconfig as you do no= t need to calculate the netmas= k from Dotted Decimal to Bitmask (Bits). I also noticed = a difference between the two commands. With the ifconfig, a brd number is a= dded. I have no idea what the brd number is used for. Both approaches do wo= rk. 

In this example, we will add 64.73.220.110 to the existing eth= ernet card.

ifconfig Approach

This approach has a brd number,

=20
# synta=
x with add or del to add or delete the ip
# ip address add/del [ip]/[mask-digits] dev [nic]
ifconfig eth0:0 64.73.220.117 netmask 255.255.255.0 up


# verify new address shows up,
ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN g=
roup default=20
    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=20
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast =
state UP group default qlen 1000
    link/ether 00:16:3c:3f:68:7f brd ff:ff:ff:ff:ff:ff
    inet 64.73.220.110/24 brd 64.73.220.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 64.73.220.111/24 brd 64.73.220.255 scope global secondary eth0:0
       valid_lft forever preferred_lft forever
    inet6 fe80::216:3cff:fe3f:687f/64 scope link=20
       valid_lft forever preferred_lft forever
3: lxcbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue s=
tate UP group default=20
    link/ether fe:33:d8:e0:ef:6b brd ff:ff:ff:ff:ff:ff
    inet 10.0.3.1/24 brd 10.0.3.255 scope global lxcbr0
       valid_lft forever preferred_lft forever
    inet6 fe80::b06f:d2ff:fe9d:49be/64 scope link=20
       valid_lft forever preferred_lft forever
5: vethHVREWV: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo=
_fast master lxcbr0 state UP group default qlen 1000
    link/ether fe:33:d8:e0:ef:6b brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc33:d8ff:fee0:ef6b/64 scope link=20
       valid_lft forever preferred_lft forever
=20

ip Approach

This approach results in not brd number  and you need to make = sure to calculate the netmask from Dotted Decimal to Bitmask (Bits). In thi= s case, 255.255.255.0 =3D 24,

=20
# synta=
x with add or del to add or delete the ip
# ip address add/del [ip]/[mask-digits] dev [nic]
sudo ip address add 64.73.220.111/24 dev eth0
 
# verify new address shows up,
ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN g=
roup default=20
    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=20
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast =
state UP group default qlen 1000
    link/ether 00:16:3c:3f:68:7f brd ff:ff:ff:ff:ff:ff
    inet 64.73.220.110/24 brd 64.73.220.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 64.73.220.111/24 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::216:3cff:fe3f:687f/64 scope link=20
       valid_lft forever preferred_lft forever
3: lxcbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue s=
tate UP group default=20
    link/ether fe:33:d8:e0:ef:6b brd ff:ff:ff:ff:ff:ff
    inet 10.0.3.1/24 brd 10.0.3.255 scope global lxcbr0
       valid_lft forever preferred_lft forever
    inet6 fe80::b06f:d2ff:fe9d:49be/64 scope link=20
       valid_lft forever preferred_lft forever
5: vethHVREWV: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo=
_fast master lxcbr0 state UP group default qlen 1000
    link/ether fe:33:d8:e0:ef:6b brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc33:d8ff:fee0:ef6b/64 scope link=20
       valid_lft forever preferred_lft forever
=20

Ad= d a permanent IP Address

To make the changes permanent modify the /etc/network/interfaces with th= e following syntax,

=20
auto [N=
IC]:[n]
iface [NIC]:[n] inet static
address [ip.add.rr.ss]
gateway [gw.ip.ad.rs]
netmask [ne.tm.as.kk]
=20

Continuing with the example the full file would look like this,

=20
# This =
file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Second IP
auto eth0:1
iface eth0:1 inet static
address 64.73.220.111
gateway 64.73.220.1
netmask 255.255.255.0
dns-nameservers 216.15.129.205 216.15.129.206
=20

Based on my home server work, name server entries are required for stat= ic entries. But in this this case, it is a second entry and resolv.conf has= the name servers listed from the first dhcp assigned network card. Will te= st how this pans out without name server first then update here if needed.<= /p>

References

Best article yet - https://www= .garron.me/en/linux/add-secondary-ip-linux.html


# syntax ifconfig [nic]:0 [IP-Address] netmask [mask] upsudo ifconfi= g eth0:0 64.73.220.110 netmask 255.255.255.0 up

------=_Part_510_19425246.1711727025291--