Page 1 of 2
Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/28 17:24:51
by iAnathema
I have the same problem!!!
If I switch to dhcp, all works correctly again.
My network-script:
Code: Select all
DEVICE=enp1s0
BOOTPROTO=static
NM_CONTROLLED="no"
#PERSISTENT_DHCLIENT=1
ONBOOT="yes"
TYPE=Ethernet
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME="eth0"
IPADDR=172.20.0.25
NETMASK=255.255.255.0
GATEWAY=172.20.0.1
DNS1 = 8.8.8.8
DNS2 = 8.8.4.4
Code: Select all
[root@server ~]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 172.20.0.1 0.0.0.0 UG 0 0 0 enp1s0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 enp1s0
172.20.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp1s0
[root@server ~]#
Code: Select all
[root@server ~]# cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.8.4
[root@server ~]#
Gateway Ping Stuck
Code: Select all
[root@server ~]# ping 172.20.0.1
PING 172.20.0.1 (172.20.0.1) 56(84) bytes of data.
^C
--- 172.20.0.1 ping statistics ---
13 packets transmitted, 0 received, 100% packet loss, time 11999ms
[root@server ~]#
Re: Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/28 22:45:09
by TrevorH
When you use DHCP, do you get assigned an ip address that's within 172.20.0.0/24?
Re: Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/29 08:29:25
by iAnathema
Yep...
For Example :
Dhcp give me the address 172.20.0.30 it's works.
After this if I set the static address 172.20.0.25....it doesn't work...
Then if I set the same static address that the Dhcp server gave to me(172.20.0.30), it's works!
Another stranger thing... If i ping from another host the static address, the ping work, but backwards I can't ping no host from my CentOS server in my network except localhost and itself
I'm going mad!
Re: Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/29 10:35:25
by TrevorH
Post the output from ip route show from both DHCP (working) and non-working static setups.
Re: Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/29 10:45:26
by iAnathema
DHCP
Code: Select all
[root@localhost ~]# ifconfig
enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.20.0.30 netmask 255.255.255.0 broadcast 172.20.0.255
inet6 fe80::7ed3:aff:fe2e:4d8e prefixlen 64 scopeid 0x20<link>
ether 7c:d3:0a:2e:4d:8e txqueuelen 1000 (Ethernet)
RX packets 2493 bytes 299246 (292.2 KiB)
RX errors 0 dropped 64 overruns 0 frame 0
TX packets 5178 bytes 5238082 (4.9 MiB)
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 808 bytes 419820 (409.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 808 bytes 419820 (409.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]# ip route show
default via 172.20.0.1 dev enp1s0
169.254.0.0/16 dev enp1s0 scope link metric 1002
172.20.0.0/24 dev enp1s0 proto kernel scope link src 172.20.0.30
[root@localhost ~]# ping 172.20.0.1
PING 172.20.0.1 (172.20.0.1) 56(84) bytes of data.
64 bytes from 172.20.0.1: icmp_seq=1 ttl=64 time=0.280 ms
64 bytes from 172.20.0.1: icmp_seq=2 ttl=64 time=0.250 ms
64 bytes from 172.20.0.1: icmp_seq=3 ttl=64 time=0.249 ms
64 bytes from 172.20.0.1: icmp_seq=4 ttl=64 time=0.242 ms
64 bytes from 172.20.0.1: icmp_seq=5 ttl=64 time=0.422 ms
64 bytes from 172.20.0.1: icmp_seq=6 ttl=64 time=0.285 ms
64 bytes from 172.20.0.1: icmp_seq=7 ttl=64 time=0.284 ms
^C
--- 172.20.0.1 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6000ms
rtt min/avg/max/mdev = 0.242/0.287/0.422/0.059 ms
[root@localhost ~]#
Static IP
Code: Select all
[root@localhost ~]# ifconfig
enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.20.0.25 netmask 255.255.255.0 broadcast 172.20.0.255
inet6 fe80::7ed3:aff:fe2e:4d8e prefixlen 64 scopeid 0x20<link>
ether 7c:d3:0a:2e:4d:8e txqueuelen 1000 (Ethernet)
RX packets 1168 bytes 136294 (133.0 KiB)
RX errors 0 dropped 32 overruns 0 frame 0
TX packets 2344 bytes 2292480 (2.1 MiB)
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 293 bytes 173948 (169.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 293 bytes 173948 (169.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]# ip route show
default via 172.20.0.1 dev enp1s0
169.254.0.0/16 dev enp1s0 scope link metric 1002
172.20.0.0/24 dev enp1s0 proto kernel scope link src 172.20.0.25
[root@localhost ~]# ping 172.20.0.1
PING 172.20.0.1 (172.20.0.1) 56(84) bytes of data.
Ping stuck!
Re: Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/29 11:03:37
by iAnathema
Another clue.
If i ping from server an inexistent address it resposes: "Destination Host Unreachable",
while if it exists the ping stuck
Re: Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/29 12:20:36
by pjsr2
Dhcp give me the address 172.20.0.30 it's works.
After this if I set the static address 172.20.0.25....it doesn't work...
Then if I set the same static address that the Dhcp server gave to me(172.20.0.30), it's works!
Do you have a router/switch between your computer and the gateway (172.20.0.1) that restricts network traffic to only traffic originating from the IP address range that is provided by the DHCP server?
Re: Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/29 13:06:05
by iAnathema
Yep, but i tried to make a connect Host2Host with my notebook ad result was the same
Re: Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/29 16:13:07
by TrevorH
What pool is your DHCP server set up to hand out? Perhaps you need to pick a static ip from outside of the range it believes belongs to it to assign.
Re: Not able to connect to the internet after configuring a static ip in centos 7
Posted: 2017/12/30 15:12:38
by pjsr2
VLAN ?