LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-05-2016, 10:03 AM   #1
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Rep: Reputation: 0
Unhappy Why default gateway goes away after reboot??


Good Folks,

Can you please guide me to have a default gateway on my centos 7 VM as permanent solution??

Pre adding default gateway configuration is
Code:
[root@agent1 ~]# ip route
169.254.0.0/16 dev enp0s3  scope link  metric 1002 
192.168.1.0/24 dev enp0s3  proto kernel  scope link  src 192.168.1.3 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
[root@agent1 ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 08:00:27:67:fe:aa brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT 
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 500
    link/ether 52:54:00:56:92:94 brd ff:ff:ff:ff:ff:ff
[root@agent1 ~]# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 enp0s3
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
[root@agent1 ~]# route add default gw 192.168.1.1 enp0s3
[root@agent1 ~]# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 enp0s3
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 enp0s3
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
[root@agent1 ~]# ip route
default via 192.168.1.1 dev enp0s3 
169.254.0.0/16 dev enp0s3  scope link  metric 1002 
192.168.1.0/24 dev enp0s3  proto kernel  scope link  src 192.168.1.3 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
[root@agent1 ~]#
Here is a list of configuration files after system is boot up.

Code:
[root@agent1 ~]# ./spit-out.sh 
+ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.2 puppet master
192.168.1.3 agent1 machine1
192.168.1.4 agent2 machine2
192.168.1.5 agent3 machine3
+ cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=no
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=enp0s3
UUID=d490afd5-e894-4ed5-a9ca-1b4d984c9a25
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.1.3
GATEWAY=192.168.1.1
NM_CONTROLLED=no
NETMASK=255.255.255.0
PREFIX=24
DNS1=192.168.1.1
+ cat /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
NETWORKING_IPV6=no
+ cat /etc/resolv.conf
nameserver 192.168.1.1
+ grep dhcp
+ grep -v grep
+ ps -ef
nobody    2693     1  0 00:53 ?        00:00:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
root      2694  2693  0 00:53 ?        00:00:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
+ systemctl status network.service -l
● network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network)
   Active: failed (Result: exit-code) since Wed 2016-07-06 00:55:28 AEST; 46s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 3301 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)

Jul 06 00:55:28 agent1 network[3301]: RTNETLINK answers: File exists
Jul 06 00:55:28 agent1 network[3301]: RTNETLINK answers: File exists
Jul 06 00:55:28 agent1 network[3301]: RTNETLINK answers: File exists
Jul 06 00:55:28 agent1 network[3301]: RTNETLINK answers: File exists
Jul 06 00:55:28 agent1 network[3301]: RTNETLINK answers: File exists
Jul 06 00:55:28 agent1 network[3301]: RTNETLINK answers: File exists
Jul 06 00:55:28 agent1 systemd[1]: network.service: control process exited, code=exited status=1
Jul 06 00:55:28 agent1 systemd[1]: Failed to start LSB: Bring up/down networking.
Jul 06 00:55:28 agent1 systemd[1]: Unit network.service entered failed state.
Jul 06 00:55:28 agent1 systemd[1]: network.service failed.
+ systemctl status NetworkManager -l
● NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2016-07-06 00:55:26 AEST; 48s ago
 Main PID: 3215 (NetworkManager)
   CGroup: /system.slice/NetworkManager.service
           └─3215 /usr/sbin/NetworkManager --no-daemon

Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  startup complete
Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  (virbr0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  (virbr0): device state change: prepare -> config (reason 'none') [40 50 0]
Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  (virbr0): device state change: config -> ip-config (reason 'none') [50 70 0]
Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  (virbr0): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  wpa_supplicant running
Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  (virbr0): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  (virbr0): device state change: secondaries -> activated (reason 'none') [90 100 0]
Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  NetworkManager state is now CONNECTED_LOCAL
Jul 06 00:55:26 agent1 NetworkManager[3215]: <info>  (virbr0): Activation: successful, device activated.
+ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:67:fe:aa brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.3/24 brd 192.168.1.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe67:feaa/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 500
    link/ether 52:54:00:56:92:94 brd ff:ff:ff:ff:ff:ff
+ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 08:00:27:67:fe:aa brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT 
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 500
    link/ether 52:54:00:56:92:94 brd ff:ff:ff:ff:ff:ff
+ netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 enp0s3
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
+ ip route
169.254.0.0/16 dev enp0s3  scope link  metric 1002 
192.168.1.0/24 dev enp0s3  proto kernel  scope link  src 192.168.1.3 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
+ ping -c 5 google.com
connect: Network is unreachable
+ ping -c 5 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=6.73 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.75 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=2.58 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=1.15 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=1.06 ms

--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4008ms
rtt min/avg/max/mdev = 1.068/2.659/6.735/2.108 ms
+ systemctl restart NetworkManager
+ systemctl restart network.service
Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
+ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.2 puppet master
192.168.1.3 agent1 machine1
192.168.1.4 agent2 machine2
192.168.1.5 agent3 machine3
+ cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=no
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=enp0s3
UUID=d490afd5-e894-4ed5-a9ca-1b4d984c9a25
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.1.3
GATEWAY=192.168.1.1
NM_CONTROLLED=no
NETMASK=255.255.255.0
PREFIX=24
DNS1=192.168.1.1
+ cat /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
NETWORKING_IPV6=no
+ cat /etc/resolv.conf
nameserver 192.168.1.1
+ ps -ef
+ grep dhcp
+ grep -v grep
nobody    2693     1  0 00:53 ?        00:00:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
root      2694  2693  0 00:53 ?        00:00:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
+ ping -c 5 google.com
connect: Network is unreachable
+ ping -c 5 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.40 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.08 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.929 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=2.04 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=2.18 ms

--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 0.929/1.529/2.186/0.504 ms
+ traceroute google.com
traceroute to google.com (220.244.136.50), 30 hops max, 60 byte packets
connect: Network is unreachable
[root@agent1 ~]#
Another question is why some sort of dhcp process is lingering around, is that required? can we stop it?? I am not sure if that is responsible for the error message "Connection Failed: Failed to activate network connection" error on boot up.

Your guidance is like always would be very much appreciated.
 
Old 07-05-2016, 12:26 PM   #2
crazy-yiuf
Member
 
Registered: Nov 2015
Distribution: Debian Sid
Posts: 119

Rep: Reputation: 51
I'm not super familiar with the Redhat style networking configs, but it looks to me like you should either be bringing the network up with ifup instead of network manager (probably my preferred method for a stationary computer) or change NM_CONTROLLED=no to yes.

On the second question: yes, it's my understanding that some sort of DHCP client needs to occasionally talk to your router and make sure they're still in agreement, as well as a supplicant for rekeying if you're using WPA/WPA2. You can look at your network log file (for rsyslog) or sudo journalctl -r (for journald) to see what it's doing, mine says it renews every 33,000 seconds or so.

There are alternatives to using DHCP, but I don't recommend them.

Last edited by crazy-yiuf; 07-05-2016 at 12:59 PM.
 
Old 07-05-2016, 01:48 PM   #3
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,138

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
From the Redhat spec

Code:
DEFROUTE=<answer>, where <answer> is one of the following:
    yes  Set this interface as the default route.
    no  Do not set this interface as the default route.
 
1 members found this post helpful.
Old 07-21-2016, 07:42 AM   #4
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
Yes , DEFROUTE=yes is the answer as for rest everything was in tact. with DEFROUTE=no even if I add a default route it used to go away after reboot. Another to consider is delete all IPV6 settings as well. Thread be closed. Thanks very much for your help Guys ! This forum is super amazing !!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adding default gateway and aditional gateway veru.naresh Linux - Networking 1 06-13-2012 07:34 AM
normal default gateway reapperas with openvpn redirect-gateway jonnytabpni Linux - Networking 2 04-23-2009 02:11 PM
. as default gateway serge Linux - Networking 3 01-31-2009 09:39 AM
default gateway changes on reboot vbsaltydog Linux - Networking 2 04-19-2006 03:04 PM
lm10.0 gateway is set but when I reboot I have to set the gateway rharvey32 Mandriva 8 02-13-2006 01:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration