Tag Info

Hot answers tagged

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 ...


21

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, ...


20

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 ...


18

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 noting that transfer via scp/SSH is encrypted while transfer via netcat or HTTP isn't. So if you are transferring sensitive ...


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


12

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 ...


11

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 ...


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

This is easy enough to measure, at least if you nmap a host your machine is not otherwise communicating with. Just use tcpdump or wireshark to capture the traffic, limited to that IP address. You could also use iptables counters, etc. I did so (using wireshark), the machine I tested on has fewer open TCP ports (5), but the totals were 2009 packets, 118,474 ...


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

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

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


7

I've seen (broken) smart switches going down due to nmap activity, but that was when nmapping a subnet (so ARP traffic for a lot of different endpoints). That may be the kind of problem he's thinking of. Now Intrusion Detection Systems do try and detect port scanning activity and may be configured to block the IP address of the host doing the scanning. If ...


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

When using Network Manager the default contents of the file /etc/network/interfaces is typically this: auto lo iface lo inet loopback NOTE: That is from my Ubuntu 14.04 system, but Debian should be identical to this. Where's it come from? If you search to find out what package /etc/network/interfaces is a part of you'll find that it's not. $ dpkg -S ...


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

Use the "-o" option of ip: ip -o addr | sed -e 's/^[0-9]: \([^ ]*\).*inet \([^ \t]*\).*/\1: "\2"/;t;s/^[0-9]*: \([^ :]*\).*/\1: ""/g' | sort -r | sort -u -t: -k1,1 Output should be then in your case: br-priv: "" eth0: "192.168.1.123/24" lo: "127.0.0.1/8" wlan0: "10.42.0.10/24" The command prints only one IPv4 per network device (it is possible to ...


5

From a casual review of the source, it appears the author(s) were overzealous in their use of set_nonblock in sslh-select.c. If you flag every socket (as it does) as non-blocking, the the loop while(1) { select(… a bunch of non-blocking sockets …); } at around line 230 in the linked file becomes a busy-wait. That is, even if there is no data ...


5

You can add the following line to /etc/dhcp/dhclient.conf: prepend domain-name-servers <working DNS IP(s) here>; This adds the DNS IP address(es) you specify before that/those provided by the DHCP. If you would like to add it/them after the address(es) provided by the DHCP, just use append domain-name-servers <working DNS IP(s) here>; If, ...


5

This is as simple as it could be. You do not need any bridging. Just MASQUERADE your local network on RPi: iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE Enable forwarding of traffic: echo 1 > /proc/sys/net/ipv4/ip_forward RPi will not work as invisible bump-on-the-wire but will need a network setup between it and your private router – which ...


5

If you have this problem with every program you run, you should check your server firewall rule. Make sure that it only use NAT for external destination. Your route table make no sense if you have a wide NAT rule. After fixing firewall rule, for wget, you can use --bind-address option to chose what interface you want to use: wget ...


5

There are a few dozen versions of netcat available, but this is likely because: You have 2 entries for localhost in /etc/hosts. One for IPv4, another for IPv6. The daemon is only listening on one protocol (likely IPv4). The client is first connecting via the protocol the daemon isn't listening on, and then trying the one that it is. For example: $ grep ...


5

As someone rightly said once, Nothing is impossible in LinuxTM, I could achieve the kvm in my host with a bridged network over a wireless interface. These are the steps I followed to accomplish the same. I installed the virt-manager package to manage the installation more efficiently. I installed it as below. sudo apt-get install virt-manager Now, ...


5

Technically they should both use the same way of resolving addresses, however ping is likely not going to try resolving IPv6 addresses at all (AAAA records) and query directly A records as it's an IPv4-only tool (ping6 does IPv6 ICMP requests). A configuration issue I've seen in some load-balancing DNS servers backed by named (the same should apply no mater ...


5

1) You shouldn't manually update your resolv.conf, because all changes will be overwritten by data that your local DHCP server provides. If you want it to be static, run sudo dpkg-reconfigure resolvconf and answer "no" to dynamic updates. If you want to add new entries there, edit /etc/resolvconf/resolv.conf.d/base and run sudo resolvconf -u, it will append ...


5

Using Port 0 triggers the operating system to search for and allocate the next available port. This avoids you having to hard code a specific port or having to search for an available port. My Mint Linux system returns nc: port range not valid to nc localhost 0



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