RTFB!
12 Dec
Včasih rabimo na sistemu več IP naslovov. Ker nam po defaultu Ubuntu doda samo en IP naslov bom pokazal kako se doda nov IP naslov. Zadeva je zelo preprosta tako da nebi smeli imeti težav.
Kaj potrebujete:
SU (SuperUser) dostop
vi ali katerikoli drug editor (jaz bom uporabil ee)
Prijavite se v sistem (preko konzole SSH) in se zlogirajte v sistem kot su.
su
ali
sudo su
ali pa uporabite
sudo
pred ukazi.
Vsi IP naslovi in pa nastavitve za mrežo se nahajajo v datoteki: /etc/network/interfaces
ee /etc/network/interfaces
V datoteki bi moralo biti nekaj podobnega naslednjemu:
# 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 static
address 10.0.0.10
netmask 255.255.255.0
network 192.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.99
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 10.0.0.99
Če dobite kaj temu podobnega potem ste na pravi poti. Kot vidite uporabljam IP naslove 10.0.0.xx.
Naslednje dodamo pod to kar smo dobili:
auto eth0:1
iface eth0:1 inet static
address 10.0.0.20
netmask 255.255.255.0
network 192.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.99
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 10.0.0.99
Shranimo! Kot vidite sem dodal nov IP naslov 10.0.0.20 mrežni kartici eth0:1. eth0 je mrežna kartica (če jih imate več pač izberete katero hočete uporabiti) :1 je za ločilo IP naslovov tako da jih lahko dodamo neomejeno :2 :3 :4 itd.
Če sedaj poženete ukaz ifconfig boste dobili še stare podatke o mreži.
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:40:F4:60:D7:A1
inet addr:10.0.0.10 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::240:f4ff:fe60:d7a1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:147909 errors:0 dropped:0 overruns:0 frame:0
TX packets:125638 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:44033380 (41.9 MiB) TX bytes:42312161 (40.3 MiB)
Interrupt:11 Base address:0×6000lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4118 errors:0 dropped:0 overruns:0 frame:0
TX packets:4118 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:330719 (322.9 KiB) TX bytes:330719 (322.9 KiB)
Da osvežite podatke ki ste jih dodali v /etc/network/interfaces poženite naslednji ukaz:
/etc/init.d/networking restart
Ko to izvedete bi morali dobiti naslednje:
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:40:F4:60:D7:A1
inet addr:10.0.0.10 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::240:f4ff:fe60:d7a1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:148383 errors:0 dropped:0 overruns:0 frame:0
TX packets:126045 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:44075455 (42.0 MiB) TX bytes:42363253 (40.4 MiB)
Interrupt:11 Base address:0×6000eth0:1 Link encap:Ethernet HWaddr 00:40:F4:60:D7:A1
inet addr:10.0.0.20 Bcast:10.0.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0×6000lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4125 errors:0 dropped:0 overruns:0 frame:0
TX packets:4125 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:331391 (323.6 KiB) TX bytes:331391 (323.6 KiB)
Tako. To je cela umetnost! Na ta način lahko dodate kolikor hočete IP naslovov. Jaz sem bil prijavljen kot ‘superuser’ zato nisem uporabljal sudo itd. Če niste kot ‘superuser’ potem pred vsemi ukazi uporabite sudo blablabla ![]()
To sem delal na sistemu Ubuntu:
Linux 2.6.17-10-server #2 SMP Fri Oct 13 18:47:26 UTC 2006 i686 GNU/Linux
iNobl: 15% [?]
Tagi:
Leave a reply