Networking

From wiki.mikejung.biz
Jump to: navigation, search

Liquidweb 728x90.jpg

List of sysctl tunables

This list is not complete and many of these settings might not always be appropriate, however I will start going through these at a later time to explain what they do.

echo 'net.core.wmem_max=12582912' >> /etc/sysctl.conf
echo 'net.core.rmem_max=12582912' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_rmem= 10240 87380 12582912' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_wmem= 10240 87380 12582912' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_sack = 1' >> /etc/sysctl.conf
echo 'net.core.netdev_max_backlog = 5000' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_tw_reuse=1' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_tw_recycle=1' >> /etc/sysctl.conf
echo 'net.ipv4.ip_local_port_range=1024 65535' >> /etc/sysctl.conf
sysctl -p

Virtual IP Address

You can add several virtual IP addresses to a physical network interface. A good starting point is to copy the interface definition file of the device you want to add a virtual IP address to.

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0 
  • You may have to modify ifcfg-eth0 to match your physical interface name.
  • Now you can edit the new file ifcfg-eth0:0 and specify the network settings of the virtual interface.
  • If you want the virtual IP address come up on boot, you need to remove
ONBOOT=YES

and make it

ONPARENT=YES

This makes the interface only come up when the parent interface comes up, while ONBOOT=YES would pull up the parent interface even if that is configured to not come up on boot.

  • To make the changes take effect please restart the network services using:
service network restart

ip_conntrack

Find the current limit

cat /proc/sys/net/ipv4/netfilter/ip_conntrack_max

Find the current amount of connections

cat /proc/sys/net/ipv4/netfilter/ip_conntrack_count

Raise this limit

sysctl net.ipv4.netfilter.ip_conntrack_max net.ipv4.netfilter.ip_conntrack_max =

Misc

Get network statistics

iptraf

New server missing some IPs it was supposed to come with?

 service ipaliases restart
 /scripts/rebuildippool

Networking commands

Show route table:

route -n

Ifconfig commands:

ifconfig ethX ip
ifconfig ethx netmask (netmask)
ifconfig ethx broadcast (broadcast)

Ubuntu Networking

Where all the nics are actually configured:

vim /etc/udev/rules.d/70-persistent-net.rules

Bonding info

cat /proc/net/bonding/bond0

Interface config

vim /etc/network/interfaces

IP Forwarding

To enable IP packet forwarding please edit /etc/sysctl.conf with your editor of choice and set:

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

You can then verify your settings with:

/sbin/sysctl -p