# brctl show bridge name bridge id STP enabled interfaces br0 8000.000c293e6326 yes eth0 isolationbr 8000.000000000000 no virbr0 8000.525400305441 yes virbr0-nic
# ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen1000 link/ether 00:0c:29:3e:63:26 brd ff:ff:ff:ff:ff:ff 3: br0:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN link/ether 00:0c:29:3e:63:26 brd ff:ff:ff:ff:ff:ff 4: virbr0:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN link/ether 52:54:00:30:54:41 brd ff:ff:ff:ff:ff:ff 5: virbr0-nic: <BROADCAST,MULTICAST>mtu 1500 qdisc noop state DOWN qlen 500 link/ether 52:54:00:30:54:41 brd ff:ff:ff:ff:ff:ff 16: isolationbr:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN link/ether 6e:5e:8d:39:56:b5 brd ff:ff:ff:ff:ff:ff 17: vnet1:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWNqlen 500 link/ether 3a:ce:49:1d:f4:a3 brd ff:ff:ff:ff:ff:ff 18: vnet2:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWNqlen 500 link/ether 62:fc:96:5c:1f:7d brd ff:ff:ff:ff:ff:ff
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c293e6326 yes eth0
vnet1
vnet2
isolationbr 8000.000000000000 no
virbr0 8000.525400305441 yes virbr0-nic
# brctl delif br0 vnet1 # brctl delif br0 vnet2
# brctl show bridge name bridge id STP enabled interfaces br0 8000.000c293e6326 yes eth0 isolationbr 8000.000000000000 no virbr0 8000.525400305441 yes virbr0-nic
# brctl addif isolationbr vnet1 # brctl addif isolationbr vnet2
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c293e6326 yes eth0
isolationbr 8000.3ace491df4a3 no vnet1
vnet2
virbr0 8000.525400305441 yes virbr0-nic
[root@createOS ~]# ifconfig isolationbr 10.0.0.254/8 up
[root@createOS ~]# ifconfig isolationbr
isolationbr Link encap:Ethernet HWaddr 3A:CE:49:1D:F4:A3
inet addr:10.0.0.254 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::6c5e:8dff:fe39:56b5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1 errors:0 dropped:0overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:28 (28.0 b) TX bytes:468(468.0 b)
# sysctl -w net.ipv4.ip_forward=1 net.ipv4.ip_forward = 1
# tcpdump -i eth0 icmp -nn tcpdump: WARNING: eth0: no IPv4 addressassigned tcpdump: verbose output suppressed, use -vor -vv for full protocol decode listening on eth0, link-type EN10MB(Ethernet), capture size 65535 bytes 10:24:52.377558 IP 10.0.0.2 >172.16.0.1: ICMP echo request, id 1793, seq 0, length 64 10:24:53.384063 IP 10.0.0.2 >172.16.0.1: ICMP echo request, id 1793, seq 1, length 64
# iptables -t nat -A POSTROUTING -s 10.0.0.0/8 ! -d 10.0.0.0/8 -j MASQUERADE # iptables -t nat -L POSTROUTING Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE tcp -- 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535 MASQUERADE udp -- 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535 MASQUERADE all -- 192.168.122.0/24 !192.168.122.0/24 MASQUERADE all -- 10.0.0.0/8 !10.0.0.0/8
# tcpdump -i isolationbr -nn tcpdump: verbose output suppressed, use -vor -vv for full protocol decode listening on isolationbr, link-type EN10MB(Ethernet), capture size 65535 bytes 10:35:35.391069 IP 10.0.0.2 >172.16.0.1: ICMP echo request, id 2305, seq 0, length 64 10:35:35.393619 ARP, Request who-has10.0.0.2 tell 10.0.0.254, length 28 10:35:35.395095 ARP, Reply 10.0.0.2 is-at52:54:00:65:43:21, length 28 10:35:35.395137 IP 172.16.0.1 >10.0.0.2: ICMP echo reply, id 2305, seq 0, length 64 10:35:36.394760 IP 10.0.0.2 >172.16.0.1: ICMP echo request, id 2305, seq 1, length 64 10:35:36.395943 IP 172.16.0.1 >10.0.0.2: ICMP echo reply, id 2305, seq 1, length 64 10:35:41.426182 ARP, Request who-has10.0.0.254 tell 10.0.0.2, length 28 10:35:41.427695 ARP, Reply 10.0.0.254 is-at3a:ce:49:1d:f4:a3, length 28
# tcpdump -i eth0 icmp -nn tcpdump: WARNING: eth0: no IPv4 addressassigned tcpdump: verbose output suppressed, use -vor -vv for full protocol decode listening on eth0, link-type EN10MB(Ethernet), capture size 65535 bytes 10:35:35.392027 IP 172.16.31.7 >172.16.0.1: ICMP echo request, id 2305, seq 0, length 64 10:35:35.393361 IP 172.16.0.1 >172.16.31.7: ICMP echo reply, id 2305, seq 0, length 64 10:35:36.395052 IP 172.16.31.7 >172.16.0.1: ICMP echo request, id 2305, seq 1, length 64 10:35:36.395860 IP 172.16.0.1 >172.16.31.7: ICMP echo reply, id 2305, seq 1, length 64
#vim /etc/qemu-natup
#!/bin/bash
BRIDGE=isolationbr
NETWORK=10.0.0.0
GATEWAY=10.0.0.254
NETMASK=255.0.0.0
DHCPRANGE=10.0.0.1,10.0.0.100
TFTPROOT=
BOOTP=
function check_bridge()
{
if brctl show | grep "^BRIDGE"&> /dev/null;then
return 1
else
return 0
fi
}
function create_bridge()
{
brctl addbr "BRIDGE"
brctl stp "BRIDGE" on
brctl setfd "BRIDGE" 0
ifconfig "$BRIDGE""GATEWAY" netmask "$NETMASK" up
}
function enable_ip_forward()
{
echo 1 > /proc/sys/net/ipv4/ip_forward
}
function add_filter_rules()
{
iptables -t nat -A POSTROUTING -s"$NETWORK"/"$NETMASK" ! -d"$NETWORK"/"$NETMASK" -j MASQUERADE
}
function start_dnsmasq()
{
ps -ef | grep "dnsmasq" |grep -v"grep" &> /dev/null
if [ $? -eq 0 ];then
echo "warning:dnsmasq is already running"
return 1
fi
dnsmasq --strict-order--except-interface=lo --interface=$BRIDGE --listen-address=$GATEWAY--bind-interfaces --dhcp-range=$DHCPRANGE --conf-file=""--pid-file=/var/run/qemu-dhcp-$BRIDGE.pid --dhcp-leasefile=/var/run/qemu-dhcp-$BRIDGE.leases--dhcp-no-override ${TFTPROOT:+"--enable-tftp"}${TFTPROOT:+"--tftp-root=$TFTPROOT"}${BOOTP:+"--dhcp-boot=$BOOTP"}
}
function setup_bridge_nat()
{
check_bridge "$BRIDGE"
if [ $? -eq 0 ];then
create_bridge
fi
enable_ip_forward
add_filter_rules "$BRIDGE"
start_dnsmasq "$BRIDGE"
}
if [ -n "$1" ];then
setup_bridge_nat
ifconfig "$1" 0.0.0.0 up
brctl addif "$BRIDGE""$1"
exit 0
else
echo "Error:no interfacespecified"
exit 1
fi
#vim /etc/qemu-natdown
#!/bin/bash
BRIDGE="isolotionbr"
if [ -n "$1" ];then
ip link set $1 down
brctl delif "$BRIDGE" $1
ip link set "$BRIDGE" down
brctl delbr "$BRIDGE"
iptables -t nat -F
exit 0
else
echo "Error: no interface specified"
exit 1
fi
# chmod +x /etc/qemu-natup # chmod +x /etc/qemu-natdown
# ps -ef | grep "dnsmasq" |grep-v "grep" nobody 38355 1 0 11:49 ? 00:00:00 dnsmasq --strict-order--except-interface=lo --interface=isolationbr --listen-address=10.0.0.254--bind-interfaces --dhcp-range=10.0.0.1,10.0.0.100 --conf-file=--pid-file=/var/run/qemu-dhcp-isolationbr.pid--dhcp-leasefile=/var/run/qemu-dhcp-isolationbr.leases --dhcp-no-override
# ifconfig |grep -Ei"(vnet1|vnet2)" vnet1 Link encap:Ethernet HWaddr16:85:A7:5C:84:9D vnet2 Link encap:Ethernet HWaddrE6:81:C9:31:4F:78
#iptables -t nat -L POSTROUTING Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE all -- 10.0.0.0/8 !10.0.0.0/8
# tcpdump -i isolationbr -nn tcpdump: verbose output suppressed, use -vor -vv for full protocol decode listening on isolationbr, link-type EN10MB(Ethernet), capture size 65535 bytes 12:05:14.655667 IP 10.0.0.83 >172.16.0.1: ICMP echo request, id 257, seq 0, length 64 12:05:14.658466 IP 172.16.0.1 >10.0.0.83: ICMP echo reply, id 257, seq 0, length 64 12:05:15.657273 IP 10.0.0.83 >172.16.0.1: ICMP echo request, id 257, seq 1, length 64 12:05:15.658252 IP 172.16.0.1 >10.0.0.83: ICMP echo reply, id 257, seq 1, length 64 12:05:19.659800 ARP, Request who-has10.0.0.83 tell 10.0.0.254, length 28 12:05:19.661522 ARP, Request who-has10.0.0.254 tell 10.0.0.83, length 28 12:05:19.661569 ARP, Reply 10.0.0.254 is-at16:85:a7:5c:84:9d, length 28 12:05:19.662053 ARP, Reply 10.0.0.83 is-at52:54:00:88:88:88, length 28 12:05:47.759101 ARP, Request who-has10.0.0.47 tell 10.0.0.83, length 28 12:05:47.760926 ARP, Reply 10.0.0.47 is-at52:54:00:12:34:56, length 28 12:05:47.761579 IP 10.0.0.83 >10.0.0.47: ICMP echo request, id 513, seq 0, length 64 12:05:47.765075 IP 10.0.0.47 >10.0.0.83: ICMP echo reply, id 513, seq 0, length 64 12:05:48.759703 IP 10.0.0.83 >10.0.0.47: ICMP echo request, id 513, seq 1, length 64 12:05:48.760848 IP 10.0.0.47 >10.0.0.83: ICMP echo reply, id 513, seq 1, length 64 12:05:52.775287 ARP, Request who-has10.0.0.83 tell 10.0.0.47, length 28 12:05:52.776601 ARP, Reply 10.0.0.83 is-at52:54:00:88:88:88, length 28 12:05:59.376454 IP 10.0.0.83 >172.16.31.7: ICMP echo request, id 769, seq 0, length 64 12:05:59.376548 IP 172.16.31.7 >10.0.0.83: ICMP echo reply, id 769, seq 0, length 64 12:06:00.482899 IP 10.0.0.83 >172.16.31.7: ICMP echo request, id 769, seq 1, length 64 12:06:00.483035 IP 172.16.31.7 >10.0.0.83: ICMP echo reply, id 769, seq 1, length 64 12:06:04.376987 ARP, Request who-has10.0.0.83 tell 10.0.0.254, length 28 12:06:04.378153 ARP, Reply 10.0.0.83 is-at52:54:00:88:88:88, length 28
# tcpdump -i eth0 icmp -nn tcpdump: WARNING: eth0: no IPv4 addressassigned tcpdump: verbose output suppressed, use -vor -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet),capture size 65535 bytes 12:05:14.657680 IP 172.16.31.7 >172.16.0.1: ICMP echo request, id 257, seq 0, length 64 12:05:14.658427 IP 172.16.0.1 >172.16.31.7: ICMP echo reply, id 257, seq 0, length 64 12:05:15.657329 IP 172.16.31.7 >172.16.0.1: ICMP echo request, id 257, seq 1, length 64 12:05:15.658215 IP 172.16.0.1 >172.16.31.7: ICMP echo reply, id 257, seq 1, length 64
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有