Ubuntu Network Configuration
Configure a temporary IP
Ifconfig eth0 192.168.3.136/24
Where 24 refers to the netmask 24 bits.
Vim/etc/network/interfaces Add the following:
Auto Eth0 #开机自动连接
Iface eth0 inet Static #静态IP
Address 192.168.1.112
Netmask 255.255.255.0
Gateway 192.168.1.1
If it is DHCP, add
Auto Eth0
Iface eth0 inet DHCP
DNS configuration:
Vim/etc/resolv.conf
NameServer 202.96.128.166
NameServer 202.96.134.133
NameServer 8.8.8.8
Add the IP addresses of some DNS servers (such as telecommunications) to the resolv.conf file.
Network restart:
sudo/etc/init.d/networking restart
To turn off the network card:
sudo ifconfig eth0 down
Open Network card
sudo ifconfig eth0 up
CentOS Network Configuration
In the networ-scripts directory, different NICs correspond to different configuration files.
sudo vim/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0
ipaddr=192.168.3.136
netmask=255.255.255.0
gateway=192.168.3.1
Hwaddr=00:0c:29:c1:78:f6
Onboot=yes #开机启动
Nm_controlled=yes
Bootproto=static
DNS Configuration
Vim/etc/resolv.conf
NameServer 202.96.128.166
NameServer 202.96.134.133
Service Restart:
sudo service network restart
Start
sudo service network start
Shut down
sudo service network stop
Ubuntu/centos Network Configuration