Decouple network setup

Change-Id: If49cd89f6624caf57c77b31642edd39ba8412bd7
Signed-off-by: Guo Ruijing <ruijing.guo@intel.com>
This commit is contained in:
Guo Ruijing 2016-06-03 05:17:32 +08:00
parent d8399b6ea0
commit 133eadeac3
4 changed files with 46 additions and 54 deletions

13
demo/00_bootstrap.sh Executable file
View File

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

View File

@ -1,38 +1,8 @@
#!/bin/sh
HTTP_PROXY=${HTTP_PROXY:-http://10.19.8.225:911}
DNS_SERVER=${DNS_SERVER:-10.248.2.1}
SOCKS5_IP=${SOCKS5_IP:-10.7.211.16}
SOCKS5_PORT=${SOCKS5:-1080}
for i in "$@"
do
case $i in
-h=*|--http=*)
HTTP_PROXY="${i#*=}"
shift
;;
-d=*|--dns=*)
DNS_SERVER="${i#*=}"
shift
;;
-s=*|--socks5-ip=*)
SOCKS5_IP="${i#*=}"
shift
;;
-p=*|--socks5-port=*)
SOCKS5_PORT="${i#*=}"
shift
;;
*)
# unknown option
;;
esac
done
cat <<EOF | sudo tee /etc/apt/apt.conf
Acquire::http::Proxy "$HTTP_PROXY";
EOF
RED_TCPORT=${RED_TCPORT:-6666}
sudo apt-get update -y
sudo apt-get install redsocks -y
@ -48,7 +18,7 @@ base {
redsocks {
local_ip = 0.0.0.0;
local_port = 6666;
local_port = ${RED_TCPORT};
ip = $SOCKS5_IP;
port = $SOCKS5_PORT;
type = socks5;
@ -58,21 +28,12 @@ EOF
sudo apt-get install iptables -y
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo iptables -t filter -F
sudo iptables -t mangle -F
sudo iptables -t nat -F
#DNS DNAT
sudo iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to-destination $DNS_SERVER
#NTP DNAT
sudo iptables -t nat -A PREROUTING -p udp --dport 123 -j DNAT --to-destination 10.20.0.1
sudo iptables -t nat -A POSTROUTING -s 10.20.0.0/24 -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
sudo iptables -t nat -N REDSOCKS
sudo iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
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
sudo iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 6666
sudo iptables -t nat -A REDSOCKS -p udp -j REDIRECT --to-ports 9999
sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports ${RED_TCPORT}
sudo iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
sudo iptables -t nat -A PREROUTING -p tcp -j REDSOCKS

View File

@ -1,5 +1,7 @@
#!/bin/bash
DNS_SERVER=${DNS_SERVER:-10.248.2.1}
#setup ntp server
sudo service ntp restart
@ -19,6 +21,20 @@ sudo ifconfig br-dpdk down
sudo brctl delbr br-dpdk
sudo brctl addbr br-dpdk
sudo iptables -t nat -D PREROUTING -j PRE_FUEL
sudo iptables -t nat -N PRE_FUEL
sudo iptables -t nat -F PRE_FUEL
sudo iptables -t nat -A PRE_FUEL -p udp --dport 53 -j DNAT --to-destination $DNS_SERVER
sudo iptables -t nat -A PRE_FUEL -p udp --dport 123 -j DNAT --to-destination 10.20.0.1
sudo iptables -t nat -A PREROUTING -j PRE_FUEL
sudo iptables -t nat -D POSTROUTING -j POST_FUEL
sudo iptables -t nat -N POST_FUEL
sudo iptables -t nat -F POST_FUEL
sudo iptables -t nat -A POST_FUEL -s 10.20.0.0/24 -j MASQUERADE
sudo iptables -t nat -A POST_FUEL -s 172.16.0.0/24 -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -j POST_FUEL
#setup master
sudo virt-manager

View File

@ -19,19 +19,19 @@ the following scripts.
Scripts
-------
0. 00_bootstrap.sh
a. copy from https://raw.githubusercontent.com/openstack/fuel-plugin-ovs/master/demo/00_bootstrap.sh
b. change HTTP_PROXY
c. run the script
1. 01_setup_network.sh
The script is to setup socks5 proxy. You may change the script to support
NAT. The following network setting is updated before running the script:
a. HTTP_PROXY: proxy for package installation
b. DNS_SERVER: DNS for fuel VM
c. SOCK5_IP: socks5 proxy for fuel VM
d. SOCK5_PORT: socks5 proxy for fuel VM
In fresh installation, 01_setup_network.sh can be run by:
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>
a. SOCK5_IP: socks5 proxy for fuel VM
b. SOCK5_PORT: socks5 proxy for fuel VM
b. RED_TCPORT: redsocks tcp port
2. 02_install_packages.sh
@ -43,8 +43,11 @@ The script is to setup vnc. Default vnc password is 123456.
4. 04_setup_fuel.sh
The script is to create 1 master VM and 4 slave VMs. Fuel ISO is copied to this
directory before running the script.
The script is to create 1 master VM and 4 slave VMs:
a. change DNS_SERVER
b. download ISO. Examle: http://seed-us1.fuel-infra.org/fuelweb-community-release/fuel-community-9.0.iso.
c. run the script
5. 05_destroy_fuel.sh