Troubleshooting Linux: Part 1

  • I am looking for a command line solution that would return me the primary (first) IP address of the localhost, other than

    The solution should work at least for Linux (Debian and RedHat) and OS X 10.7+

    I am aware that ifconfig is available on both but its output is not so consistent between these platforms.

    ip route get 1 | awk '{print $(NF-3); exit}'</pre>
    <div class="post-text">
    Is there any Linux command to translate domain name to IP?
    You have multiple options to resolve this. You can use dig, nslookup as well as host.
    ~$ nslookup
    Non-authoritative answer:
    Address: 2620:100:6040:1::a27d:f801
    ~$ dig
    ; &lt;&gt; DiG 9.11.3-1ubuntu1.5-Ubuntu &lt;&gt;
    ;; global options: +cmd
    ;; Got answer:
    ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 1369
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
    ; EDNS: version: 0, flags:; udp: 65494
    ;			IN	A
    ;; Query time: 35 msec
    ;; SERVER:
    ;; WHEN: Mon Apr 15 21:16:32 CDT 2019
    ;; MSG SIZE  rcvd: 56
    $ host has address has IPv6 address 2620:100:6040:1::a27d:f801 mail is handled by 1 mail is handled by 10 mail is handled by 10 mail is handled by 5 mail is handled by 5

    As you can see above, most of them returned the non-authoritative answer to your request.

    • I am programming a server and it seems like my number of connections is being limited since my bandwidth isn't being saturated even when I've set the number of connections to "unlimited".

      How can I increase or eliminate a maximum number of connections that my Ubuntu Linux box can open at a time? Does the OS limit this, or is it the router or the ISP? Or is it something else?

    #on client side, modify your tcp stack parameters
    sysctl net.ipv4.ip_local_port_range #increasing this will increase the number of ports connections you can make over a single IP
    sysctl net.ipv4.tcp_fin_timeout #This answers the question of, how long to hold on to socket while in wait state.
    sysctl net.ipv4.tcp_tw_reuse=1 #This indicates that socket can be used for making connection while in time wait. Please be careful with this option. I can fully explain why lol
    #on server side
    sysctl net.core.somaxconn=1024 #This decides how many requsts a listening socket can queue.
    ifconfig eth0 txqueuelen 5000 #This sets the number of traffic that can be queue on your network card.
    sysctl net.core.netdev_max_backlog=2000 #This defines how many of those networks that made it through the NIC will be queued
    sysctl net.ipv4.tcp_max_syn_backlog=2048 #Thia queue decides how many unacknowdleged sync can be held.


    • Is there some simple sysctl variable to allow non-root processes to bind to "privileged" ports (ports less than 1024) on Linux, or am I just out of luck?

    Yes, you can use option to set net.ipv4.ip_unprivileged_port_start. This allow you to control where "privledge" port starts.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s