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 127.0.0.1

    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>
    </li>
    	<li>
    <blockquote>
    <div class="post-text">
    
    Is there any Linux command to translate domain name to IP?
    
    </div></blockquote>
    </li>
    </ul>
    You have multiple options to resolve this. You can use dig, nslookup as well as host.
    <pre>
    ~$ nslookup dropbox.com
    Server:		127.0.0.53
    Address:	127.0.0.53#53
    
    Non-authoritative answer:
    Name:	dropbox.com
    Address: 162.125.248.1
    Name:	dropbox.com
    Address: 2620:100:6040:1::a27d:f801
    
    ~$ dig dropbox.com
    
    ; &lt;&gt; DiG 9.11.3-1ubuntu1.5-Ubuntu &lt;&gt; dropbox.com
    ;; 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
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 65494
    ;; QUESTION SECTION:
    ;dropbox.com.			IN	A
    
    ;; ANSWER SECTION:
    dropbox.com.		48	IN	A	162.125.248.1
    
    ;; Query time: 35 msec
    ;; SERVER: 127.0.0.53#53(127.0.0.53)
    ;; WHEN: Mon Apr 15 21:16:32 CDT 2019
    ;; MSG SIZE  rcvd: 56
    $ host dropbox.com
    dropbox.com has address 162.125.248.1
    dropbox.com has IPv6 address 2620:100:6040:1::a27d:f801
    dropbox.com mail is handled by 1 aspmx.l.google.com.
    dropbox.com mail is handled by 10 aspmx2.googlemail.com.
    dropbox.com mail is handled by 10 aspmx3.googlemail.com.
    dropbox.com mail is handled by 5 alt1.aspmx.l.google.com.
    dropbox.com mail is handled by 5 alt2.aspmx.l.google.com.
    

    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.
    
    

    sddd

    • 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:

WordPress.com Logo

You are commenting using your WordPress.com 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