Last active
December 29, 2015 06:29
-
-
Save pasupulaphani/7629545 to your computer and use it in GitHub Desktop.
Working with vagrant.1. vagrantFile with port forwarded and nat enabled2. Opening ports on vm instance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "centos_6.4" | |
config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box" | |
# Enable access via "localhost:8080" to access port 80 on the guest machine. | |
config.vm.network :forwarded_port, guest: 80, host: 8080, auto_correct: true | |
config.vm.provider :virtualbox do |vb| | |
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | |
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] | |
end | |
Vagrant::Config.run do |config| | |
config.vm.provision :chef_client do |chef| | |
chef.chef_server_url = "https://api.opscode.com/organizations/orgname" | |
chef.validation_key_path = "path to pem file" | |
chef.environment = "development" | |
chef.run_list = ["recipe[iptables]"] | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With RHEL 7 / CentOS 7, firewalld was introduced to manage iptables. IMHO, firewalld is more suited for workstations than for server environments. | |
# It is possible to go back to a more classic iptables setup. First, stop and mask the firewalld service: | |
systemctl stop firewalld | |
systemctl mask firewalld | |
# Then, install the iptables-services package: | |
yum install iptables-services | |
# Enable the service at boot-time: | |
systemctl enable iptables | |
# Managing the service | |
systemctl [stop|start|restart] iptables | |
# Saving your firewall rules can be done as follows: | |
service iptables save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh -p 2222 [email protected] | |
pass: vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Opening up ports: | |
To access apps hosted on your VM from your machine. | |
You may have to open up some ports on a linux vm or a machine. | |
You need to open port to accept or allow connections in iptables | |
## allow everyone to access port 80 and 443 (IPv4 Only)## | |
vi /etc/sysconfig/iptables | |
-A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT | |
-A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT | |
Note:All ACCEPT lines should be above REJECT lines in the cofiguration | |
# restart service | |
service iptables restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment