Browse Source

Decouple network setup

Change-Id: If49cd89f6624caf57c77b31642edd39ba8412bd7
Signed-off-by: Guo Ruijing <ruijing.guo@intel.com>
Guo Ruijing 2 years ago
parent
commit
133eadeac3
4 changed files with 46 additions and 54 deletions
  1. 13
    0
      demo/00_bootstrap.sh
  2. 4
    44
      demo/01_setup_redsocks.sh
  3. 16
    0
      demo/04_setup_fuel.sh
  4. 13
    10
      demo/README.md

+ 13
- 0
demo/00_bootstrap.sh View File

@@ -0,0 +1,13 @@
1
+#!/bin/sh
2
+
3
+HTTP_PROXY=${HTTP_PROXY:-http://proxy-chain.intel.com:911}
4
+cat <<EOF | sudo tee /etc/apt/apt.conf
5
+Acquire::http::Proxy "$HTTP_PROXY";
6
+EOF
7
+
8
+sudo apt-get update -y
9
+sudo apt-get install -y git
10
+
11
+git config --global http.proxy ${HTTP_PROXY}
12
+git clone https://github.com/openstack/fuel-plugin-ovs/
13
+git config --global --unset http.proxy

demo/01_setup_network.sh → demo/01_setup_redsocks.sh View File

@@ -1,38 +1,8 @@
1 1
 #!/bin/sh
2 2
 
3
-HTTP_PROXY=${HTTP_PROXY:-http://10.19.8.225:911}
4
-DNS_SERVER=${DNS_SERVER:-10.248.2.1}
5 3
 SOCKS5_IP=${SOCKS5_IP:-10.7.211.16}
6 4
 SOCKS5_PORT=${SOCKS5:-1080}
7
-
8
-for i in "$@"
9
-do
10
-case $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
-    ;;
30
-esac
31
-done
32
-
33
-cat <<EOF | sudo tee /etc/apt/apt.conf
34
-Acquire::http::Proxy "$HTTP_PROXY";
35
-EOF
5
+RED_TCPORT=${RED_TCPORT:-6666}
36 6
 
37 7
 sudo apt-get update -y
38 8
 sudo apt-get install redsocks -y
@@ -48,7 +18,7 @@ base {
48 18
 
49 19
 redsocks {
50 20
  local_ip = 0.0.0.0;
51
- local_port = 6666;
21
+ local_port = ${RED_TCPORT};
52 22
  ip = $SOCKS5_IP;
53 23
  port = $SOCKS5_PORT;
54 24
  type = socks5;
@@ -58,21 +28,12 @@ EOF
58 28
 
59 29
 sudo apt-get install iptables -y
60 30
 
61
-echo  1 | sudo tee /proc/sys/net/ipv4/ip_forward 
31
+echo  1 | sudo tee /proc/sys/net/ipv4/ip_forward
62 32
 
63 33
 sudo iptables -t filter -F
64 34
 sudo iptables -t mangle -F
65 35
 sudo iptables -t nat -F
66 36
 
67
-#DNS DNAT
68
-sudo iptables -t nat -A PREROUTING  -p udp --dport 53  -j DNAT --to-destination $DNS_SERVER
69
-
70
-#NTP DNAT
71
-sudo iptables -t nat -A PREROUTING  -p udp --dport 123 -j DNAT --to-destination 10.20.0.1
72
-
73
-sudo iptables -t nat -A POSTROUTING -s 10.20.0.0/24 -j MASQUERADE
74
-sudo iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
75
-
76 37
 sudo iptables -t nat -N REDSOCKS
77 38
 sudo iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
78 39
 sudo 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
82 43
 sudo iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
83 44
 sudo iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
84 45
 sudo iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
85
-sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 6666
86
-sudo iptables -t nat -A REDSOCKS -p udp -j REDIRECT --to-ports 9999
46
+sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports ${RED_TCPORT}
87 47
 sudo iptables -t nat -A OUTPUT -p tcp  -j REDSOCKS
88 48
 sudo iptables -t nat -A PREROUTING -p tcp  -j REDSOCKS
89 49
 

+ 16
- 0
demo/04_setup_fuel.sh View File

@@ -1,5 +1,7 @@
1 1
 #!/bin/bash
2 2
 
3
+DNS_SERVER=${DNS_SERVER:-10.248.2.1}
4
+
3 5
 #setup ntp server
4 6
 sudo service ntp restart
5 7
 
@@ -19,6 +21,20 @@ sudo ifconfig br-dpdk down
19 21
 sudo brctl delbr br-dpdk
20 22
 sudo brctl addbr br-dpdk
21 23
 
24
+sudo iptables -t nat -D PREROUTING  -j PRE_FUEL
25
+sudo iptables -t nat -N PRE_FUEL
26
+sudo iptables -t nat -F PRE_FUEL
27
+sudo iptables -t nat -A PRE_FUEL -p udp --dport 53  -j DNAT --to-destination $DNS_SERVER
28
+sudo iptables -t nat -A PRE_FUEL -p udp --dport 123 -j DNAT --to-destination 10.20.0.1
29
+sudo iptables -t nat -A PREROUTING  -j PRE_FUEL
30
+
31
+sudo iptables -t nat -D POSTROUTING  -j POST_FUEL
32
+sudo iptables -t nat -N POST_FUEL
33
+sudo iptables -t nat -F POST_FUEL
34
+sudo iptables -t nat -A POST_FUEL -s 10.20.0.0/24 -j MASQUERADE
35
+sudo iptables -t nat -A POST_FUEL -s 172.16.0.0/24 -j MASQUERADE
36
+sudo iptables -t nat -A POSTROUTING  -j POST_FUEL
37
+
22 38
 #setup master
23 39
 
24 40
 sudo virt-manager

+ 13
- 10
demo/README.md View File

@@ -19,19 +19,19 @@ the following scripts.
19 19
 Scripts
20 20
 -------
21 21
 
22
+0. 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
+
22 27
 1. 01_setup_network.sh
23 28
 
24 29
 The script is to setup socks5 proxy. You may change the script to support
25 30
 NAT. The following network setting is updated before running the script:
26 31
 
27
-a. HTTP_PROXY: proxy for package installation
28
-b. DNS_SERVER: DNS for fuel VM
29
-c. SOCK5_IP:  socks5 proxy for fuel VM
30
-d. SOCK5_PORT: socks5 proxy for fuel VM
31
-
32
-In fresh installation, 01_setup_network.sh can be run by:
33
-
34
-curl --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>
32
+a. SOCK5_IP:  socks5 proxy for fuel VM
33
+b. SOCK5_PORT: socks5 proxy for fuel VM
34
+b. RED_TCPORT: redsocks tcp port
35 35
 
36 36
 2. 02_install_packages.sh
37 37
 
@@ -43,8 +43,11 @@ The script is to setup vnc. Default vnc password is 123456.
43 43
 
44 44
 4. 04_setup_fuel.sh
45 45
 
46
-The script is to create 1 master VM and 4 slave VMs. Fuel ISO is copied to this
47
-directory before running the script.
46
+The script is to create 1 master VM and 4 slave VMs:
47
+
48
+a. change DNS_SERVER
49
+b. download ISO. Examle: http://seed-us1.fuel-infra.org/fuelweb-community-release/fuel-community-9.0.iso.
50
+c. run the script
48 51
 
49 52
 5. 05_destroy_fuel.sh
50 53
 

Loading…
Cancel
Save