I have a Box 'foo' which has sshd running. I wish to ssh to this machine via Box 'bar'. Box 'foo' has the IP address and Box 'bar' has the IP The gateway for both of these machines is If I am outside the LAN, I can ssh to Box 'foo' just fine.

I fear it has something to do with my iptables running on the gateway. Can someone double check my work for me? I can't figure it out.

Seems as there's no route between machines on the LAN. Should mention that Box 'foo' is connected to gateway via eth1 (gateway) and Box 'bar' is connected via wlan0 (gateway). Both these interfaces are bridged as 'br0'.

I have a firewall on box 'foo' however, it was disabled for testing.


I figured out that by changing the policy from Drop to Forward on iptables on gateway, connecting are allowed once again. Now my question is how can I insert a rule that allows LAN connections to occur while keeping Forward's polic on Drop?

$ cat /etc/ssh/sshd_config ## ON BOX 'foo'

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

# Subsystem sftp /usr/lib/openssh/sftp-server #out 2/20/16

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

# Allow limited users access to server
AllowUsers foouser XXXXXXXXXX  # <--- Censored

# SFTP Subsystem  
Subsystem sftp internal-sftp
Match group XXXXXXXXXX  #  <--- Censored
ChrootDirectory /srv/sftp
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp


# iptables -nvL ## ON gateway

Chain INPUT (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  lo     *             
  703 52346 ACCEPT     all  --  *      *              ctstate RELATED,ESTABLISHED
    0     0 ACCEPT     tcp  --  *      *              tcp dpt:22
    0     0 ACCEPT     tcp  --  *      *              tcp dpt:2022
    7   757 LOGNDROP   all  --  *      *             

Chain FORWARD (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  110 21617 ACCEPT     all  --  eth0   br0              ctstate RELATED,ESTABLISHED
  126 16289 ACCEPT     all  --  br0    eth0             
    0     0 ACCEPT     tcp  --  *      *              tcp dpt:22 state NEW,RELATED,ESTABLISHED

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      lo             
  590  173K ACCEPT     all  --  *      *              ctstate RELATED,ESTABLISHED

Chain LOGNDROP (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    7   757 LOG        all  --  *      *              LOG flags 0 level 4 prefix "iptables: "
    7   757 DROP       all  --  *      *  

Solved my own problem, the question I had after "edit".

Adding this rule to my Forward chain in iptables solved the issue

iptables -A FORWARD -i br0 -o br0 -j ACCEPT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.