[root@localhost ~]# yum -y install bridge-utils [root@localhost ~]# vi /etc/sysctl.conf <- 커널의 파라미터 변수의 변경 부팅 시 변경됨
# Kernel sysctl configuration file for Red Hat Linux # # For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and # sysctl.conf(5) for more details.
# Controls IP packet forwarding net.ipv4.ip_forward = 1
# Controls source route verification net.ipv4.conf.default.rp_filter = 1
....
[root@localhost ~]# cat /proc/sys/net/ipv4/ip_forward <- 강제로 지금 포워드 시키기 위해 1로 수정 0 [root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward [root@localhost ~]# cat /proc/sys/net/ipv4/ip_forward 1 [root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-eth0 ifcfg-br0 [root@localhost network-scripts]# vi ifcfg-br0
======================== DEVICE=br0 TYPE=Bridge BOOTPROTO=none ONBOOT=yes IPADDR=192.168.100.128 NETMASK=255.255.255.0 NETWORK=192.168.100.0 BROADCAST=192.168.100.255 ========================
[root@localhost network-scripts]# vi ifcfg-eth0 ======================== DEVICE=eth0 BRIDGE=br0 ONBOOT=yes ========================
[root@localhost network-scripts]# vi ifcfg-eth1 ======================== DEVICE=eth1 BRIDGE=br0 ONBOOT=yes ========================
[root@localhost network-scripts]# /etc/init.d/network restart Shutting down interface eth0: bridge br0 does not exist! [ OK ] Shutting down interface eth1: bridge br0 does not exist! [ OK ] Shutting down loopback interface: [ OK ] Disabling IPv4 packet forwarding: net.ipv4.ip_forward = 0 [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: [ OK ] Bringing up interface eth1: [ OK ] Bringing up interface br0: [ OK ]
아이피를 확인하게 되면 br0이 활성화 되고 eth0,1가 떠야 한다.
[root@localhost network-scripts]# ifconfig br0 Link encap:Ethernet HWaddr 00:0C:29:19:D5:33 inet addr:192.168.100.128 Bcast:192.168.100.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:13 errors:0 dropped:0 overruns:0 frame:0 TX packets:27 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:994 (994.0 b) TX bytes:5666 (5.5 KiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:19:D5:33 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1345 errors:0 dropped:0 overruns:0 frame:0 TX packets:1206 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:155144 (151.5 KiB) TX bytes:181876 (177.6 KiB) Interrupt:67 Base address:0x2000
eth1 Link encap:Ethernet HWaddr 00:0C:29:19:D5:3D UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:98 errors:0 dropped:0 overruns:0 frame:0 TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:8028 (7.8 KiB) TX bytes:3014 (2.9 KiB) Interrupt:67 Base address:0x2080
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:4 errors:0 dropped:0 overruns:0 frame:0 TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2304 (2.2 KiB) TX bytes:2304 (2.2 KiB)
brctl show 명령어를 이용하여 브릿지의 목록을 확인 한다.
[root@localhost network-scripts]# brctl show bridge name bridge id STP enabled interfaces br0 8000.000c2919d533 no eth1 eth0
만약 지금 iptables 에 체인이 걸려 있다면 iptables -F 를 이용하여 해제 한다. iptables 를 이용하여 Forward 를 걸어 줘야 한다.
[root@localhost network-scripts]# iptables -nvL Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination
Centos(Guest2~4) 을 다음과 같이 firewall 에 접근 하도록 한다.
브릿지 방화벽에 물려 있는 패킷을 제어 하기 위해서 방화벽에서 iptables 를 이용하여 패킷을 제어 가능하다.
[root@localhost network-scripts]# iptables -A FORWARD -j DROP
제대로 설정 되었다면 guest pc에서는 ping 이 안나가는 것을 확인 할 수 있다.
실습> 브릿지 방화벽 에서 iptables 를 이용하여 guestpc의 제어
다음과 같이 host pc(192.168.100.1) 에서 icmp 패킷을 보낼 경우 다음과 같이 tcpdump 를 통하여, 브릿지 방화벽에서 확인이 가능하다. 즉, 정상적으로 FORWARD가 되고 있다.
[Bridge_Firewall] tcpdump dst 192.168.100.129 tcpdump: WARNING: eth0: no IPv4 address assigned tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 17:18:42.995209 IP 192.168.100.1 > 192.168.100.129: ICMP echo request, id 512, seq 2304, length 40 17:18:43.995925 IP 192.168.100.1 > 192.168.100.129: ICMP echo request, id 512, seq 2560, length 40 17:18:44.996926 IP 192.168.100.1 > 192.168.100.129: ICMP echo request, id 512, seq 2816, length 40 17:18:45.997975 IP 192.168.100.1 > 192.168.100.129: ICMP echo request, id 512, seq 3072, length 40 17:18:47.995456 arp reply 192.168.100.1 is-at 00:50:56:c0:00:08 (oui Unknown)
Guest pc3대의 모든 ip 에 대한 포트정보를 확인 하려면 다음과 같이 or를 붙여 사용이 용이하다.
[Bridge_Firewall] tcpdump dst 192.168.100.130 or 192.168.100.131 or 192.168.100.129 tcpdump: WARNING: eth0: no IPv4 address assigned tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 17:25:22.872333 IP 192.168.100.1.l3-hbmon > 192.168.100.129.ssh: P 3837455752:3837455788(36) ack 3987336542 win 65467 17:25:23.530974 arp reply 192.168.100.1 is-at 00:50:56:c0:00:08 (oui Unknown) 17:25:25.954056 arp reply 192.168.100.1 is-at 00:50:56:c0:00:08 (oui Unknown) 17:25:26.487926 IP 192.168.100.1 > 192.168.100.129: ICMP echo request, id 512, seq 10496, length 17:25:27.489169 IP 192.168.100.1 > 192.168.100.129: ICMP echo request, id 512, seq 10752, length 17:25:27.872060 arp reply 192.168.100.1 is-at 00:50:56:c0:00:08 (oui Unknown) 17:25:29.491237 IP 192.168.100.1 > 192.168.100.129: ICMP echo request, id 512, seq 11264, length 17:25:32.154302 IP 192.168.100.1 > 192.168.100.130: ICMP echo request, id 512, seq 11520, length
Guest pc 의 방화벽을 모두 내리고 브릿지 방화벽이서 제어 가능하도록 다음과 같이 설정 한다.
[root@localhost ~]# /etc/init.d/iptables stop [root@localhost ~]# chkconfig iptables off [root@localhost ~]# chkconfig --list iptables
|