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 18.104.22.168 dev eth0
Here 22.214.171.124 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 126.96.36.199 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 188.8.131.52 dev eth0 ip route add default via 184.108.40.206 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