2

After setting the static IP address on vmware machine, restarted centos, here is that after I get this error:

Destination Host Unreachable
  1. I try to change NAT to Bridge but nothing change, indeed, I can not connect using Putty in Bridge mode via terminal
  2. nano ifcfg-ens33

    TYPE=Ethernet
    BOOTPROTO=static
    IPADDR=192.168.52.128
    BROADCAST=192.168.52.255
    NETMASK=255.255.255.0
    GATEWAY=192.168.160.1
    DEFROUTE=yes
    PEERDNS=yes
    PEERROUTES=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes
    IPV6_FAILURE_FATAL=no
    NAME=ens33
    UUID=(long)
    DEVICE=ens33
    ONBOOT=yes
    DNS1=8.8.8.8
    DNS2=8.8.4.4`
    
  3. /etc/resolv.conf

    #Generated by NetworkManager
    nameserver 8.8.8.8
    nameserver 8.8.4.4`
    
  4. lspci | egrep -i --color 'network|ethernet'

    02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
    
  5. I am able to ping myself.
    ping 127.0.0.1 return packets

  6. route

    [root@localhost ~]# route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    default         gateway         0.0.0.0         UG    100    0        0 ens33
    192.168.52.0    0.0.0.0         255.255.255.0   U     100    0        0 ens33
    gateway         0.0.0.0         255.255.255.255 UH    100    0        0 ens33
    
  7. ifconfig -a

    [root@localhost ~]# ifconfig -a
    ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.52.128  netmask 255.255.255.0  broadcast 192.168.52.255
            inet6 fe80::20c:29ff:fea1:d692  prefixlen 64  scopeid 0x20<link>
            ether 00:0c:29:a1:d6:92  txqueuelen 1000  (Ethernet)
            RX packets 81  bytes 8444 (8.2 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 129  bytes 15447 (15.0 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1  (Local Loopback)
            RX packets 126  bytes 11662 (11.3 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 126  bytes 11662 (11.3 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
  8. Network is active

    [root@localhost ~]# systemctl status NetworkManager
     NetworkManager.service - Network Manager
       Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
       Active: active (running) since sab 2017-06-10 14:29:39 CEST; 3min 36s ago
         Docs: man:NetworkManager(8)
     Main PID: 658 (NetworkManager)
       CGroup: /system.slice/NetworkManager.service
               └─658 /usr/sbin/NetworkManager --no-daemon
    
    giu 10 14:29:41 localhost.localdomain NetworkManager[658]: <info>  [149709778...
    

I need to have a static IP because I set up a server game

Thomas
  • 4,225
  • 5
  • 23
  • 28
Super Sonic
  • 21
  • 1
  • 1
  • 2

2 Answers2

2

Your configured gateway is outside of your subnet.

IPADDR=192.168.52.128
NETMASK=255.255.255.0
GATEWAY=192.168.160.1

You can reach addresses within the range 192.168.52.1..192.168.52.254 without a router/gateway.
If you want to reach addresses outside this range, you need a router/gateway. That router/gateway has to be in the reachable IP address range.

Thomas
  • 4,225
  • 5
  • 23
  • 28
  • mm..what IP should be insert to allow ping 8.8.8.8 works with packet returns ? Netmask of physical gateway is also 255.255.128.0 – Super Sonic Jun 10 '17 at 16:45
0

Setting a static IP on CentOS
To find the correct gateway, do:

nmtui
// select your ens18 or eth01 or your connection-name
Modify > IPV4 > select <Automatic>

Go to a terminal and type

ip route
// you'll get
// default via 172.16.0.22 <-- this is your gateway

To find the DNS server, do:

nslookup google.com
// you'll
// Server: 172.18.4.13 <-- this is your DNS

Now you can configure you static IP as follow:

nmtui > Modify connection
// select connection-name > Modify
select IPV4 Configuartion > Manual
// Addresses: enter your static IP address / 24; ex. 172.16.40.4/24
// Gateway: enter your gateway
// DNS server: enter your DNS server
Then you can tick "Connect automatically" > Save
nmcli con down connection-name // or deactivate/reactivate connection from nmtui gui
nmcli con up connection-name
y3zh
  • 1
  • 2