Skip to content

Instantly share code, notes, and snippets.

@xemoe
Last active March 14, 2016 15:51
Show Gist options
  • Save xemoe/8fe8764a0e6ae76b796d to your computer and use it in GitHub Desktop.
Save xemoe/8fe8764a0e6ae76b796d to your computer and use it in GitHub Desktop.
Network configure
#!/bin/bash
#
# Configure network interfaces scripts
# Ansible managed: /vagrant/005-application/roles/sran.network-interfaces/templates/configure-network-interfaces.sh.j2 modified on 2016-03-14 22:42:44 by vagrant on ubuntu
#
####################################################################################################
# Configure bridge interfaces #
###############################
#
# If br0 status is true
# so link status is up
#
sudo brctl addbr br0;
sudo ip link set dev eth2 down;
sudo ip add flush dev eth2;
sudo ip link set dev eth2 promisc on arp off up;
sudo ifconfig eth2 txqueuelen 10000;
sudo ethtool -K eth2 tso off;
sudo brctl addif br0 eth2;
sudo ip link set dev eth3 down;
sudo ip add flush dev eth3;
sudo ip link set dev eth3 promisc on arp off up;
sudo ifconfig eth3 txqueuelen 10000;
sudo ethtool -K eth3 tso off;
sudo brctl addif br0 eth3;
sudo brctl setfd br0 0
sudo brctl stp br0 off
sudo ip add flush dev br0;
sudo ip link set dev br0 up;
sudo sysctl -w net.ipv4.ip_forward=1
####################################################################################################
# Configure manager interfaces #
################################
#
# If eth4 status is true
# so link status is up
#
sudo ip link set dev eth4 down;
sudo ip add flush dev eth4;
sudo ip link set dev eth4 promisc on arp on up;
sudo ifconfig eth4 txqueuelen 1000;
sudo ethtool --offload eth4 rx off tx off;
sudo ethtool -K eth4 tso off;
#
# If eth3 status is true
# so link status is up
#
#
# If eth2 status is true
# so link status is up
#
#
# If eth1 status is true
# so link status is up
#
sudo ip add flush dev eth1;
sudo ip addr add 172.16.200.100/255.255.255.0 dev eth1;
sudo ip link set dev eth1 promisc off arp on up;
sudo ifconfig eth1 txqueuelen 1000;
sudo ethtool --offload eth1 rx on tx on;
sudo ethtool -K eth1 tso on;
#
# Manage interface eth0 is not manage
#
####################################################################################################
# Configure default routing #
#############################
sudo ip route del default
sudo ip route add default via 10.0.2.2
#!/bin/bash
#
# Configure network interfaces scripts
# Ansible managed: /vagrant/005-application/roles/sran.network-interfaces/templates/configure-network-interfaces.sh.j2 modified on 2016-03-14 22:42:44 by vagrant on ubuntu
#
####################################################################################################
# Configure bridge interfaces #
###############################
#
# If br0 status is false
# so link status is down
#
sudo brctl delif br0 eth2;
sudo brctl delif br0 eth3;
#
# Bring down bridge interface
# and remove interface
#
sudo ip link set dev br0 down;
sudo brctl delbr br0;
sudo sysctl -w net.ipv4.ip_forward=0
####################################################################################################
# Configure manager interfaces #
################################
#
# If eth4 status is true
# so link status is up
#
sudo ip add flush dev eth4;
sudo ip addr add 172.16.100.102/255.255.255.0 dev eth4;
sudo ip link set dev eth4 promisc off arp on up;
sudo ifconfig eth4 txqueuelen 1000;
sudo ethtool --offload eth4 rx on tx on;
sudo ethtool -K eth4 tso on;
#
# If eth3 status is true
# so link status is up
#
sudo ip add flush dev eth3;
sudo ip addr add 172.16.100.101/255.255.255.0 dev eth3;
sudo ip link set dev eth3 promisc off arp on up;
sudo ifconfig eth3 txqueuelen 1000;
sudo ethtool --offload eth3 rx on tx on;
sudo ethtool -K eth3 tso on;
#
# If eth2 status is true
# so link status is up
#
sudo ip add flush dev eth2;
sudo ip addr add 172.16.100.100/255.255.255.0 dev eth2;
sudo ip link set dev eth2 promisc off arp on up;
sudo ifconfig eth2 txqueuelen 1000;
sudo ethtool --offload eth2 rx on tx on;
sudo ethtool -K eth2 tso on;
#
# If eth1 status is true
# so link status is up
#
sudo ip add flush dev eth1;
sudo ip addr add 172.16.0.100/255.255.255.0 dev eth1;
sudo ip link set dev eth1 promisc off arp on up;
sudo ifconfig eth1 txqueuelen 1000;
sudo ethtool --offload eth1 rx on tx on;
sudo ethtool -K eth1 tso on;
#
# Manage interface eth0 is not manage
#
####################################################################################################
# Configure default routing #
#############################
sudo ip route del default
sudo ip route add default via 10.0.2.2
interfaces:
eth0: { ip_address: 192.168.100.10, netmask: 255.255.255.0, status: true, manage: false, mode: manage }
eth1: { ip_address: 172.16.200.100, netmask: 255.255.255.0, status: true, manage: true, mode: manage }
eth2: { ip_address: 172.16.100.100, netmask: 255.255.255.0, status: true, manage: true, mode: bridge_port }
eth3: { ip_address: 172.16.100.101, netmask: 255.255.255.0, status: true, manage: true, mode: bridge_port }
eth4: { ip_address: 172.16.200.102, netmask: 255.255.255.0, status: true, manage: true, mode: passive }
bridges:
br0: { bridge_ports: [eth2, eth3], status: true, manage: true }
routing:
default_gateway: 10.0.2.2
nameserver: [8.8.8.8, 127.0.1.1]
name: network
interfaces:
eth0: { ip_address: 192.168.100.10, netmask: 255.255.255.0, status: true, manage: false, mode: manage }
eth1: { ip_address: 172.16.0.100, netmask: 255.255.255.0, status: true, manage: true, mode: manage }
eth2: { ip_address: 172.16.100.100, netmask: 255.255.255.0, status: true, manage: true, mode: manage }
eth3: { ip_address: 172.16.100.101, netmask: 255.255.255.0, status: true, manage: true, mode: manage }
eth4: { ip_address: 172.16.100.102, netmask: 255.255.255.0, status: true, manage: true, mode: manage }
bridges:
br0: { bridge_ports: [eth2, eth3], status: false, manage: true }
routing:
default_gateway: 10.0.2.2
nameserver: [8.8.8.8, 127.0.1.1]
name: network
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment