'ifdown'에 해당되는 글 4건

  1. 2009.12.29 ifup / ifdown 을 통한 static <-> dhcp 변환
  2. 2009.12.02 busybox udhcp interface 파일 주의사항
  3. 2009.08.18 ifup/ifdown
  4. 2009.08.17 ifup / ifdown + busybox
프로그램 사용/busybox2009. 12. 29. 14:47
windows나 linux에서는 static / dhcp 변환이 자유롭다.
박스에서 이 기능을 구현하기 위해 ifup / ifdown 을 사용하여 구현을 하려고 했다.

일단 구현되어야 할 내용은
static -> dhcp
dhcp -> static
인데, 문제는 dhcp -> static이었다.

이유는 모르겠지만,
# ifdown -i interface.dhcp eth0
# ifup -i interface.static eth0
를 해도 dhcp에서 받아왔던 아이피로 남아있는데

일단 미봉책으로
# ifdown -i interface.dhcp eth0
# ifup -i interface.static eth0
# ifdown -i interface.static eth0
# ifup -i interface.static eth0
이렇게 static한 설정을 한번더 down/up 해주니 문제없이 아이피가 설정이 된다.

대부분의 예제 파일들이,

static up/down
dhcp up
예제만 있지,

dhcp down
static -> dhcp
는 존재하지 않는다.

아무튼, 일단은 되는게 장땡 -ㅁ-!
Posted by 구차니
프로그램 사용/busybox2009. 12. 2. 19:00
static / dhcp 로 변경하는 일련의 함수들을 만들었는데,

static -> interface 파일변경 -> ifdown -> ifup -> dhcp
dhcp -> interface 파일변경 -> ifdown -> ifup -> static

순서로 작동되도록 했는데,
static에서 dhcp로는 udhcp 프로세스가 이상없이 작동하는데
dhcp에서 static으로는 udhcp 프로세스가 죽지 않는다.

그래서 계속 순환하면 udhcp 프로세스가 쌓여간다(좀비는 아니고 Sleep 상태)


아무튼,

dhcp -> ifdown -> interface 파일변경 -> ifup -> static
으로 하니 제대로 작동한다.

아마 interface 파일 내용에
ifdown에 관련한 내용이 제대로 들어 있지않아 그랬던 것으로 보인다.


상관이 있을지 없을지 모르는 링크
[링크 : http://lists.busybox.net/pipermail/busybox/2007-July/062158.html]
Posted by 구차니
Linux API/network2009. 8. 18. 11:16
이 녀석들은 데비안 출신이었나?

5.3.5. The network interface with the static IP

The network interface served by the static IP is configured by creating the configuration entry in the "/etc/network/interfaces" file as the following.

allow-hotplug eth0
iface eth0 inet static
address 192.168.11.100
netmask 255.255.255.0
broadcast 192.168.11.255
gateway 192.168.11.1
dns-domain lan
dns-nameservers 192.168.11.1

When the Linux kernel detects the physical interface eth0, the allow-hotplug stanza will cause ifup to bring up the interface and the iface stanza will cause ifup to use the static IP to configure the interface.


[링크 : http://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_network_interface_with_the_static_ip]


간단하게 해석하자면, 물리적으로 연결이 되었음을 탐지하게 되면, 자동으로 설정을 실행한다는 의미이다.
(interface-eth0-를 up 시키고 iface구절을 실행함)


Check to see if a Network Link/Interface is up|down

ip link show eth0
//the iproute package is required. If there is no ip package, apt-get install iproute

If eth0 has a Network link, the following will be returned:
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:26:57:4e brd ff:ff:ff:ff:ff:ff

If eth0 has no Network link, the following will be returned:
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:26:57:4e brd ff:ff:ff:ff:ff:ff

The "UP" is the operative word.


[링크 : http://wiki.kartbuilding.net/index.php/Ifup-ifdown]


실제로 ifup, ifdown 시에 제대로 interface가 up / down 되었는지 확인하는 방법이다.
Posted by 구차니
프로그램 사용/u-boot2009. 8. 17. 18:34
busybox에서 라고 해야 하나,
아무튼, busybox의 경우에는 커널에서 부팅시에 ip를 설정한다.

TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
stmmaceth_open: MAC address 00:fa:e0:fa:e0:59
stmmac_init_phy: phy_id=0:03, phy_addr=0x3
IP-Config: Complete:
      device=eth0, addr=192.168.10.116, mask=255.255.255.0, gw=192.168.10.1,
     host=hmp_7109, domain=, nis-domain=(none),
     bootserver=255.255.255.255, rootserver=192.168.10.10, rootpath=
Looking up port of RPC 100003/2 on 192.168.10.10
PHY: 0:03 - Link is Up - 100/Full
Looking up port of RPC 100005/1 on 192.168.10.10
VFS: Mounted root (nfs filesystem) readonly.
Freeing unused kernel memory: 100k freed
  Vendor: AXXEN     Model: SKYMIRROR         Rev: 1.00
  Type:   Direct-Access                      ANSI SCSI revision: 02
SCSI device sda: 4016128 512-byte hdwr sectors (2056 MB)
sda: assuming Write Enabled
sda: assuming drive cache: write through
SCSI device sda: 4016128 512-byte hdwr sectors (2056 MB)
sda: assuming Write Enabled
sda: assuming drive cache: write through
 sda: sda1
sd 1:0:0:0: Attached scsi removable disk sda
Welcome to STLinux BusyBox system

머.. 이건 중요한게 아니고, 아무튼, ifdown을 통해서 죽이고
ifup을 통해서 올리려고 하는데, ifup시 static ip가 설정이 되지 않고
초기 kernel argument로 넘긴 값으로 부팅이 되는 문제가 있다.

검색을 해보니

Re: ETH0 already configured durring boot
The U-boot uses its own network driver and only the MAC address set up by the U-boot affects the network driver under Linux.

The network is started by the script /etc/init.d/networking in Debian/Emdebian distribution.  The soft links are used in each run level start up directories /etc/rcX.d, where X is run level 0, 1, 2, etc.  The normal run level is 3.  You can remove the link in the directory to disable the network start up.

The text file /etc/network/interfaces configures the network interfaces.  It should be something like,

auto eth0
iface eth0 inet dhcp

You can also just remove everything in this file to disable the automatic start up of the network.

[링크 : http://glomation.net/smf/index.php?topic=111.0]

라고 되어있는데, 일단 커널레벨에서 설정하는 것과는 별개의 문제이다.

# cat /etc/network/interfaces
######################################################################
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
#
# A "#" character in the very first column makes the rest of the line
# be ignored. Blank lines are ignored. Lines may be indented freely.
# A "\" character at the very end of the line indicates the next line
# should be treated as a continuation of the current one.
#
# The "pre-up", "up", "down" and "post-down" options are valid for all
# interfaces, and may be specified multiple times. All other options
# may only be specified once.
#
# See the interfaces(5) manpage for information on what options are
# available.
######################################################################

# We always want the loopback interface.
#
# auto lo
# iface lo inet loopback

# An example ethernet card setup: (broadcast and gateway are optional)
#
# auto eth0
# iface eth0 inet static
#     address 192.168.0.42
#     network 192.168.0.0
#     netmask 255.255.255.0
#     broadcast 192.168.0.255
#     gateway 192.168.0.1

# A more complicated ethernet setup, with a less common netmask, and a downright
# weird broadcast address: (the "up" lines are executed verbatim when the
# interface is brought up, the "down" lines when it's brought down)
#
# auto eth0
# iface eth0 inet static
#     address 192.168.1.42
#     network 192.168.1.0
#     netmask 255.255.255.128
#     broadcast 192.168.1.0
#     up route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.2
#     up route add default gw 192.168.1.200
#     down route del default gw 192.168.1.200
#     down route del -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.2

# A more complicated ethernet setup with a single ethernet card with
# two interfaces.
# Note: This happens to work since ifconfig handles it that way, not because
# ifup/down handles the ':' any differently.
# Warning: There is a known bug if you do this, since the state will not
# be properly defined if you try to 'ifdown eth0' when both interfaces
# are up. The ifconfig program will not remove eth0 but it will be
# removed from the interfaces state so you will see it up until you execute:
# 'ifdown eth0:1 ; ifup eth0; ifdown eth0'
# BTW, this is "bug" #193679 (it's not really a bug, it's more of a
# limitation)
#
# auto eth0 eth0:1
# iface eth0 inet static
#     address 192.168.0.100
#     network 192.168.0.0
#     netmask 255.255.255.0
#     broadcast 192.168.0.255
#     gateway 192.168.0.1
# iface eth0:1 inet static
#     address 192.168.0.200
#     network 192.168.0.0
#     netmask 255.255.255.0

# "pre-up" and "post-down" commands are also available. In addition, the
# exit status of these commands are checked, and if any fail, configuration
# (or deconfiguration) is aborted. So:
#
# auto eth0
# iface eth0 inet dhcp
#     pre-up [ -f /etc/network/local-network-ok ]
#
# will allow you to only have eth0 brought up when the file
# /etc/network/local-network-ok exists.

# Two ethernet interfaces, one connected to a trusted LAN, the other to
# the untrusted Internet. If their MAC addresses get swapped (because an
# updated kernel uses a different order when probing for network cards,
# say), then they don't get brought up at all.
#
# auto eth0 eth1
# iface eth0 inet static
#     address 192.168.42.1
#     netmask 255.255.255.0
#     pre-up /path/to/check-mac-address.sh eth0 11:22:33:44:55:66
#     pre-up /usr/local/sbin/enable-masq
# iface eth1 inet dhcp
#     pre-up /path/to/check-mac-address.sh eth1 AA:BB:CC:DD:EE:FF
#     pre-up /usr/local/sbin/firewall

# Two ethernet interfaces, one connected to a trusted LAN, the other to
# the untrusted Internet, identified by MAC address rather than interface
# name:
#
# auto eth0 eth1
# mapping eth0 eth1
#     script /path/to/get-mac-address.sh
#     map 11:22:33:44:55:66 lan
#     map AA:BB:CC:DD:EE:FF internet
# iface lan inet static
#     address 192.168.42.1
#     netmask 255.255.255.0
#     pre-up /usr/local/sbin/enable-masq $IFACE
# iface internet inet dhcp
#     pre-up /usr/local/sbin/firewall $IFACE

# A PCMCIA interface for a laptop that is used in different locations:
# (note the lack of an "auto" line for any of these)
#
# mapping eth0
#    script /path/to/pcmcia-compat.sh
#    map home,*,*,*                  home
#    map work,*,*,00:11:22:33:44:55  work-wireless
#    map work,*,*,01:12:23:34:45:50  work-static
#
# iface home inet dhcp
# iface work-wireless bootp
# iface work-static static
#     address 10.15.43.23
#     netmask 255.255.255.0
#     gateway 10.15.43.1
#
# Note, this won't work unless you specifically change the file
# /etc/pcmcia/network to look more like:
#
#     if [ -r ./shared ] ; then . ./shared ; else . /etc/pcmcia/shared ; fi
#     get_info $DEVICE
#     case "$ACTION" in
#         'start')
#             /sbin/ifup $DEVICE
#             ;;
#         'stop')
#             /sbin/ifdown $DEVICE
#             ;;
#     esac
#     exit 0

# An alternate way of doing the same thing: (in this case identifying
# where the laptop is is done by configuring the interface as various
# options, and seeing if a computer that is known to be on each particular
# network will respond to pings. The various numbers here need to be chosen
# with a great deal of care.)
#
# mapping eth0
#    script /path/to/ping-places.sh
#    map 192.168.42.254/24 192.168.42.1 home
#    map 10.15.43.254/24 10.15.43.1 work-wireless
#    map 10.15.43.23/24 10.15.43.1 work-static
#
# iface home inet dhcp
# iface work-wireless bootp
# iface work-static static
#     address 10.15.43.23
#     netmask 255.255.255.0
#     gateway 10.15.43.1
#
# Note that the ping-places script requires the iproute package installed,
# and the same changes to /etc/pcmcia/network are required for this as for
# the previous example.


# Set up an interface to read all the traffic on the network. This
# configuration can be useful to setup Network Intrusion Detection
# sensors in 'stealth'-type configuration. This prevents the NIDS
# system to be a direct target in a hostile network since they have
# no IP address on the network. Notice, however, that there have been
# known bugs over time in sensors part of NIDS (for example see
# DSA-297 related to Snort) and remote buffer overflows might even be
# triggered by network packet processing.
#
# auto eth0
# iface eth0 inet manual
#     up ifconfig $IFACE 0.0.0.0 up
#       up ip link set $IFACE promisc on
#       down ip link set $IFACE promisc off
#       down ifconfig $IFACE down

# Set up an interface which will not be allocated an IP address by
# ifupdown but will be configured through external programs. This
# can be useful to setup interfaces configured through other programs,
# like, for example, PPPOE scripts.
#
# auto eth0
# iface eth0 inet manual
#       up ifconfig $IFACE 0.0.0.0 up
#       up /usr/local/bin/myconfigscript
#       down ifconfig $IFACE down

/etc/network/interfaces는 ifup / ifdown 에서 사용하는 내용으로 저러면 된다는데...
결국 미궁이다.. 후우...

[링크 : http://www.annodex.net/cgi-bin/man/man2html?interfaces]
[링크 : http://www.annodex.net/cgi-bin/man/man2html?8+ifup]
[링크 : http://www.annodex.net/cgi-bin/man/man2html?8+ifdown]


Posted by 구차니