Tag Info

Hot answers tagged

50

Looking at the RFC for TCP: RFC 793 - Transmission Control Protocol, the answer would seem to be no because of the fact that a TCP header is limited to 16-bits for the source/destination port field.      Does IPv6 improve things? No. Even though IPv6 will give us a much larger IP address space, 32-bit vs. 128-bits, it makes no attempt ...


23

Just to make sure we're on the same page (your question is ambiguous this way), asking to bind TCP on port 0 indicates a request to dynamically generate an unused port number. In other words, the port number you're actually listening on after that request is not zero. There's a comment about this in [linux kernel source]/net/ipv4/inet_connection_sock.c on ...


20

In the simplest terms, a socket is a pseudo-file that represents a network connection. Once a socket has been created (using the proper primitives, and the proper parameters to identify the other host), writes to the socket are turned into network packets that get sent out, and data received from the network can be read from the socket. In one regard, ...


19

The limit on "open files" is not really just for files. It's a limit on the number of kernel handles a single process can use at one time. Historically, the only thing that programs would typically open a lot of were files, so this became known as a limit on the number of open files. There is a limit to help prevent processes from say, opening a lot of files ...


17

Setting up a dummy interface If you want to create network interfaces, but lack a physical NIC to back it, you can use the dummy link type. You can read more about them here: iproute2 Wikipedia page. Creating eth10 To make this interface you'd first need to make sure that you have the dummy kernel module loaded. You can do this like so: $ sudo lsmod | ...


15

You're complicating your life needlessly. Use scp. To transfer a file myfile from your local directory to directory /foo/bar on machine otherhost as user user, here's the syntax: scp myfile user@otherhost:/foo/bar. EDIT: It is worth noticing that transfer via scp/SSH is encrypted while transfer via netcat or HTTP isn't. So if you are transferring sensitive ...


14

Well, lets separate into pieces, to make it more easier to understand /etc/network/interfaces: Link layer options(and generally the first of each interface Stanza): auto <interface> - Start the interface(s) at boot. That´s why lo interface uses this kind of linking configuration. allow-auto <interface> - Same as auto allow-hotplug ...


13

This is one of those things that surprises people because it goes against what they've been taught. 2 machines with the same hardware mac address on the same broadcast domain can talk to each other just fine as long as they have different IP addresses (and the switching gear plays nice). Lets start with a test setup: VM1 $ ip addr show dev enp0s8 3: ...


11

Your path looks ok, but does not include /sbin, which may be intended. You were probably looking for the command /sbin/ifconfig. If this file does not exist (try ls /sbin/ifconfig), the command may just be not installed. It is part of the package net-tools, which is not installed by default, because it's deprecated and superseeded by the command ip ...


10

In a screen or tmux session, set up a shell that will reverse your changes after a delay. I don't know anything about iptables, so can't help with that, but something like this has saved my proverbial bacon on numerous occasions while altering live firewall configs on FreeBSD: # In one `screen` or `tmux` window % sleep 60 && <command to reverse ...


10

The reason why TCP/IP sockets use file descriptors is that, when the sockets interface was first designed and implemented (in BSD Unix, in 1983), its designers felt that a network connection was analogous to a file - you can read, write, and close both, and that it would fit well with the Unix idea of "everything is a file". Other TCP/IP network stack ...


9

My solution is to bind to port 0, which asks the kernel to allocate a port from it's ip_local_port_range. Then, close the socket and use that port number in your configuration. This works because the kernel doesn't seem to reuse port numbers until it absolutely has to. Subsequent binds to port 0 will allocate a different port number. Python code: import ...


9

As written in the manual page, the /etc/networks file is to describe symbolic names for networks. With network, it is meant the network address with tailing .0 at the end. Only simple Class A, B or C networks are supported. In your example the google-dns entry is wrong. It's not a A,B or C network. It's an ip-address-hostname-relationship therefore it ...


8

That's a change in how now udevd assigns names to ethernet devices. Now your devices use the "Predictable Interface Names", which are based on (and quoting the sources): firmware/bios-provided index numbers for on-board devices firmware-provided pci-express hotplug slot index number physical/geographical location of the hardware the interface's MAC address ...


8

The 2 methods I've seen used predominately are to use ethtool or to manually parse the contents of /sys. ethtool For example if your interface is eth0 you can query it using ethtool and then parse for the line, "Link detected". Example $ sudo ethtool eth0 Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full ...


7

Assuming I'm reading correctly, your problem isn't that you want to know how to change the IP address, it's that you want to prevent changing it to something that stops future access. This isn't necessarily a technical problem, it's a quality issue. However, you might try something like this (you'll need to work out how to achieve it in detail). Write a ...


7

You should be able to find all open ports in /proc/net/tcp and /proc/net/udp. Each of those files have an inode column, which can be used to find the process owning that socket. Once you have an inode number, you can run an ls command such as ls -l /proc/*/fd/* | grep socket:.$INODE to find the processes using that socket. In case a process has been set up ...


7

You can use a modified version of this script to do what you want: #!/bin/bash downTime=0 lastAccessTime=$(date +"%s") while [ true ]; do if ! ping -c1 google.com >& /dev/null; then downTime=$(( $(date +"%s") - $lastAccessTime )) else downTime=0 lastAccessTime=$(date +"%s") fi sleep 15 if [ $downTime -ge 300 ]; then echo "alert" fi ...


7

Network interfaces can have different names on Linux depending on their type (wired Ethernet, Wi-Fi, PPP, SLIP, etc.), PCI slot, initialization order, etc. For example if a computer has a single Ethernet card, its name would be eth0*. In your case, there's a virtual private server without an Ethernet network card in it, not even an emulated one. ...


7

you want tcpdump not nc, and the syntax would be tcpdump -i eth0 netcat is only for basic TCP/IP testing. tcpdump utilizes the libpcap library which allows for lowlevel interactions with packets and the likes


6

Some ideas, assuming interfaces are eth0 and eth1: Sniff on both interfaces at the same time for non unicast traffic. You should see all packets twice ( tcpdump -nni eth0 -c 10 broadcast or multicast & tcpdump -nni eth1 -c 10 broadcast or multicast & ) | sort Probe with an IP-less protocol. For example with this tool to generate DHCP requests: ...


6

RRDTool and/or mrtg will do the trick. It stores the tx and rx counters of an interface (or any other metric you wish to provide) in a database and creates nice graphs of it. Been using it for for years.. http://oss.oetiker.ch/mrtg/


6

Some reasons I've found: Historical limitation: there is no MASK in the first implementation of tcpip, that means network nodes use the first number to distinguish network size and host ID. moreover, since class A is determined by its first octet, the higher-order bit is 0, so 127.x.x.x (01111111.x.x.x) is the latest segement of class A addresses. people ...


6

For tcp, just checking $?. If connection failed, $? won't be 0: $ >/dev/tcp/google.com/81 bash: connect: Network is unreachable bash: /dev/tcp/google.com/81: Network is unreachable $ echo $? 1 It will take time for bash to realize that the connection failed. You can use timeout to trigger bash: $ timeout 1 bash -c '>/dev/tcp/google.com/80' ...


6

If you're happy with netcat you can work around the file name issue by intruducing tar. This also simplifies sending multiple files at once as well as sending directories. On the sending side use: tar cf - <files> | nc <host> <port> And on the receiving side: nc -l <port> | tar x Another solution would be to use rsync or scp.


5

There is Danijel J's two options are good, but there is also a 3rd option if you have this working via the 'standard Ubuntu tool' using nmcli, which should already be installed at /usr/bin/nmcli. First, run nmcli c This will list your connections, with the first column being the SSID, and the second column being the UUID of the connection. Copy the UUID ...


5

Why does *BSD uses driver specific names for network interfaces? It's just a historical choice. The letters in the name come from the driver that talks to the card, so they will be the same for two separate interfaces if they happen to use the same driver. It does have one practical benefit: on BSD, the network drivers have their own manual pages in ...


5

The choice of using generic or driver-specific names has nothing to do with any driver limitation. It's mostly a cosmetic choice. Using generic names has the advantage of hiding information that is almost always irrelevant — a network interface is a network interface, no matter who made it. The capabilities of a device depend on the exact model and on its ...


5

iwlist is seriously deprecated. Remove it from your system and never use it again. Do the same with iwconfig, iwspy. Those tools are ancient and were designed in an era where 802.11n didn't exist. Kernel developers maintain a ugly compatibility layer to still support wireless-tools, and this compatibility layer often lies. Now install iw if not already ...


5

You can use a while loop in a shell script: failed=1 # any number not equal to zero while [ $failed -ne 0 ] do ping -n 8.8.8.8 failed=$? done # after the $? becomes "0" it will get out of the while loop echo "ping succeeded" To stop keep printing the connect: Network is unreachable message you can edit the line with ping like this: ping -n ...



Only top voted, non community-wiki answers of a minimum length are eligible