I installed CentOS 7 on a Hyper-V server. I want to manually assign IP to the server. This is done by editing file
The file name vary depending on the network interface you have.
Instead of editing the file via GUI, i prefer SSH in the server, then edit the file. For this, i assigned IP address to the server with command
ip addr add SERVER_IP_HERE dev INTERFACE_NAME
ip addr add 22.214.171.124 dev eth0
Here 126.96.36.199 is IP assigned to the server. eth0 is name of network interface.
Next we need to add route. To route traffic to internet, we need a gateway. In our cause server provider given IP 188.8.131.52 as gateway. To add route, run
ip route add GATEWAY_IP_ADDR dev INTERFACE_NAME ip route default via GATEWAY_IP_ADDR dev INTERFACE_NAME
ip route add 184.108.40.206 dev eth0 ip route add default via 220.127.116.11 dev eth0
Now i am able to connect to the server with its IP.
On CentOS 7, there is some changes, when you add IP to interface, use CIDR notation, for example
ip addr add IP_HERE/32 dev INTERFACE_NAME
When you add default route, use following command
ip route add 0.0.0.0/0 dev INTERFACE_NAME