change the DHCP address to static address at home

Quoted from the web-site below:

https://www.howtoforge.com/linux-basics-set-a-static-ip-on-ubuntu

In your home network, when you installed a ubuntu linux PC, the address will be a DHCP assigned address. If you want to use port forward function to forward the data from internet to your server, the address has to be static. How to set port forward function on the router is beyond this topic.

2 pointers:

  1. Example for ubuntu 16.04:

#This file describes the network interfaces available on your system
#and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/

#The loopback network interface
auto lo
iface lo inet loopback

#test

#The primary network interface
auto ens33
iface ens33 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4

The domain name server for google in china is not available. Last line can be removed. You need to supply your own DNS server in China if needed a real system hostname.

  1. The above modification is sufficient for the local hostname of your unbuntu PC to be recognized by any another pc within your home network. It seems that the router will resolve the local hostname?

转载于:https://blog.51cto.com/greg10/2071187

你可能感兴趣的:(change the DHCP address to static address at home)