스크립트 설정 사용 시 브리지 작업 문제

스크립트 설정 사용 시 브리지 작업 문제

나는 본질적으로 내 기계를 스위치로 바꾸는 다리를 만들려고 노력하고 있습니다.

INTERFACES='br0'인터페이스 설정과 동일한 컴퓨터에서 DHCP 서버를 실행하고 있습니다.

/etc/network/interfaces다음과 같습니다.

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
auto eth1
iface eth1 inet manual
auto wlan0
iface wlan0 inet manual

auto br0
iface br0 inet static
    bridge_ports eth0 eth1 wlan0
    address 10.1.36.10
    netmask 255.255.255.0
    network 10.1.36.0
    broadcast 10.1.36.255

수동으로 구성하면 모든 것이 잘 작동합니다.

그런 다음 동일한 방식으로 많은 시스템을 구성해야 하므로 이를 설정하기 위한 bash 스크립트를 작성했습니다.

echo "Setting up Static IP..."
if [ $(ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d' | wc -l) -gt 1 ]
then
   BRIDGE_PORTS=""
   for i in $(ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'); do
       sudo echo "auto $i" | sudo tee -a  /etc/network/interfaces
       sudo echo "iface $i inet manual" | sudo tee -a  /etc/network/interfaces
       BRIDGE_PORTS="$BRIDGE_PORTS $i "
   done
   sudo echo "auto br0" | sudo tee -a  /etc/network/interfaces
   sudo echo "iface br0 inet static" | sudo tee -a  /etc/network/interfaces
   sudo echo "bridge_ports $BRIDGE_PORTS" | sudo tee -a  /etc/network/interfaces
   sudo echo "address $STATIC_IP" | sudo tee -a  /etc/network/interfaces
   sudo echo "netmask 255.255.255.0" | sudo tee -a  /etc/network/interfaces
   sudo echo "network $NETWORK_IP" | sudo tee -a  /etc/network/interfaces
   sudo echo "broadcast $BROADCAST_IP" | sudo tee -a  /etc/network/interfaces
   DHCP_INTERFACE="br0"
else
   sudo echo "auto eth0" | sudo tee -a  /etc/network/interfaces
   sudo echo "iface eth0 inet static" | sudo tee -a  /etc/network/interfaces
   sudo echo "address $STATIC_IP" | sudo tee -a  /etc/network/interfaces
   sudo echo "netmask 255.255.255.0" | sudo tee -a  /etc/network/interfaces
   sudo echo "network $NETWORK_IP" | sudo tee -a  /etc/network/interfaces
   sudo echo "broadcast $BROADCAST_IP" | sudo tee -a  /etc/network/interfaces
   DHCP_INTERFACE="eth0"
fi

이유는 모르겠지만 스크립트를 사용하여 브리지를 설정할 때 eth0 또는 eth1 인터페이스가 포함되지 않습니다.

내가 실행하면 ip addr다음과 같은 결과를 얻습니다.

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
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 
   valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default      qlen 1000
link/ether 78:d0:04:20:b9:6c brd ff:ff:ff:ff:ff:ff
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 78:d0:04:20:b9:6d brd ff:ff:ff:ff:ff:ff
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
link/ether c4:d9:87:8e:72:f9 brd ff:ff:ff:ff:ff:ff
inet6 fe80::c6d9:87ff:fe8e:72f9/64 scope link 
   valid_lft forever preferred_lft forever
5: mon.wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN group default qlen 1000
link/ieee802.11/radiotap c4:d9:87:8e:72:f9 brd ff:ff:ff:ff:ff:ff
6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
link/ether c4:d9:87:8e:72:f9 brd ff:ff:ff:ff:ff:ff
inet 10.1.36.10/24 brd 10.1.36.255 scope global br0
   valid_lft forever preferred_lft forever
inet6 fe80::c6d9:87ff:fe8e:72f9/64 scope link 
   valid_lft forever preferred_lft forever

eth0과 eth1에는 br0이 마스터로 없습니다! 왜 그런 겁니까?

관련 정보