Ubuntu network card address configuration, setting DNS and hostname (transfer)

http://blog.chinaunix.net/uid-656828-id-3098797.html
Ubuntu system network configuration sometimes does not work with the graphical interface, in this case, you can directly modify some startup scripts or configuration files
Ubuntu system network configuration involves several configuration files 1./etc/network/interfaces 2./etc/resolv.conf
Manipulation steps:
1. Open the /etc/network/interfaces file of ubuntu. The default content is as follows:
auto lo
iface lo inet loopback
Dynamically obtained configuration method:
auto eth0
iface eth0 inet dhcp
Configuration method for static allocation:
auto eth0
iface eth0 inet static
address 192.168.0.1
netmask  255.255.255.0
gateway  192.168.0.1
Modify the configuration file and save it according to the configuration requirements (whether it is dynamically allocated or automatically obtained).
 
2. Add a domain name server: Open the /etc/resolv.conf file
 Add this line: nameserver 202.99.166.4
 
3. Restart the network
$/etc/init.d/networking restart (this command is to restart the network card)
or
$ifdown eth0
$ifup eth0 (These two commands are targeted to restart a network interface, because a system may have multiple network interfaces)
 
4. Check whether the parameters of the network configuration are correct ( you can check whether the network configuration has been modified every time you perform an operation )
$ifconfig
 
5. See if it can be pinged
If the gateway cannot be pinged, there is a problem with the network configuration. If the domain name cannot be pinged, there is a problem with the dns.
 
Sometimes it is necessary to modify the hardware address of the network card:
method one:
$ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX
$/etc/init.d/networking restart (restart the network card)
Method Two:
The above is only a temporary modification of the hardware address. To be permanently modified, edit the /etc/network/interfaces file directly, and add a line after iface eth0 inet static: pre-up ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx (to be changed to MAC)
$ sudo /etc/init.d/networking restart (restart the network card)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326262592&siteId=291194637