03-Web-Setting
Check IP and Gateway¶
ipconfig
: Check both ip address for host and virtual machine (Windows)ifconfig
: Check both ip address for host and virtual machine (Linux)
ping + [Target ip]
: Check the connection between host and virtual machine
Bridged vs Network Address Translation (NAT) vs Host¶
Bridged Mode¶
Bridged mode allows the virtual machine to appear as a separate device on the host network.
It's as if the virtual machine has its own network adapter and IP address, independent of the host.
Bridged mode is suitable for scenarios where you need the virtual machine to be fully visible and accessible on the network, such as running server applications that need to be reachable from other devices.
Advantages
- Virtual machines in bridged mode can communicate directly with other devices on the network, including other virtual machines and physical machines.
Disadvantages
- Bridged mode requires assigning IP address to virtual machine
- Since virtual machines in bridged mode appear as separate devices on the network, they are susceptible to the same security risks as physical machines.
Network Address Translation (NAT)¶
NAT mode allows the virtual machine to share the host's IP address for outbound connections
while incoming traffic is routed to the virtual machine based on port forwarding rules.
NAT mode is suitable for scenarios where you need internet connectivity for the virtual machine but don't require direct inbound access from the network, such as browsing the web or downloading updates.
Advantages
- NAT mode provides internet connectivity to virtual machines without needing multiple public IP addresses. (created a local network)
- It adds an extra layer of security by hiding the virtual machine's IP address behind the host's IP address.
Disadvantages
- External network can not access the virtual machine directly.
Host-Only Mode¶
- Created a private network between host and virtual machine, can not access the external network.
Change to Static IP¶
Why we need static IP instead of dynamic?¶
- In a server mode, we do want to dynamically assign device IP address, we want every node (especially the virtual machine, since we need access them very often through the host) have a static IP for testing and maintenance purpose.
Change the Internet configuration file in Linux¶
su
: activate superuser authorityvim etc/sysconfig/network-scripts/ifcfg-ens33
Change BootProTO from
dhcp
tostatic
Add information about IP, Gateway and DNS
IPADDR = [Your wanted IP address]
GATEWAY = [Your wanted Gateway address]
DNS1 = [Your wanted DNS address]
reset the network service to activate our setting
service network restart
ping to check if the network is working
Change the host name¶
- Give every node a better memorable name is much convenient than access using IP address
hostname
: return the current host name
change hostname config file
vim /etc/hostname
: access the config file to change the hostname
change hostname using built-in tool
hostnamectl set-hostname "[your hostname]"
Save hostname and corresponding IP to config file¶
vim /etc/hosts
: get into the config fileChange the host file in Windows as well
- find the config file
- add node name and IP
Connect host / node using SSH / Xshell¶
- Connect to node
ssh [user name]@[node name]
- Use Xshell
- Transfer file
scp [options] [user@]host1:]source_file_or_directory ... [[user@]host2:]destination
- Use Xftp