Mepụta ọtụtụ adreesị IP n'otu interface netwọk otu


Echiche nke ịmepụta ma ọ bụ ịhazi ọtụtụ adreesị IP na otu netwọk netwọk ka a na-akpọ IP aliasing. IP aliasing bara ezigbo uru maka ịtọlite ọtụtụ saịtị mebere na Apache site na iji otu interface netwọkụ nwere adreesị IP dị iche iche na otu netwọkụ subnet.

Isi uru dị n'iji aliasing IP a bụ, ọ dịghị mkpa ka ị nweta ihe nkwụnye anụ ahụ na IP ọ bụla, kama ị nwere ike ịmepụta ọtụtụ ma ọ bụ ọtụtụ mebere interfaces (aliases) na otu kaadị anụ ahụ.

Ntuziaka enyere ebe a na-emetụta nkesa Linux niile dị ka Red Hat, Fedora, na CentOS. Ịmepụta ọtụtụ oghere na iji aka kenye ya adreesị IP bụ ọrụ dị egwu. N'ebe a, anyị ga-ahụ ka anyị ga-esi kenye adreesị IP na ya na-akọwa otu ụdị IP dị iche iche. Ghọtakwa ka anyị ga-esi mepụta interface mebere ma kenye ụdị adreesị IP dị iche iche na interface n'otu oge. N'isiokwu a, anyị ji LAN IP's, yabụ dochie ndị ị ga-eji.

Ịmepụta Interface mebere ma kenye ọtụtụ adreesị IP

N'ebe a, enwere m interface akpọrọ ifcfg-eth0, interface ndabere maka ngwaọrụ Ethernet. Ọ bụrụ na ị jikọtara ngwaọrụ Ethernet nke abụọ, mgbe ahụ, a ga-enwe ngwaọrụ ifcfg-eth1 na ihe ndị ọzọ maka ngwaọrụ ọ bụla ị tinyere. Faịlụ netwọkụ ngwaọrụ ndị a dị na ndekọ /etc/sysconfig/network-scripts/ ndekọ. Gaa na ndekọ ma mee “ls -l” ka ịdepụta ngwaọrụ niile.

# cd /etc/sysconfig/network-scripts/
# ls -l
ifcfg-eth0   ifdown-isdn    ifup-aliases  ifup-plusb     init.ipv6-global
ifcfg-lo     ifdown-post    ifup-bnep     ifup-post      net.hotplug
ifdown       ifdown-ppp     ifup-eth      ifup-ppp       network-functions
ifdown-bnep  ifdown-routes  ifup-ippp     ifup-routes    network-functions-ipv6
ifdown-eth   ifdown-sit     ifup-ipv6     ifup-sit
ifdown-ippp  ifdown-tunnel  ifup-isdn     ifup-tunnel
ifdown-ipv6  ifup           ifup-plip     ifup-wireless

Ka anyị chee na anyị chọrọ ịmepụta oghere mebere atọ ọzọ iji jikọta adreesị IP atọ (172.16.16.126, 172.16.16.127, na 172.16.16.128) na NIC. Yabụ, anyị kwesịrị imepụta faịlụ utu aha atọ ọzọ, ebe “ifcfg-eth0” na-edobe otu adreesị IP mbụ ahụ. Nke a bụ ka anyị na-aga n'ihu ịtọlite aha aha atọ iji kechie adreesị IP ndị a.

Adapter            IP Address                Type
-------------------------------------------------
eth0              172.16.16.125            Primary
eth0:0            172.16.16.126            Alias 1
eth0:1            172.16.16.127            Alias 2
eth0:2            172.16.16.128            Alias 3

Ebe “:X” bụ nọmba ngwaọrụ (interface) iji mepụta utu aha maka interface eth0. Maka utu aha ọ bụla, ị ga-ekenye nọmba n'usoro. Dịka ọmụmaatụ, anyị na-eṅomi paramita dị ugbu a nke interface ifcfg-eth0 na oghere mebere nke a na-akpọ ifcfg-eth0:0, ifcfg-eth0:1 na ifcfg-eth0:2. Banye na ndekọ netwọkụ wee mepụta faịlụ dịka egosiri n'okpuru.

# cd /etc/sysconfig/network-scripts/
# cp ifcfg-eth0 ifcfg-eth0:0
# cp ifcfg-eth0 ifcfg-eth0:1
# cp ifcfg-eth0 ifcfg-eth0:2

Mepee faịlụ ifcfg-eth0 wee lelee ọdịnaya.

 vi ifcfg-eth0

DEVICE="eth0"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.125
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C

N'ebe a, anyị chọrọ naanị parampat abụọ (ngwaọrụ na IPADDR). Ya mere, mepee faịlụ ọ bụla na onye nchịkọta akụkọ VI wee nyegharịa aha ngwaọrụ na utu aha ya kwekọrọ wee gbanwee adreesị IPADDR. Dịka ọmụmaatụ, mepee faịlụ ifcfg-eth0: 0, ifcfg-eth0: 1 na ifcfg-eth0: 2 site na iji nchịkọta VI wee gbanwee ma paramita ahụ. N'ikpeazụ ọ ga-adị ka n'okpuru.

DEVICE="eth0:0"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.126
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C
DEVICE="eth0:1"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.127
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C
DEVICE="eth0:2"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.128
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C

Ozugbo, ịmeela mgbanwe niile, chekwaa mgbanwe gị niile wee malitegharịa/malite ọrụ netwọk ka mgbanwe ndị ahụ tụgharịa.

 /etc/init.d/network restart

Iji nyochaa aha aha niile (virtual interface) na-arụ ọrụ, ị nwere ike iji iwu ip.

 ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.125  Bcast:172.16.16.100  Mask:255.255.255.224
          inet6 addr: fe80::20c:29ff:fe28:fd4c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:237 errors:0 dropped:0 overruns:0 frame:0
          TX packets:198 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:25429 (24.8 KiB)  TX bytes:26910 (26.2 KiB)
          Interrupt:18 Base address:0x2000

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.126  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.127  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.128  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

Ping onye ọ bụla n'ime ha si dị iche iche igwe. Ọ bụrụ na hazie ihe niile nke ọma, ị ga-enweta nzaghachi ping n'aka nke ọ bụla n'ime ha.

ping 172.16.16.126
ping 172.16.16.127
ping 172.16.16.128
 ping 172.16.16.126
PING 172.16.16.126 (172.16.16.126) 56(84) bytes of data.
64 bytes from 172.16.16.126: icmp_seq=1 ttl=64 time=1.33 ms
64 bytes from 172.16.16.126: icmp_seq=2 ttl=64 time=0.165 ms
64 bytes from 172.16.16.126: icmp_seq=3 ttl=64 time=0.159 ms

--- 172.16.16.126 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.159/0.552/1.332/0.551 ms

 ping 172.16.16.127
PING 172.16.16.127 (172.16.16.127) 56(84) bytes of data.
64 bytes from 172.16.16.127: icmp_seq=1 ttl=64 time=1.33 ms
64 bytes from 172.16.16.127: icmp_seq=2 ttl=64 time=0.165 ms
64 bytes from 172.16.16.127: icmp_seq=3 ttl=64 time=0.159 ms

--- 172.16.16.127 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.159/0.552/1.332/0.551 ms

 ping 172.16.16.128
PING 172.16.16.128 (172.16.16.128) 56(84) bytes of data.
64 bytes from 172.16.16.128: icmp_seq=1 ttl=64 time=1.33 ms
64 bytes from 172.16.16.128: icmp_seq=2 ttl=64 time=0.165 ms
64 bytes from 172.16.16.128: icmp_seq=3 ttl=64 time=0.159 ms

--- 172.16.16.128 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.159/0.552/1.332/0.551 ms

Ọ dị ka ihe niile na-arụ ọrụ nke ọma, Site na IP ọhụrụ ndị a, ị nwere ike ịtọlite saịtị mebere na Apache, akaụntụ FTP na ọtụtụ ihe ndị ọzọ.

Kenye otutu Adreesị IP nso

Ọ bụrụ na ịchọrọ ịmepụta ọtụtụ adreesị IP na otu interface a na-akpọ ifcfg-eth0, anyị na-eji ifcfg-eth0-range0 ma detuo ihe nwere ifcfg-eth0 na ya dị ka egosiri n'okpuru.

 cd /etc/sysconfig/network-scripts/
 cp -p ifcfg-eth0 ifcfg-eth0-range0

Ugbu a mepee faịlụ ifcfg-eth0-range0 wee tinye IPADDR_START na IPADDR_END adreesị IP dị ka egosiri n'okpuru.

 vi ifcfg-eth0-range0

#DEVICE="eth0"
#BOOTPROTO=none
#NM_CONTROLLED="yes"
#ONBOOT=yes
TYPE="Ethernet"
IPADDR_START=172.16.16.126
IPADDR_END=172.16.16.130
IPV6INIT=no
#GATEWAY=172.16.16.100

Chekwa ya wee malitegharịa/malite ọrụ netwọk

 /etc/init.d/network restart

Nyochaa na ejiri adreesị IP mebere oghere mebere.

 ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.125  Bcast:172.16.16.100  Mask:255.255.255.224
          inet6 addr: fe80::20c:29ff:fe28:fd4c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1385 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:127317 (124.3 KiB)  TX bytes:200787 (196.0 KiB)
          Interrupt:18 Base address:0x2000

eth0:0     Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.126  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.127  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.128  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:3    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.129  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

eth0:4    Link encap:Ethernet  HWaddr 00:0C:29:28:FD:4C
          inet addr:172.16.16.130  Bcast:172.16.16.100  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x2000

Ọ bụrụ na ị nwere nsogbu ọ bụla na nhazi, biko biputere ajụjụ gị na ngalaba nkọwa.