다음 이전 차례

2. 명령 및 결과

첫째로 IP Alias 모듈을 띄워야 한다. (미리 모듈을 커널로 컴파일 했으면, 이 단계를 뛰어넘어도 된다.)

     /sbin/insmod /lib/modules/`uname -r`/ipv4/ip_alias.o

두번째, 루프백을 설정한후 eth0과 모든 다른 IP넘버들은 eth0 인터페이스를 위해서 주 IP넘버로 시작되어야 한다.

     /sbin/ifconfig lo 127.0.0.1
     /sbin/ifconfig eth0 up
     /sbin/ifconfig eth0 172.16.3.1
     /sbin/ifconfig eth0:0 172.16.3.10
     /sbin/ifconfig eth0:1 172.16.3.100

172.16.3.1 은 주IP넘버이고 .10과 .100은 Alias된 IP넘버이다. 다른 아이피 넘버에 대해서 eth0:x에 0,1,2...n을 대입하는 것이 방법이다. 주 IP 넘버는 알리아스될 필요가 없다.

셋째로 라우트 정보를 설정한다. 루프백을 첫째로 라우트시키고 net 을 그 다음으로 그리고 마지막으로 기본 아이피(원래 배당받았던)로 시작되는 아이피 넘버들을 셋업한다.

     /sbin/route add -net 127.0.0.0
     /sbin/route add -net 172.16.3.0 dev eth0
     /sbin/route add -host 172.16.3.1 dev eth0
     /sbin/route add -host 172.16.3.10 dev eth0:0
     /sbin/route add -host 172.16.3.100 dev eth0:1
     /sbin/route add default gw 172.16.3.200

이게 다이다.

위의 예에서 든 아이피넘버는 Private IP넘버(RFC 1918)를 실제적 예가 되는 목적으로 사용했다. 여러분의의 실제 아이피넘버를 이것이랑 대체해서 써라.

3개의 아이피 넘버에 대해서 예를 들었다. 최대치는 256으로 /usr/include/linux/net_alias.h에 정의되어있다. 사실 한카드에 256개의 IP넘버는 많은 것이다.

여기에 나의 /sbin/infconfig이 보여주는 결과가 있다.

lo       Link encap:Local Loopback
          inet addr:127.0.0.1  Bcast:127.255.255.255  Mask:255.0.0.0
          UP BROADCAST LOOPBACK RUNNING  MTU:3584  Metric:1
          RX packets:5088 errors:0 dropped:0 overruns:0
          TX packets:5088 errors:0 dropped:0 overruns:0

eth0      Link encap:10Mbps Ethernet  HWaddr 00:8E:B8:83:19:20
          inet addr:172.16.3.1  Bcast:172.16.3.255  Mask:255.255.255.0
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:334036 errors:0 dropped:0 overruns:0
          TX packets:11605 errors:0 dropped:0 overruns:0
          Interrut:7 Base address:0x378

eth0:0    Link encap:10Mbps Ethernet  HWaddr 00:8E:B8:83:19:20
          inet addr:172.16.3.10  Bcast:172.16.3.255  Mask:255.255.255.0
          UP BROADCAST RUNNING  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0
          TX packets:0 errors:0 dropped:0 overruns:0

eth0:1    Link encap:10Mbps Ethernet  HWaddr 00:8E:B8:83:19:20
          inet addr:172.16.3.100  Bcast:172.16.3.255  Mask:255.255.255.0
          UP BROADCAST RUNNING  MTU:1500  Metric:1
          RX packets:1 errors:0 dropped:0 overruns:0
          TX packets:0 rrors:0 dropped:0 overruns:0

그리고 /proc/netaliase:

device           family address
eth0:0           2      172.16.3.10
eth0:1           2      172.16.3.100

/proc/net/alias_types에서 보여지는 것이다.

type    name            n_attach
2       ip              2

물론, /proc/net에 있는 이런것들은 ifconfig 명령에 의해서 만들어진 것이지

내 수작업이 아니다!!


다음 이전 차례