Troubleshooting connection loss (novice question)

Discussion in 'Linux Networking' started by Allen Weiner, Oct 29, 2007.

  1. Allen Weiner

    Bit Twister Guest

    It is pretty easy, you pick an ip in the range handled by your gateway.
    You have a Network Configuration set of screens, Instead of Automatic,
    you select Static and set ip address 192.168.1.147
    Mask 255.255.255.0
    gateway 192.168.1.1
    dns 192.168.1.1

    Look at my a.txt dump to see where all the information gets stored.
    If it does not work get back in Network Configuration and set it Automatic.
     
    Bit Twister, Nov 1, 2007
    #21
    1. Advertisements

  2. Allen Weiner

    Allen Weiner Guest

    Regarding your suggestion to turn off the service "avahi-daemon", I
    forgot to mention in my other reply of Oct. 31 that I checked with the
    information source I rely on for deletion of unneeded services,
    "Services in Fedora 7" by Mauriat Miranda (mjmwired.com). It confirms
    your suggestion, so I've deleted it.
     
    Allen Weiner, Nov 1, 2007
    #22
    1. Advertisements

  3. Allen Weiner

    Bit Twister Guest

    Another mod to your dump net script.
    You may want to add " | tail -10" to dmesg command

    echo "======== dmesg | grep eth$nic | tail -10 ==========" >> $_out_fn
    dmesg | grep eth$nic | tail -10 >> $_out_fn

    echo "======= grep eth$nic /var/log/messages | tail -10 =========" >> $_out_fn
    grep eth$nic /var/log/messages | tail -10 >> $_out_fn
     
    Bit Twister, Nov 1, 2007
    #23
  4. Allen Weiner

    Allen Weiner Guest

    It sure would be worthwhile in my case, with all of those iptables
    messages, to cut limit the size of the report. It seems to me, that the
    worthwhile stuff is at the head of dmesg. Wouldn't | head -10 be the
    better way to go?
     
    Allen Weiner, Nov 1, 2007
    #24
  5. Allen Weiner

    Bit Twister Guest

    I checked fedora's dmesg and saw oct 30 and oct 31 so I picked the
    tail instead of head.
     
    Bit Twister, Nov 1, 2007
    #25
  6. Allen Weiner

    Bit Twister Guest

    Or better yet, " | grep -v Inbound" instead of tail or head.
     
    Bit Twister, Nov 1, 2007
    #26
  7. Allen Weiner

    Allen Weiner Guest

    Looks good:

    [[email protected] ~]# dmesg | grep eth0 | grep -v Inbound
    e100: eth0: e100_probe: addr 0xfc9ff000, irq 11, MAC addr 00:07:E9:01:B2:09
    ADDRCONF(NETDEV_UP): eth0: link is not ready
    e100: eth0: e100_watchdog: link up, 100Mbps, full-duplex
    ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    eth0: no IPv6 routers present

    Also, I rebooted with avahi-daemon turned off. I issued dmesg. There
    were none of those tcp/ip transmissions Multicast DNS to/from port 5353.
     
    Allen Weiner, Nov 1, 2007
    #27
  8. Allen Weiner

    Allen Weiner Guest

    What change were you recommending for /var/log/messages? The most recent
    copy of your script that I have, has tail -10 for /var/log/messages. It
    also uses eth0 rather than eth$nic. If I replace the eth0 with eth$nic,
    then the a.txt reports on eth2, but not on eth0. Apparently, the
    /var/log/messages statement is outside of a loop that steps through $nic
    from 0 to 2, and I'm using the leftover value of 2.

    /var/lib/dhclient/dhclient-eth0.leases is not in a.txt. (I added the
    extra line that you gave me.)

    I added the | grep -v Inbound to the dmesg as you suggested. Since I
    reboot every day, I think | head -10 would have been OK for me.
     
    Allen Weiner, Nov 1, 2007
    #28
  9. Allen Weiner

    Bit Twister Guest

    Sorry, delete the two grep eth0 /var/log/messages lines,

    Those Four lines go inside the for nic loop above the line
    cat_fn /etc/sysconfig/network-scripts/ifcfg-eth$nic
     
    Bit Twister, Nov 1, 2007
    #29
  10. Allen Weiner

    Allen Weiner Guest

    I now have the four lines as you describe, and I deleted the two grep
    eth0 /var/log/messages lines.

    The output now displays /var/log/messages OK. It displays the comment
    line for dmesg but it no longer displays dmesg contents.

    I don't know if this is significant, but look at the change you gave me:

    tail_fn /var/lib/dhcp/dhclient-eth${nic}.leases
    tail_fn /var/lib/dhclient/dhclient-eth{nic}.leases <========
    tail_fn /etc/dhcpc/dhcpcd-eth${nic}.info

    The added line has eth{nic}, not eth${nic} like the other lines (i.e.
    missing $ after nic.
     
    Allen Weiner, Nov 1, 2007
    #30
  11. Allen Weiner

    Bit Twister Guest

    Hmmm, show me your code snippet or you can add
    some debugging controls and see what happens. Set commands
    enable/disable debugging. :)

    set -v
    echo "======== dmesg | grep eth$nic | grep -v SRC= ======" >> $_out_fn
    dmesg | grep eth$nic | grep -v SRC= >> $_out_fn
    set -
    Yup. needs the $ like the rest I screwed up.
    Sorry, should have booted into Fedora and tested my changes.

    Thank you for the feed back.
     
    Bit Twister, Nov 1, 2007
    #31
  12. Allen Weiner

    Allen Weiner Guest

    While I was editing my copy of the source, I mistyped something and got
    a strange ">>". I believe I corrected the error, but I apologize in
    advance if I didn't.

    Code snippet:

    for nic in 0 1 2 ; do

    if [ -n "$_cmd" ] ; then
    $_cmd eth$nic > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    echo ======== $_cmd eth$nic ========== >> $_out_fn
    $_cmd eth$nic >> $_out_fn
    fi
    fi

    echo "======== dmesg | grep eth$nic | grep -v Inbound ==========" >>
    $_out_fn
    dmesg | grep eth$nic | grep -v Inbound >> $_out_fn


    echo "======= grep eth$nic /var/log/messages | tail -10 ======" >>
    $_out_fn
    grep eth$nic /var/log/messages | tail -10 >> $_out_fn


    cat_fn /etc/sysconfig/network-scripts/ifcfg-eth$nic
     
    Allen Weiner, Nov 1, 2007
    #32
  13. Allen Weiner

    Allen Weiner Guest

    I added the $ and reran the script. The dhcp stuff showed up, and also
    dmesg content showed up. I doubt that there's a connection between the
    two. So I have no idea why dmesg showed up OK this time. But at least
    for this run, it looks like the script is OK.
     
    Allen Weiner, Nov 1, 2007
    #33
  14. Allen Weiner

    Bit Twister Guest

    Yep, been there, done that. What I do before I start playing around;
    cp script_fn script_fn.works
    That allows me to have a fallback.works if I realy dink something up.

    Also allows me to do a
    diff -bBw script_fn script_fn.works
    to check changes.


    Well, Up line problems can cause/hide downline problems.

    Assuming your lines look something like the above I do not see a problem.

    Beside the "set -v" and "set -" debugging commands, you can test commands
    at the command line.

    Assuming you are in a root terminal, you can test each command to see how
    it works. Just cut/paste each line to see what happens:

    nic=0
    dmesg
    dmesg | grep eth$nic
    dmesg | grep eth$nic | grep -v Inbound


    Now to check output to the file:

    _out_fn=a.txt
    cp /dev/null $_out_fn
    cat $_out_fn
    dmesg | grep eth$nic | grep -v Inbound >> $_out_fn
    cat $_out_fn

    If your script is still dinked up, here is new and improved.
    I changed the Inbound for SRC=


    #!/bin/bash
    #******** start of xx.txt script ****************

    _fn=a.txt
    _out_fn=$PWD/$_fn
    _dos_fn=$PWD/dos${_fn}
    _home=$PWD

    function cat_fn
    {
    _fn=$1
    if [ -f $_fn ] ; then
    _count=$(stat -c %s $_fn )
    if [ $_count -gt 0 ] ; then
    echo "======== cat $_fn ==========" >> $_out_fn
    cat $_fn >> $_out_fn
    fi
    fi
    } # end cat_fn

    function grep_fn
    {
    _fn=$1
    if [ -e $_fn ] ; then
    _count=$(stat -c %s $_fn )
    if [ $_count -gt 0 ] ; then
    _count=$(grep -v '^#' $_fn | wc -l)
    if [ $_count -gt 0 ] ; then
    echo "======== grep -v '^#' $_fn ==========" >> $_out_fn
    if [ "$_fn" != "shorewall.conf" ] ; then
    grep -v '^#' $_fn >> $_out_fn
    else
    awk 'empty{if (!/^#/) print; empty=0} /^$/{empty=1}' $_fn >> $_out_fn
    fi
    fi
    fi
    fi
    } # end grep_fn

    function ls_dir
    {
    _dr=$1
    if [ -d $_dr ] ; then
    echo "========= cd $_dr ; ls -al ========" >> $_out_fn
    cd $_dr
    ls -al >> $_out_fn
    fi
    } # end ls_dir

    function tail_fn
    {
    _fn=$1
    if [ -e $_fn ] ; then
    echo "======== tail -18 $_fn ==========" >> $_out_fn
    tail -18 $_fn >> $_out_fn
    fi
    } # end tail_fn

    #********************************
    # check if commands are in $PATH
    # and if not add them path to $PATH
    #********************************

    _path=""
    type ifconfig > /dev/null 2>&1
    if [ $? -ne 0 ] ; then
    _path="${_path}/sbin:"
    fi

    type cat > /dev/null 2>&1
    if [ $? -ne 0 ] ; then
    _path="${_path}/bin:"
    fi

    type id > /dev/null 2>&1
    if [ $? -ne 0 ] ; then
    _path="${_path}/usr/bin:"
    fi

    if [ -n "$_path" ] ; then
    PATH=${_path}$PATH
    export PATH
    fi

    #********************************
    # check if root and logged in correctly
    #********************************

    _uid=$(id --user)

    if [ $_uid -ne 0 ] ; then
    echo " "
    echo "You need to be root to run $0"
    echo "CLick up a terminal and do the following:"
    echo " "
    echo "su - root"
    echo "$PWD/xx"
    exit 1
    fi

    root_flg=1

    if [ -n "$LOGNAME" ] ; then
    if [ "$LOGNAME" != "root" ] ; then
    root_flg=0
    fi
    fi

    if [ -n "$USER" ] ; then
    if [ "$USER" != "root" ] ; then
    root_flg=0
    fi
    fi

    if [ $root_flg -eq 0 ] ; then
    echo " "
    echo "Guessing you did a su root"
    echo "instead of a su - root"
    echo "please exit/logout of this session and do the following:"
    echo " "
    echo "su - root"
    echo "$PWD/xx"
    echo " "
    exit 1
    fi


    #********************************
    # main code starts here
    #********************************


    echo "Working, output will be in $_out_fn "

    date > $_out_fn
    chmod 666 $_out_fn

    if [ -n "$_path" ] ; then
    echo "======== echo $PATH ==========" >> $_out_fn
    echo $PATH >> $_out_fn 2>&1
    fi

    cat_fn /etc/product.id

    echo "======== cat /etc/*release ==========" >> $_out_fn
    cat /etc/*release >> $_out_fn 2>&1

    echo "======== uname -rvi =============" >> $_out_fn
    uname -rvi >> $_out_fn

    echo "======== cat /etc/*version ==========" >> $_out_fn
    cat /etc/*version >> $_out_fn 2>&1

    echo "======== cat /proc/version ==========" >> $_out_fn
    cat /proc/*version >> $_out_fn 2>&1

    type lsb_release > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    echo "======== lsb_release -a ==========" >> $_out_fn
    lsb_release -a >> $_out_fn 2>&1
    fi

    echo " " >> $_out_fn
    if [ -n "$SECURE_LEVEL" ] ; then
    echo "msec security level is $SECURE_LEVEL" >> $_out_fn
    fi

    echo "======== free ==========" >> $_out_fn
    free >> $_out_fn 2>&1

    type chkconfig > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    echo "======== chkconfig --list ==========" >> $_out_fn
    for _serv in avahi named tmdns ; do
    chkconfig --list | grep -i $_serv > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    echo "Double check if /$_serv/ needs to be disabled on boot" >> $_out_fn
    chkconfig --list | grep -i $_serv >> $_out_fn
    fi
    done

    chkconfig --list >> $_out_fn

    else
    echo "======== ls -o /etc/rcS.d/ ==========" >> $_out_fn
    for _serv in avahi named tmdns ; do
    ls /etc/rcS.d/S* | grep $_serv > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    echo "Double check if /$_serv/ needs to be disabled on boot" >> $_out_fn
    fi
    done

    ls -o /etc/rcS.d >> $_out_fn
    fi

    _fn=/etc/nsswitch.conf
    if [ -e $_fn ] ; then
    echo "======== grep hosts: $_fn ==========" >> $_out_fn
    grep hosts: $_fn >> $_out_fn
    fi

    grep_fn /etc/resolv.conf

    grep_fn /etc/resolvconf/resolv.conf.d/head
    cat_fn /etc/resolvconf/resolv.conf.d/base
    cat_fn /etc/resolvconf/resolv.conf.d/tail


    echo "======== hostname ==========" >> $_out_fn
    hostname >> $_out_fn

    cat_fn /etc/netprofile/profiles/default/files/etc/hosts
    cat_fn /etc/hostname
    cat_fn /etc/HOSTNAME

    ls /etc/mod*.conf > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    echo "======== grep eth /etc/mod*.conf ==========" >> $_out_fn
    grep eth /etc/mod*.conf >> $_out_fn
    fi

    cat_fn /etc/dhclient-enter-hooks
    cat_fn /etc/dhclient-exit-hooks

    grep_fn /etc/host.conf

    echo "================ ifconfig -a ==============" >> $_out_fn
    ifconfig -a >> $_out_fn

    cat_fn /etc/iftab
    cat_fn /etc/udev/rules.d/61-net_config.rules

    echo "============== route -n =================" >> $_out_fn
    route -n >> $_out_fn

    cat_fn /etc/sysconfig/network/routes

    cat_fn /etc/sysconfig/network
    grep_fn /etc/mkinitramfs/initramfs.conf

    echo "========== head -15 /etc/hosts ===========" >> $_out_fn
    head -15 /etc/hosts >> $_out_fn

    cat_fn /etc/network/interfaces
    cat_fn /var/run/network/ifstate


    _cmd=""
    type ethtool > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    _cmd="ethtool"
    fi

    type mii-tool > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    _cmd="mii-tool -v"
    fi

    if [ -z "$_cmd" ] ; then
    echo "====== mii-tool/ethtool NOT INSTALLED ======" >> $_out_fn
    fi

    for nic in 0 1 2 ; do

    if [ -n "$_cmd" ] ; then
    $_cmd eth$nic > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    echo "======== $_cmd eth$nic ==========" >> $_out_fn
    $_cmd eth$nic >> $_out_fn
    fi
    fi

    echo "=== dmesg | grep eth$nic | grep -v SRC= ===" >> $_out_fn
    dmesg | grep eth$nic | grep -v SRC= >> $_out_fn

    echo "=== grep eth$nic /var/log/messages | tail -10 ===" >> $_out_fn
    grep eth$nic /var/log/messages | tail -10 >> $_out_fn

    cat_fn /etc/sysconfig/network-scripts/ifcfg-eth$nic

    ifconfig eth$nic > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    set $(ifconfig eth$nic | tr [A-Z] [a-z])
    cat_fn /etc/sysconfig/network/ifcfg-eth-id-$5
    fi

    tail_fn /var/lib/dhcp/dhclient-eth${nic}.leases
    tail_fn /var/lib/dhclient/dhclient-eth${nic}.leases
    tail_fn /etc/dhcpc/dhcpcd-eth${nic}.info

    done # end for nic in 0 1 2 ; do

    _dir=/etc/NetworkManager/dispatcher.d
    if [ -d $_dir ] ; then
    ls_dir $_dir

    for _d in "if-up.d" "if-down.d" "if-pre-up.d" "if-post-down.d" ; do
    if [ -e /etc/network/${_d} ] ; then
    echo "==== cd /etc/network/${_d} ; ls -al ===" >> $_out_fn
    cd /etc/network/${_d}
    ls -al >> $_out_fn
    fi
    done
    fi

    if [ -d /etc/sysconfig/network-scripts ] ; then
    for _d in "ifdown.d" "ifup.d" ; do
    if [ -e /etc/sysconfig/network-scripts/${_d} ] ; then
    _cmd="cd /etc/sysconfig/network-scripts/${_d} ; ls -al "
    echo "===== $_cmd ====" >> $_out_fn
    cd /etc/sysconfig/network-scripts/${_d}
    ls -al >> $_out_fn
    fi
    done
    fi

    ls_dir /etc/dhcp3/dhclient-exit-hooks.d
    ls_dir /etc/resolvconf/update.d


    if [ -d /etc/shorewall ] ; then
    _count=$(chkconfig --list shorewall | grep -c :eek:n )
    if [ $_count -gt 0 ] ; then
    echo "======= Shorewall settings =========" >> $_out_fn
    cd /etc/shorewall
    for _f in $(ls) ; do
    echo "======= $_f =========" >> $_out_fn
    grep_fn $_f
    done
    fi
    fi


    cd $_home

    grep_fn /etc/hosts.allow
    grep_fn /etc/hosts.deny
    echo "======= end of config/network data dump ===========" >> $_out_fn

    awk '{print $0 "\r" }' $_out_fn > $_dos_fn
    chmod 666 $_dos_fn


    echo " "
    echo "If posting via linux, post contents of $_out_fn"
    echo "You might want to copy it to your account with the command"
    echo "cp $_out_fn ~your_login"
    echo " "
    echo "If posting via windows, post contents of $_dos_fn"
    echo " "
    echo "If using diskette,"
    echo "Copy $_dos_fn to diskette with the following commands:"
    echo " "
    echo "mkdir -p /floppy"
    echo "mount -t auto /dev/fd0 /floppy"
    echo "cp $_dos_fn /floppy"
    echo "umount /floppy "
    echo " "
    echo "and $_dos_fn is ready for windows from diskette"
    echo " "

    #*********** end of dump xx.txt script *********
     
    Bit Twister, Nov 1, 2007
    #34
  15. Allen Weiner

    Allen Weiner Guest

    route -n after connection loss is the same as during connection.


    I'm looking into changing to static IP. I'm not there yet.
     
    Allen Weiner, Nov 1, 2007
    #35
  16. Allen Weiner

    Bit Twister Guest

    Well there was still a route to modem as far as fedora is concerned then.

    Looking more and more like modem is the one dropping the connection.
    That assumes there is no fancy code deciding to block 192.168.1.1
    based on all those firewall packets. I do not run Fedora so I can not
    help in that area.

    I assume you have changed default login/password in your router,
    if it allows you to do so.
    Hey, better to make the ignorant mistake instead of creating a stupid
    problem. It always helps to know something about what you are doing.

    When I feel I am about to do something which can take out the system,
    I'll copy the install into one of my spare partitions, change it's fstab,
    add a line to the boot loader, boot that copy, and play around there.

    For playing with my user account, I have a test account called, junk.
    I'll log into junk and screw around there. If works, make the change
    in bittwister.
     
    Bit Twister, Nov 2, 2007
    #36
  17. Allen Weiner

    Allen Weiner Guest

    Yes, I changed the password on the modem/router.

    I'm up and running with static IP, so we'll see what happens with
    connection loss.

    You may have missed my post today where I reported that my copy of your
    script is now running OK including dmesg and dhcp.

    Thanks for your help.
     
    Allen Weiner, Nov 2, 2007
    #37
  18. Allen Weiner

    Bit Twister Guest

    Nope, caught it, hope you saw the response and have the updated script.

    Thanks for your time playing with it.
     
    Bit Twister, Nov 2, 2007
    #38
  19. Allen Weiner

    Allen Weiner Guest

    Just out of curiosity, what is the reason for changing Inbound to SRC?

    Your script gives me a good impetus to improve my knowledge of BASH
    scripting. Ethtool runs OK with my NIC.If time permits, I will look at
    your script and see if I can get the ethtool report running.

    <snip source code>
     
    Allen Weiner, Nov 2, 2007
    #39
  20. Allen Weiner

    Bit Twister Guest

    More better. :)

    SRC= will work on an Inbound and an Outbound record.

    If you get Ethtool to work, just move the
    type ethtool > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
    _cmd="ethtool"
    fi

    below the test for mii-tool
     
    Bit Twister, Nov 2, 2007
    #40
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.