The Linux command line modifies the methods of IP gateway and DNS

  • 2020-05-07 20:50:33
  • OfStack

The network card eth0       IP was changed to 102.168.0.1    
ifconfig eth0 102.168.0.1 netmask 255.255.255.0

The gateway was changed to 102.168.0.254
route add default gw 102.168.0.254

The Linux command line modifies DNS
echo "nameserver 202.202.202.20 ">> /etc/resolv.conf

Restart network service
service network restart

or
/etc/rc.d/init.d/network restrart

Related articles: