How To Set Ip Address In Linux Command Line?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To set an IP address in Linux Command Line, use the ifconfig command.
1. Run the command “sudo ifconfig” to display the current network configuration.
2. Run the command “sudo ifconfig <interface> <desired_IP_address> netmask <desired_netmask>” to set a static IP address.
3. Run the command “sudo ifconfig <interface> up” to enable the interface.
4. If a gateway is required, run the command “sudo route add default gw <gateway_IP_address>” to set the gateway.
5. To save the changes, run the command “sudo /etc/init.d/networking restart”.