summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuo Ruijing <ruijing.guo@intel.com>2016-06-03 05:17:32 +0800
committerGuo Ruijing <ruijing.guo@intel.com>2016-06-03 05:24:11 +0800
commit133eadeac3e24bba349fe3e5adde4bc3b08a9cb9 (patch)
tree74cf96d4b93cd0a477a0a0fe53b1f287eb62228a
parentd8399b6ea0de8af89d4fba88f91fa5336eba77ba (diff)
Decouple network setup
Change-Id: If49cd89f6624caf57c77b31642edd39ba8412bd7 Signed-off-by: Guo Ruijing <ruijing.guo@intel.com>
Notes
Notes (review): Code-Review+2: Ruijing <ruijing.guo@intel.com> Workflow+1: Ruijing <ruijing.guo@intel.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 03 Jun 2016 05:34:05 +0000 Reviewed-on: https://review.openstack.org/325048 Project: openstack/fuel-plugin-ovs Branch: refs/heads/master
-rwxr-xr-xdemo/00_bootstrap.sh13
-rwxr-xr-xdemo/01_setup_redsocks.sh (renamed from demo/01_setup_network.sh)48
-rwxr-xr-xdemo/04_setup_fuel.sh16
-rw-r--r--demo/README.md23
4 files changed, 46 insertions, 54 deletions
diff --git a/demo/00_bootstrap.sh b/demo/00_bootstrap.sh
new file mode 100755
index 0000000..fd9095e
--- /dev/null
+++ b/demo/00_bootstrap.sh
@@ -0,0 +1,13 @@
1#!/bin/sh
2
3HTTP_PROXY=${HTTP_PROXY:-http://proxy-chain.intel.com:911}
4cat <<EOF | sudo tee /etc/apt/apt.conf
5Acquire::http::Proxy "$HTTP_PROXY";
6EOF
7
8sudo apt-get update -y
9sudo apt-get install -y git
10
11git config --global http.proxy ${HTTP_PROXY}
12git clone https://github.com/openstack/fuel-plugin-ovs/
13git config --global --unset http.proxy
diff --git a/demo/01_setup_network.sh b/demo/01_setup_redsocks.sh
index fefac8f..d05f35b 100755
--- a/demo/01_setup_network.sh
+++ b/demo/01_setup_redsocks.sh
@@ -1,38 +1,8 @@
1#!/bin/sh 1#!/bin/sh
2 2
3HTTP_PROXY=${HTTP_PROXY:-http://10.19.8.225:911}
4DNS_SERVER=${DNS_SERVER:-10.248.2.1}
5SOCKS5_IP=${SOCKS5_IP:-10.7.211.16} 3SOCKS5_IP=${SOCKS5_IP:-10.7.211.16}
6SOCKS5_PORT=${SOCKS5:-1080} 4SOCKS5_PORT=${SOCKS5:-1080}
7 5RED_TCPORT=${RED_TCPORT:-6666}
8for i in "$@"
9do
10case $i in
11 -h=*|--http=*)
12 HTTP_PROXY="${i#*=}"
13 shift
14 ;;
15 -d=*|--dns=*)
16 DNS_SERVER="${i#*=}"
17 shift
18 ;;
19 -s=*|--socks5-ip=*)
20 SOCKS5_IP="${i#*=}"
21 shift
22 ;;
23 -p=*|--socks5-port=*)
24 SOCKS5_PORT="${i#*=}"
25 shift
26 ;;
27 *)
28 # unknown option
29 ;;
30esac
31done
32
33cat <<EOF | sudo tee /etc/apt/apt.conf
34Acquire::http::Proxy "$HTTP_PROXY";
35EOF
36 6
37sudo apt-get update -y 7sudo apt-get update -y
38sudo apt-get install redsocks -y 8sudo apt-get install redsocks -y
@@ -48,7 +18,7 @@ base {
48 18
49redsocks { 19redsocks {
50 local_ip = 0.0.0.0; 20 local_ip = 0.0.0.0;
51 local_port = 6666; 21 local_port = ${RED_TCPORT};
52 ip = $SOCKS5_IP; 22 ip = $SOCKS5_IP;
53 port = $SOCKS5_PORT; 23 port = $SOCKS5_PORT;
54 type = socks5; 24 type = socks5;
@@ -58,21 +28,12 @@ EOF
58 28
59sudo apt-get install iptables -y 29sudo apt-get install iptables -y
60 30
61echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward 31echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
62 32
63sudo iptables -t filter -F 33sudo iptables -t filter -F
64sudo iptables -t mangle -F 34sudo iptables -t mangle -F
65sudo iptables -t nat -F 35sudo iptables -t nat -F
66 36
67#DNS DNAT
68sudo iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to-destination $DNS_SERVER
69
70#NTP DNAT
71sudo iptables -t nat -A PREROUTING -p udp --dport 123 -j DNAT --to-destination 10.20.0.1
72
73sudo iptables -t nat -A POSTROUTING -s 10.20.0.0/24 -j MASQUERADE
74sudo iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
75
76sudo iptables -t nat -N REDSOCKS 37sudo iptables -t nat -N REDSOCKS
77sudo iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN 38sudo iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
78sudo iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN 39sudo iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
@@ -82,8 +43,7 @@ sudo iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
82sudo iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN 43sudo iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
83sudo iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN 44sudo iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
84sudo iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN 45sudo iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
85sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 6666 46sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports ${RED_TCPORT}
86sudo iptables -t nat -A REDSOCKS -p udp -j REDIRECT --to-ports 9999
87sudo iptables -t nat -A OUTPUT -p tcp -j REDSOCKS 47sudo iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
88sudo iptables -t nat -A PREROUTING -p tcp -j REDSOCKS 48sudo iptables -t nat -A PREROUTING -p tcp -j REDSOCKS
89 49
diff --git a/demo/04_setup_fuel.sh b/demo/04_setup_fuel.sh
index acb884c..3e6cc50 100755
--- a/demo/04_setup_fuel.sh
+++ b/demo/04_setup_fuel.sh
@@ -1,5 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2 2
3DNS_SERVER=${DNS_SERVER:-10.248.2.1}
4
3#setup ntp server 5#setup ntp server
4sudo service ntp restart 6sudo service ntp restart
5 7
@@ -19,6 +21,20 @@ sudo ifconfig br-dpdk down
19sudo brctl delbr br-dpdk 21sudo brctl delbr br-dpdk
20sudo brctl addbr br-dpdk 22sudo brctl addbr br-dpdk
21 23
24sudo iptables -t nat -D PREROUTING -j PRE_FUEL
25sudo iptables -t nat -N PRE_FUEL
26sudo iptables -t nat -F PRE_FUEL
27sudo iptables -t nat -A PRE_FUEL -p udp --dport 53 -j DNAT --to-destination $DNS_SERVER
28sudo iptables -t nat -A PRE_FUEL -p udp --dport 123 -j DNAT --to-destination 10.20.0.1
29sudo iptables -t nat -A PREROUTING -j PRE_FUEL
30
31sudo iptables -t nat -D POSTROUTING -j POST_FUEL
32sudo iptables -t nat -N POST_FUEL
33sudo iptables -t nat -F POST_FUEL
34sudo iptables -t nat -A POST_FUEL -s 10.20.0.0/24 -j MASQUERADE
35sudo iptables -t nat -A POST_FUEL -s 172.16.0.0/24 -j MASQUERADE
36sudo iptables -t nat -A POSTROUTING -j POST_FUEL
37
22#setup master 38#setup master
23 39
24sudo virt-manager 40sudo virt-manager
diff --git a/demo/README.md b/demo/README.md
index a19525e..474c15e 100644
--- a/demo/README.md
+++ b/demo/README.md
@@ -19,19 +19,19 @@ the following scripts.
19Scripts 19Scripts
20------- 20-------
21 21
220. 00_bootstrap.sh
23 a. copy from https://raw.githubusercontent.com/openstack/fuel-plugin-ovs/master/demo/00_bootstrap.sh
24 b. change HTTP_PROXY
25 c. run the script
26
221. 01_setup_network.sh 271. 01_setup_network.sh
23 28
24The script is to setup socks5 proxy. You may change the script to support 29The script is to setup socks5 proxy. You may change the script to support
25NAT. The following network setting is updated before running the script: 30NAT. The following network setting is updated before running the script:
26 31
27a. HTTP_PROXY: proxy for package installation 32a. SOCK5_IP: socks5 proxy for fuel VM
28b. DNS_SERVER: DNS for fuel VM 33b. SOCK5_PORT: socks5 proxy for fuel VM
29c. SOCK5_IP: socks5 proxy for fuel VM 34b. RED_TCPORT: redsocks tcp port
30d. SOCK5_PORT: socks5 proxy for fuel VM
31
32In fresh installation, 01_setup_network.sh can be run by:
33
34curl --socks5 <socks5-proxy> https://raw.githubusercontent.com/openstack/fuel-plugin-ovs/master/demo/01_setup_network.sh | bash -s -- -h=<http-proxy>-d=<dns-server> -s=<socks5-ip> -p=<socks5-port>
35 35
362. 02_install_packages.sh 362. 02_install_packages.sh
37 37
@@ -43,8 +43,11 @@ The script is to setup vnc. Default vnc password is 123456.
43 43
444. 04_setup_fuel.sh 444. 04_setup_fuel.sh
45 45
46The script is to create 1 master VM and 4 slave VMs. Fuel ISO is copied to this 46The script is to create 1 master VM and 4 slave VMs:
47directory before running the script. 47
48a. change DNS_SERVER
49b. download ISO. Examle: http://seed-us1.fuel-infra.org/fuelweb-community-release/fuel-community-9.0.iso.
50c. run the script
48 51
495. 05_destroy_fuel.sh 525. 05_destroy_fuel.sh
50 53