Last active
December 4, 2018 20:09
-
-
Save sodonnell/cfbac5fef4b4bfdb8d8ea94d0a545dd5 to your computer and use it in GitHub Desktop.
Configuring Multiple IP Addresses on a single Network Interface
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
#!/usr/bin/env bash | |
# | |
# There are many custom use cases that require | |
# assigning multiple 'virtual' IP addresses to | |
# a single network interface. | |
# | |
# One case in particular, is for developing web applications | |
# locally on a workstation, to support a project that has multiple | |
# sub-domains. In such a case, you would create virtual IP addresses | |
# to support virtul hosts in apache/nginx. You would then associate the | |
# sub-domains to the virtual IP addresses, in your /etc/hosts file. | |
# | |
# example: | |
# | |
# 192.168.1.11 mysite.net | |
# 192.168.1.12 subdomain1.mysite.net | |
# 192.168.1.13 subdomain2.mysite.net | |
# | |
# This allows you to stage network connectivity (locally) during | |
# development and testing. | |
# | |
# Assign the initial 'physical' address of the NIC | |
ifconfig eth1 192.168.1.1 netmask 255.255.255.0 & | |
ifconfig eth1 up | |
# assign 192.168.1.11 to eth1:1 | |
ifconfig eth1:1 192.168.1.11 netmask 255.255.255.0 & | |
ifconfig eth1:1 up | |
# assign 192.168.1.12 to eth1:2 | |
ifconfig eth1:2 192.168.1.12 netmask 255.255.255.0 & | |
ifconfig eth1:2 up | |
# assign 192.168.1.13 to eth1:3 | |
ifconfig eth1:3 192.168.1.13 netmask 255.255.255.0 & | |
ifconfig eth1:3 up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment